iMicknl / python-overkiz-api

Async Python wrapper to interact with internal Somfy TaHoma API, or other OverKiz API's.
MIT License
48 stars 29 forks source link

get_current_execution crashes #22

Closed vlebourl closed 4 years ago

vlebourl commented 4 years ago
2020-07-28 16:21:19 ERROR (MainThread) [custom_components.tahoma] Unexpected error fetching TaHoma Event Fetcher data: type object argument after ** must be a mapping, not str
Traceback (most recent call last):
  File "/Users/vlb/PycharmProjects/ha-tahoma/venv/lib/python3.7/site-packages/homeassistant/helpers/update_coordinator.py", line 139, in async_refresh
    self.data = await self._async_update_data()
  File "/Users/vlb/PycharmProjects/ha-tahoma/Config/custom_components/tahoma/coordinator.py", line 51, in _async_update_data
    execution = await self.client.get_current_execution(event.exec_id)
  File "/Users/vlb/PycharmProjects/ha-tahoma/venv/lib/python3.7/site-packages/tahoma_api/client.py", line 124, in get_current_execution
    executions = [Execution(**e) for e in humps.decamelize(response)]
  File "/Users/vlb/PycharmProjects/ha-tahoma/venv/lib/python3.7/site-packages/tahoma_api/client.py", line 124, in <listcomp>
    executions = [Execution(**e) for e in humps.decamelize(response)]
TypeError: type object argument after ** must be a mapping, not str
tetienne commented 4 years ago

Can you try please to catch the response you got?

vlebourl commented 4 years ago

I believe in this case Execution(**humps.decamelize(response)) is working. sample response:

{'actionGroup': {'actions': [{'commands': [{'name': 'setClosure',
                                            'parameters': [7],
                                            'type': 1}],
                              'deviceURL': 'io://xxxxxx'}],
                 'label': 'Velux Palier - Régler à 7% - TaHoma PC',
                 'notificationCondition': 'NEVER',
                 'notificationTypeMask': 0,
                 'shortcut': False},
 'description': 'Execution : Velux Palier - Régler à 7% - TaHoma PC',
 'executionSubType': 'MANUAL_CONTROL',
 'executionType': 'Immediate execution',
 'id': '95d77df3-ac10-3e01-2775-8dbb9330a189',
 'owner': 'xx@xxxm',
 'startTime': 1595946794485,
 'state': 'IN_PROGRESS'}
tetienne commented 4 years ago

Fix with #23