-
Notifications
You must be signed in to change notification settings - Fork 8
bug: EndpointNotFoundError not managed when fetching decisional context for optimization unit #72
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
Description
The API endpoint GET /api/v1/optimization-units/{unit_id}/decisional-context returns a 500 Internal Server Error when the configured Home Assistant entity does not exist.
The error originates from the homeassistant_api library, which raises an EndpointNotFoundError when attempting to query the state of an entity that cannot be found on the Home Assistant instance. This exception is not caught anywhere in the call chain, causing it to propagate up as an unhandled ASGI exception.
Error
homeassistant_api.errors.EndpointNotFoundError: Cannot make request to the endpoint
'http://172.16.50.110:8123/api/states/sensor.sdm230_rete_active_power2'
Stacktrace
router.py:429 in get_decisional_context
→ optimization_service.get_decisional_context(unit_id)
optimization_service.py:180 in get_decisional_context
→ energy_monitor.get_current_energy_state()
home_assistant_api.py:339 in get_current_energy_state
→ self.home_assistant.get_entity_state(self.entity_grid)
homeassistant_api.py:117 in get_entity_state
→ self.client.get_entity(entity_id=entity_id)
homeassistant_api (library) → raises EndpointNotFoundError
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working