Skip to content

Commit

Permalink
Trigger event on failure (#573)
Browse files Browse the repository at this point in the history
  • Loading branch information
tetienne authored Sep 29, 2021
1 parent d85c122 commit 47c92c6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,31 @@ After installation this integration adds new services to Home Assistant which ca
+ Overkiz (by Somfy): Execute command (tahoma.execute_command)
+ Overkiz (by Somfy): Get execution history (tahoma.get_execution_history)

## Events
This component listen for events returned by Overkiz. In case of command failure, the event will forwarded to Home Assistant.

You can subscribe to the `overkiz.event` event type in Developer Tools/Events in order to examine the event data JSON for the correct parameters to use in your automations. For example, `overkiz.event` returns event data JSON similar to the following when your cover is blocked.

```JSON
{
"event_type": "overkiz.event",
"data": {
"event_name": "ExecutionStateChangedEvent",
"failure_type_code": 106,
"failure_type": "CMDCANCELLED"
},
"origin": "LOCAL",
"time_fired": "2021-09-28T20:03:57.102478+00:00",
"context": {
"id": "92a84240d914b43ceaf1aee3249568f6",
"parent_id": null,
"user_id": null
}
}
```

You can find the list of available failure_type [here](https://github.com/iMicknl/python-tahoma-api/blob/master/pyhoma/enums.py#L118).

### Enable debug logging

The [logger](https://www.home-assistant.io/integrations/logger/) integration lets you define the level of logging activities in Home Assistant. Turning on debug mode will show more information about unsupported devices in your logbook.
Expand Down
10 changes: 10 additions & 0 deletions custom_components/tahoma/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ async def _async_update_data(self) -> Dict[str, Device]:
for event in events:
_LOGGER.debug(event)

if event.failure_type_code:
self.hass.bus.fire(
"overkiz.event",
{
"event_name": event.name.value,
"failure_type_code": event.failure_type_code.value,
"failure_type": event.failure_type,
},
)

if event.name == EventName.DEVICE_AVAILABLE:
self.devices[event.deviceurl].available = True

Expand Down

0 comments on commit 47c92c6

Please sign in to comment.