hellqvio86 / home_assistant_casambi

Home assistant Integration for Casambi Cloud lights
MIT License
25 stars 9 forks source link

Unknown Casambi communication errors #49

Closed antonsarg closed 2 years ago

antonsarg commented 2 years ago

Describe the bug The Casambi light devices/entities often become unavailable, especially after restarting Home Assistant. In the system logs (UI) I receive the following error message:

configuration.yaml setup: Unknown Casambi communication error occured!

Additionally I receive a lot messages that a device is not available anymore and has been turned off in the night, where of course no Home Assistant restart occurs.

To Reproduce Steps to reproduce the behavior:

  1. Restart Home Assistant or wait some time until devices became unavailable

Expected behavior Devices/Entities should be available after restart and during uptime.

Debug logs

2022-07-26 08:01:16 ERROR (MainThread) [aiocasambi.controller] init_unit_state_controls failed to get unit state for unit: [Unit ID here]
2022-07-26 08:01:16 ERROR (MainThread) [custom_components.casambi.light] configuration.yaml setup: Unknown Casambi communication error occurred!

Screenshots

Bildschirmfoto 2022-07-26 um 08 19 41

Platform information

hellqvio86 commented 2 years ago

Please set the log level to debug and share the log:

logger:
  default: info
  logs:
    homeassistant.components.casambi: debug
    custom_components.casambi: debug
    aiocasambi: debug

But this kind of problem is probably connection related, so either your Internet connection or a problem on Casambis end

antonsarg commented 2 years ago
2022-07-26 08:30:50 DEBUG (MainThread) [aiocasambi.controller] Create session called!
2022-07-26 08:30:50 DEBUG (MainThread) [aiocasambi.controller] Creating user session
2022-07-26 08:30:50 DEBUG (MainThread) [aiocasambi.controller] create_user_session called
2022-07-26 08:30:50 DEBUG (MainThread) [aiocasambi.controller] create_user_session headers: {'Content-type': 'application/json',
 'X-Casambi-Key': [key]} auth: {'email': [email], 'password': [password]}
2022-07-26 08:30:50 DEBUG (MainThread) [aiocasambi.controller] Not sending websocket ping, current_time: 1658817050.2465336, last websocket ping: 1658817050.2461684
2022-07-26 08:30:50 DEBUG (MainThread) [aiocasambi.controller] request url: https://door.casambi.com/v1/users/session
2022-07-26 08:30:50 DEBUG (MainThread) [custom_components.casambi.light] async_setup_platform CasambiController already created!

2022-07-26 08:30:51 DEBUG (MainThread) [aiocasambi.controller] create_user_session data from request {'sessionId': [session id]', 'sites': {'[site id]': {'name': 'Mein Zuhause', 'address': '', 'role': 'ADMIN', 'networks': {'[network id]': {'id': '[id]', 'mac': '[mac]', 'address': '[address]', 'name': 'Mein Zuhause', 'type': 'CLOSED', 'grade': 'CLASSIC', 'role': 'ADMIN'}}}}, 'networks': {'[network id]': {'id': '[id]', 'mac': '[mac]', 'address': '[address]', 'name': 'Mein Zuhause', 'type': 'CLOSED', 'grade': 'CLASSIC', 'role': 'ADMIN'}}}
2022-07-26 08:30:51 DEBUG (MainThread) [aiocasambi.controller] network_ids: {'[network id]'} session_ids: {'[session id]': '[id]'}
2022-07-26 08:30:51 DEBUG (MainThread) [aiocasambi.controller] initialize called
2022-07-26 08:30:51 DEBUG (MainThread) [aiocasambi.controller] get_network_information called
2022-07-26 08:30:51 DEBUG (MainThread) [aiocasambi.controller] get_network_information request <url: https://door.casambi.com/v1/networks/[id] headers= {'Content-type': 'application/json', 'X-Casambi-Key': '[key]', 'X-Casambi-Session': '[session id]'}>
2022-07-26 08:30:51 DEBUG (MainThread) [aiocasambi.controller] Not sending websocket ping, current_time: 1658817051.793892, last websocket ping: 1658817050.2461684
2022-07-26 08:30:51 DEBUG (MainThread) [aiocasambi.controller] request url: https://door.casambi.com/v1/networks/[id]
2022-07-26 08:30:51 INFO (MainThread) [homeassistant.components.websocket_api.http.connection] [140373099246880] Received unknown command: hacs/subscribe
2022-07-26 08:30:51 INFO (MainThread) [homeassistant.components.websocket_api.http.connection] [140373099246880] Received unknown command: hacs/subscribe
2022-07-26 08:30:51 INFO (MainThread) [homeassistant.components.websocket_api.http.connection] [140373099246880] Received unknown command: hacs/subscribe
2022-07-26 08:30:51 INFO (MainThread) [homeassistant.components.websocket_api.http.connection] [140373099246880] Received unknown command: hacs/subscribe

2022-07-26 08:30:51 DEBUG (MainThread) [aiocasambi.controller] request: 200 application/json <ClientResponse(https://door.casambi.com/v1/networks/[id]) [200 OK]>
<CIMultiDictProxy('Date': 'Tue, 26 Jul 2022 06:30:51 GMT', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'POST,GET,OPTIONS,PUT,DELETE,HEAD', 'Access-Control-Allow-Headers': '*', 'Access-Control-Max-Age': '728000', 'Access-Control-Allow-Credentials': 'true', 'Content-Type': 'application/json; charset=UTF-8', 'Content-Length': '1201', 'Server': 'Jetty(9.2.11.v20150529)')>

2022-07-26 08:30:51 DEBUG (MainThread) [aiocasambi.controller] get_network_information response: {'address': '[address]', [json data]}

2022-07-26 08:30:51 DEBUG (MainThread) [aiocasambi.controller] get_network_state called units: {'[id]': <aiocasambi.units.Units object at 0x7fab2a1fb250>}
2022-07-26 08:30:51 DEBUG (MainThread) [aiocasambi.controller] get_network_state request url: https://door.casambi.com/v1/networks/[id]/state headers= {'Content-type': 'application/json', 'X-Casambi-Key': '[key]', 'X-Casambi-Session': '[session id]'}
2022-07-26 08:30:51 DEBUG (MainThread) [aiocasambi.controller] Not sending websocket ping, current_time: 1658817051.9087238, last websocket ping: 1658817050.2461684
2022-07-26 08:30:51 DEBUG (MainThread) [aiocasambi.controller] request url: https://door.casambi.com/v1/networks/[id]/state

2022-07-26 08:30:52 DEBUG (MainThread) [aiocasambi.controller] request: 200 application/json <ClientResponse(https://door.casambi.com/v1/networks/[id]/state) [200 OK]>
<CIMultiDictProxy('Date': 'Tue, 26 Jul 2022 06:30:51 GMT', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'POST,GET,OPTIONS,PUT,DELETE,HEAD', 'Access-Control-Allow-Headers': '*', 'Access-Control-Max-Age': '728000', 'Access-Control-Allow-Credentials': 'true', 'Content-Type': 'application/json; charset=UTF-8', 'Content-Length': '1432', 'Server': 'Jetty(9.2.11.v20150529)')>

2022-07-26 08:30:52 DEBUG (MainThread) [aiocasambi.controller] get_network_state response: {'activeScenes': [], 'id': '[id]', 'revision': 34, 'grade': 'CLASSIC', 'address': '[address]', 'name': 'Mein Zuhause', 'type': 'CLOSED', 'timezone': 'Europe/Vienna', 'gateway': {'name': 'iPhone 5S'}, 'units': {'1': {'priority': 0, 'on': False, 'online': False, 'condition': 0, 'activeSceneId': 0, 'id': 1, 'address': 'fa3a0f1b614b', 'name': 'Mito sospeso', 'firmwareVersion': '26.24', 'position': 0, 'fixtureId': 3098, 'groupId': 1, 'type': 'Luminaire'}, '2': {'priority': 0, 'on': False, 'online': False, 'condition': 0, 'activeSceneId': 0, 'id': 2, 'address': 'fe12dba1355e', 'name': 'Mito sospeso', 'firmwareVersion': '26.24', 'position': 1, 'fixtureId': 3098, 'groupId': 1, 'type': 'Luminaire'}, '3': {'priority': 0, 'on': False, 'online': False, 'condition': 0, 'activeSceneId': 0, 'id': 3, 'address': '2aacdd28db88', 'name': 'air controller', 'firmwareVersion': '26.24', 'position': 7, 'fixtureId': 1524, 'groupId': 0, 'type': 'BatterySwitch'}}, 'photos': [], 'scenes': {'1': {'name': 'Gedimmt', 'id': 1, 'position': 0, 'icon': 2, 'color': '#FFFFFF', 'type': 'REGULAR', 'hidden': False, 'units': {'1': {'id': 1}, '2': {'id': 2}}}, '3': {'name': 'Ambiente', 'id': 3, 'position': 1, 'icon': 1, 'color': '#FFFFFF', 'type': 'REGULAR', 'hidden': False, 'units': {'1': {'id': 1}, '2': {'id': 2}}}, '5': {'name': 'Hell', 'id': 5, 'position': 2, 'icon': 0, 'color': '#FFFFFF', 'type': 'REGULAR', 'hidden': False, 'units': {'1': {'id': 1}, '2': {'id': 2}}}}, 'groups': {'1': {'id': 1, 'name': 'Esstisch', 'position': 1, 'units': [{'id': 1, 'position': 0}, {'id': 2, 'position': 1}]}}}
2022-07-26 08:30:52 DEBUG (MainThread) [aiocasambi.units] process_network_state - data={'activeScenes': [], [json data]}

2022-07-26 08:30:52 DEBUG (MainThread) [aiocasambi.unit] unit_id=1 - online - Setting unit to offline
2022-07-26 08:30:52 DEBUG (MainThread) [aiocasambi.unit] unit_id=2 - online - Setting unit to offline
2022-07-26 08:30:52 DEBUG (MainThread) [aiocasambi.unit] unit_id=3 - online - Setting unit to offline
2022-07-26 08:30:52 DEBUG (MainThread) [custom_components.casambi.light] signalling_callback signal: unit pull update data: ['[id-1]', '[id-2]', '[id-3]']
2022-07-26 08:30:52 DEBUG (MainThread) [custom_components.casambi.light] update_unit_state: unit: [id] units: {}
2022-07-26 08:30:52 DEBUG (MainThread) [custom_components.casambi.light] update_unit_state: unit: [id] units: {}
2022-07-26 08:30:52 DEBUG (MainThread) [custom_components.casambi.light] update_unit_state: unit: [id] units: {}
2022-07-26 08:30:52 DEBUG (MainThread) [aiocasambi.controller] initialize getting unit state for all units in network_ids: {'[id]'}
2022-07-26 08:30:52 DEBUG (MainThread) [aiocasambi.controller] init_unit_state_controls unique_ids: ['[id]-1',
 '[id]-2',
 '[id]-3']
2022-07-26 08:30:52 DEBUG (MainThread) [aiocasambi.controller] get_unit_state called, unit_id: 1, network_id: [id] session_id: [id]
2022-07-26 08:30:52 DEBUG (MainThread) [aiocasambi.controller] Not sending websocket ping, current_time: 1658817052.1222827, last websocket ping: 1658817050.2461684
2022-07-26 08:30:52 DEBUG (MainThread) [aiocasambi.controller] request url: https://door.casambi.com/v1/networks/[id]/units/1/state
2022-07-26 08:30:52 DEBUG (MainThread) [aiocasambi.controller] request: 200 application/json <ClientResponse(https://door.casambi.com/v1/networks/[id]/units/1/state) [200 OK]>
<CIMultiDictProxy('Date': 'Tue, 26 Jul 2022 06:30:52 GMT', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'POST,GET,OPTIONS,PUT,DELETE,HEAD', 'Access-Control-Allow-Headers': '*', 'Access-Control-Max-Age': '728000', 'Access-Control-Allow-Credentials': 'true', 'Content-Type': 'application/json; charset=UTF-8', 'Content-Length': '213', 'Server': 'Jetty(9.2.11.v20150529)')>
2022-07-26 08:30:52 ERROR (MainThread) [aiocasambi.controller] init_unit_state_controls failed to get unit state for unit: [unit id]
2022-07-26 08:30:52 ERROR (MainThread) [custom_components.casambi.light] configuration.yaml setup: Unknown Casambi communication error occurred!
hellqvio86 commented 2 years ago

Can you please update to the latest release, I have added more information to the debug information.

Looks like get_unit_state_controls returns something unexpected during the initiation phase for unit id 1

antonsarg commented 2 years ago

I have updated to version 0.88. Can you tell me for which new debug information you are looking now?

hellqvio86 commented 2 years ago

I am looking for the last lines before ERROR, so I can see the state (responses etc. from the Casambi api)

antonsarg commented 2 years ago

Not quiet sure if there is any new info for you but I hope it helps!

2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.controller] request: 200 application/json <ClientResponse(https://door.casambi.com/v1/networks/[id]) [200 OK]>
<CIMultiDictProxy('Date': 'Tue, 26 Jul 2022 07:42:22 GMT', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'POST,GET,OPTIONS,PUT,DELETE,HEAD', 'Access-Control-Allow-Headers': '*', 'Access-Control-Max-Age': '728000', 'Access-Control-Allow-Credentials': 'true', 'Content-Type': 'application/json; charset=UTF-8', 'Content-Length': '1201', 'Server': 'Jetty(9.2.11.v20150529)')>

2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.controller] get_network_information response: {'address': '[address]',
 'gateway': {'name': 'iPhone 5S'},
 'grade': 'CLASSIC',
 'groups': {'1': {'id': 1,
                  'name': 'Esstisch',
                  'position': 1,
                  'units': [{'id': 1, 'position': 0},
                            {'id': 2, 'position': 1}]}},
 'id': '[id]',
 'name': 'Mein Zuhause',
 'photos': [],
 'revision': 34,
 'scenes': {'1': {'color': '#FFFFFF',
                  'hidden': False,
                  'icon': 2,
                  'id': 1,
                  'name': 'Gedimmt',
                  'position': 0,
                  'type': 'REGULAR',
                  'units': {'1': {'id': 1}, '2': {'id': 2}}},
            '3': {'color': '#FFFFFF',
                  'hidden': False,
                  'icon': 1,
                  'id': 3,
                  'name': 'Ambiente',
                  'position': 1,
                  'type': 'REGULAR',
                  'units': {'1': {'id': 1}, '2': {'id': 2}}},
            '5': {'color': '#FFFFFF',
                  'hidden': False,
                  'icon': 0,
                  'id': 5,
                  'name': 'Hell',
                  'position': 2,
                  'type': 'REGULAR',
                  'units': {'1': {'id': 1}, '2': {'id': 2}}}},
 'timezone': 'Europe/Vienna',
 'type': 'CLOSED',
 'units': {'1': {'address': '[address]',
                 'firmwareVersion': '26.24',
                 'fixtureId': 3098,
                 'groupId': 1,
                 'id': 1,
                 'name': 'Mito sospeso',
                 'position': 0,
                 'type': 'Luminaire'},
           '2': {'address': '[address]',
                 'firmwareVersion': '26.24',
                 'fixtureId': 3098,
                 'groupId': 1,
                 'id': 2,
                 'name': 'Mito sospeso',
                 'position': 1,
                 'type': 'Luminaire'},
           '3': {'address': '[address]',
                 'firmwareVersion': '26.24',
                 'fixtureId': 1524,
                 'groupId': 0,
                 'id': 3,
                 'name': 'air controller',
                 'position': 7,
                 'type': 'BatterySwitch'}}}
2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.units] __process_units - Processing units {'1': {'address': '[address]',
       'firmwareVersion': '26.24',
       'fixtureId': 3098,
       'groupId': 1,
       'id': 1,
       'name': 'Mito sospeso',
       'position': 0,
       'type': 'Luminaire'},
 '2': {'address': '[address]',
       'firmwareVersion': '26.24',
       'fixtureId': 3098,
       'groupId': 1,
       'id': 2,
       'name': 'Mito sospeso',
       'position': 1,
       'type': 'Luminaire'},
 '3': {'address': '[address]',
       'firmwareVersion': '26.24',
       'fixtureId': 1524,
       'groupId': 0,
       'id': 3,
       'name': 'air controller',
       'position': 7,
       'type': 'BatterySwitch'}}
2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.scenes] Processing scenes {'1': {'color': '#FFFFFF',
       'hidden': False,
       'icon': 2,
       'id': 1,
       'name': 'Gedimmt',
       'position': 0,
       'type': 'REGULAR',
       'units': {'1': {'id': 1}, '2': {'id': 2}}},
 '3': {'color': '#FFFFFF',
       'hidden': False,
       'icon': 1,
       'id': 3,
       'name': 'Ambiente',
       'position': 1,
       'type': 'REGULAR',
       'units': {'1': {'id': 1}, '2': {'id': 2}}},
 '5': {'color': '#FFFFFF',
       'hidden': False,
       'icon': 0,
       'id': 5,
       'name': 'Hell',
       'position': 2,
       'type': 'REGULAR',
       'units': {'1': {'id': 1}, '2': {'id': 2}}}}
2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.scenes] Processing units {'1': {'color': '#FFFFFF',
       'hidden': False,
       'icon': 2,
       'id': 1,
       'name': 'Gedimmt',
       'position': 0,
       'type': 'REGULAR',
       'units': {'1': {'id': 1}, '2': {'id': 2}}},
 '3': {'color': '#FFFFFF',
       'hidden': False,
       'icon': 1,
       'id': 3,
       'name': 'Ambiente',
       'position': 1,
       'type': 'REGULAR',
       'units': {'1': {'id': 1}, '2': {'id': 2}}},
 '5': {'color': '#FFFFFF',
       'hidden': False,
       'icon': 0,
       'id': 5,
       'name': 'Hell',
       'position': 2,
       'type': 'REGULAR',
       'units': {'1': {'id': 1}, '2': {'id': 2}}}}
2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.scenes] Processing scenes {'[id]-1': <Scene Gedimmt: scene_id=1 state=off network_id=[id] wire_id=0>,
 '[id]-3': <Scene Ambiente: scene_id=3 state=off network_id=[id] wire_id=0>,
 '[id]-5': <Scene Hell: scene_id=5 state=off network_id=[id] wire_id=0>}
2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.controller] initialize network__information: {'[id]': {'address': '[address]',
                                      'gateway': {'name': 'iPhone 5S'},
                                      'grade': 'CLASSIC',
                                      'groups': {'1': {'id': 1,
                                                       'name': 'Esstisch',
                                                       'position': 1,
                                                       'units': [{'id': 1,
                                                                  'position': 0},
                                                                 {'id': 2,
                                                                  'position': 1}]}},
                                      'id': '[id]',
                                      'name': 'Mein Zuhause',
                                      'photos': [],
                                      'revision': 34,
                                      'scenes': {'1': {'color': '#FFFFFF',
                                                       'hidden': False,
                                                       'icon': 2,
                                                       'id': 1,
                                                       'name': 'Gedimmt',
                                                       'position': 0,
                                                       'type': 'REGULAR',
                                                       'units': {'1': {'id': 1},
                                                                 '2': {'id': 2}}},
                                                 '3': {'color': '#FFFFFF',
                                                       'hidden': False,
                                                       'icon': 1,
                                                       'id': 3,
                                                       'name': 'Ambiente',
                                                       'position': 1,
                                                       'type': 'REGULAR',
                                                       'units': {'1': {'id': 1},
                                                                 '2': {'id': 2}}},
                                                 '5': {'color': '#FFFFFF',
                                                       'hidden': False,
                                                       'icon': 0,
                                                       'id': 5,
                                                       'name': 'Hell',
                                                       'position': 2,
                                                       'type': 'REGULAR',
                                                       'units': {'1': {'id': 1},
                                                                 '2': {'id': 2}}}},
                                      'timezone': 'Europe/Vienna',
                                      'type': 'CLOSED',
                                      'units': {'1': {'address': '[address]',
                                                      'firmwareVersion': '26.24',
                                                      'fixtureId': 3098,
                                                      'groupId': 1,
                                                      'id': 1,
                                                      'name': 'Mito sospeso',
                                                      'position': 0,
                                                      'type': 'Luminaire'},
                                                '2': {'address': '[address]',
                                                      'firmwareVersion': '26.24',
                                                      'fixtureId': 3098,
                                                      'groupId': 1,
                                                      'id': 2,
                                                      'name': 'Mito sospeso',
                                                      'position': 1,
                                                      'type': 'Luminaire'},
                                                '3': {'address': '[address]',
                                                      'firmwareVersion': '26.24',
                                                      'fixtureId': 1524,
                                                      'groupId': 0,
                                                      'id': 3,
                                                      'name': 'air controller',
                                                      'position': 7,
                                                      'type': 'BatterySwitch'}}}}
2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.controller] get_network_state called units: {'[id]': <aiocasambi.units.Units object at 0x7fd2b61b0f70>}
2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.controller] get_network_state request url: https://door.casambi.com/v1/networks/[id]/state headers= {'Content-type': 'application/json', 'X-Casambi-Key': '[key]', 'X-Casambi-Session': '[session]'}
2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.controller] Not sending websocket ping, current_time: 1658821342.3190956, last websocket ping: 1658821341.3364134
2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.controller] request url: https://door.casambi.com/v1/networks/[id]/state
2022-07-26 09:42:22 INFO (SyncWorker_6) [homeassistant.loader] Loaded panasonic_viera from homeassistant.components.panasonic_viera
2022-07-26 09:42:22 INFO (SyncWorker_6) [homeassistant.loader] Loaded airtouch4 from homeassistant.components.airtouch4
2022-07-26 09:42:22 INFO (MainThread) [custom_components.hacs] Enable category: integration
2022-07-26 09:42:22 INFO (MainThread) [custom_components.hacs] Enable category: plugin
2022-07-26 09:42:22 INFO (MainThread) [custom_components.hacs] Enable category: theme
2022-07-26 09:42:22 INFO (MainThread) [custom_components.hacs] <HacsFrontend> LovelaceMode.STORAGE mode, cache for /hacsfiles/: True
2022-07-26 09:42:22 INFO (SyncWorker_2) [homeassistant.loader] Loaded moon from homeassistant.components.moon
2022-07-26 09:42:22 INFO (SyncWorker_1) [homeassistant.loader] Loaded vizio from homeassistant.components.vizio
2022-07-26 09:42:22 INFO (MainThread) [custom_components.hacs] Stage changed: HacsStage.SETUP
2022-07-26 09:42:22 INFO (MainThread) [custom_components.hacs] Stage changed: HacsStage.WAITING
2022-07-26 09:42:22 INFO (MainThread) [custom_components.hacs] Setup complete, waiting for Home Assistant before startup tasks starts
2022-07-26 09:42:22 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.hacs
2022-07-26 09:42:22 INFO (SyncWorker_5) [homeassistant.loader] Loaded smhi from homeassistant.components.smhi
2022-07-26 09:42:22 INFO (SyncWorker_3) [homeassistant.loader] Loaded vulcan from homeassistant.components.vulcan
2022-07-26 09:42:22 INFO (SyncWorker_4) [homeassistant.loader] Loaded shopping_list from homeassistant.components.shopping_list
2022-07-26 09:42:22 INFO (MainThread) [homeassistant.setup] Setting up stream
2022-07-26 09:42:22 INFO (MainThread) [homeassistant.setup] Setup of domain stream took 0.0 seconds
2022-07-26 09:42:22 INFO (SyncWorker_2) [homeassistant.loader] Loaded volumio from homeassistant.components.volumio
2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.controller] request: 200 application/json <ClientResponse(https://door.casambi.com/v1/networks/[id]/state) [200 OK]>
<CIMultiDictProxy('Date': 'Tue, 26 Jul 2022 07:42:22 GMT', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'POST,GET,OPTIONS,PUT,DELETE,HEAD', 'Access-Control-Allow-Headers': '*', 'Access-Control-Max-Age': '728000', 'Access-Control-Allow-Credentials': 'true', 'Content-Type': 'application/json; charset=UTF-8', 'Content-Length': '1432', 'Server': 'Jetty(9.2.11.v20150529)')>

2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.controller] get_network_state response: {'activeScenes': [], 'id': '[id]', 'revision': 34, 'grade': 'CLASSIC', 'address': '[address]', 'name': 'Mein Zuhause', 'type': 'CLOSED', 'timezone': 'Europe/Vienna', 'gateway': {'name': 'iPhone 5S'}, 'units': {'1': {'priority': 0, 'on': False, 'online': False, 'condition': 0, 'activeSceneId': 0, 'id': 1, 'address': '[address]', 'name': 'Mito sospeso', 'firmwareVersion': '26.24', 'position': 0, 'fixtureId': 3098, 'groupId': 1, 'type': 'Luminaire'}, '2': {'priority': 0, 'on': False, 'online': False, 'condition': 0, 'activeSceneId': 0, 'id': 2, 'address': '[address]', 'name': 'Mito sospeso', 'firmwareVersion': '26.24', 'position': 1, 'fixtureId': 3098, 'groupId': 1, 'type': 'Luminaire'}, '3': {'priority': 0, 'on': False, 'online': False, 'condition': 0, 'activeSceneId': 0, 'id': 3, 'address': '[address]', 'name': 'air controller', 'firmwareVersion': '26.24', 'position': 7, 'fixtureId': 1524, 'groupId': 0, 'type': 'BatterySwitch'}}, 'photos': [], 'scenes': {'1': {'name': 'Gedimmt', 'id': 1, 'position': 0, 'icon': 2, 'color': '#FFFFFF', 'type': 'REGULAR', 'hidden': False, 'units': {'1': {'id': 1}, '2': {'id': 2}}}, '3': {'name': 'Ambiente', 'id': 3, 'position': 1, 'icon': 1, 'color': '#FFFFFF', 'type': 'REGULAR', 'hidden': False, 'units': {'1': {'id': 1}, '2': {'id': 2}}}, '5': {'name': 'Hell', 'id': 5, 'position': 2, 'icon': 0, 'color': '#FFFFFF', 'type': 'REGULAR', 'hidden': False, 'units': {'1': {'id': 1}, '2': {'id': 2}}}}, 'groups': {'1': {'id': 1, 'name': 'Esstisch', 'position': 1, 'units': [{'id': 1, 'position': 0}, {'id': 2, 'position': 1}]}}}
2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.units] process_network_state - data={'activeScenes': [],
 'address': '[address]',
 'gateway': {'name': 'iPhone 5S'},
 'grade': 'CLASSIC',
 'groups': {'1': {'id': 1,
                  'name': 'Esstisch',
                  'position': 1,
                  'units': [{'id': 1, 'position': 0},
                            {'id': 2, 'position': 1}]}},
 'id': '[id]',
 'name': 'Mein Zuhause',
 'photos': [],
 'revision': 34,
 'scenes': {'1': {'color': '#FFFFFF',
                  'hidden': False,
                  'icon': 2,
                  'id': 1,
                  'name': 'Gedimmt',
                  'position': 0,
                  'type': 'REGULAR',
                  'units': {'1': {'id': 1}, '2': {'id': 2}}},
            '3': {'color': '#FFFFFF',
                  'hidden': False,
                  'icon': 1,
                  'id': 3,
                  'name': 'Ambiente',
                  'position': 1,
                  'type': 'REGULAR',
                  'units': {'1': {'id': 1}, '2': {'id': 2}}},
            '5': {'color': '#FFFFFF',
                  'hidden': False,
                  'icon': 0,
                  'id': 5,
                  'name': 'Hell',
                  'position': 2,
                  'type': 'REGULAR',
                  'units': {'1': {'id': 1}, '2': {'id': 2}}}},
 'timezone': 'Europe/Vienna',
 'type': 'CLOSED',
 'units': {'1': {'activeSceneId': 0,
                 'address': '[address]',
                 'condition': 0,
                 'firmwareVersion': '26.24',
                 'fixtureId': 3098,
                 'groupId': 1,
                 'id': 1,
                 'name': 'Mito sospeso',
                 'on': False,
                 'online': False,
                 'position': 0,
                 'priority': 0,
                 'type': 'Luminaire'},
           '2': {'activeSceneId': 0,
                 'address': '[address]',
                 'condition': 0,
                 'firmwareVersion': '26.24',
                 'fixtureId': 3098,
                 'groupId': 1,
                 'id': 2,
                 'name': 'Mito sospeso',
                 'on': False,
                 'online': False,
                 'position': 1,
                 'priority': 0,
                 'type': 'Luminaire'},
           '3': {'activeSceneId': 0,
                 'address': '[address]',
                 'condition': 0,
                 'firmwareVersion': '26.24',
                 'fixtureId': 1524,
                 'groupId': 0,
                 'id': 3,
                 'name': 'air controller',
                 'on': False,
                 'online': False,
                 'position': 7,
                 'priority': 0,
                 'type': 'BatterySwitch'}}}

2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.unit] unit_id=1 - online - Setting unit to offline
2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.unit] unit_id=2 - online - Setting unit to offline
2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.unit] unit_id=3 - online - Setting unit to offline
2022-07-26 09:42:22 DEBUG (MainThread) [custom_components.casambi.light] signalling_callback signal: unit pull update data: ['[id]-1', '[id]-2', '[id]-3']
2022-07-26 09:42:22 DEBUG (MainThread) [custom_components.casambi.light] update_unit_state: unit: [id]-1 units: {}
2022-07-26 09:42:22 DEBUG (MainThread) [custom_components.casambi.light] update_unit_state: unit: [id]-2 units: {}
2022-07-26 09:42:22 DEBUG (MainThread) [custom_components.casambi.light] update_unit_state: unit: [id]-3 units: {}
2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.controller] initialize getting unit state for all units in network_ids: {'[id]'}
2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.controller] init_unit_state_controls unique_ids: ['[id]-1',
 '[id]-2',
 '[id]-3']
2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.controller] get_unit_state called, unit_id: 1, network_id: [id] session_id:  [session_id]
2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.controller] Not sending websocket ping, current_time: 1658821342.5148292, last websocket ping: 1658821341.3364134
2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.controller] request url: https://door.casambi.com/v1/networks/[id]/units/1/state
2022-07-26 09:42:22 INFO (MainThread) [homeassistant.setup] Setup of domain default_config took 0.3 seconds

2022-07-26 09:42:22 DEBUG (MainThread) [aiocasambi.controller] request: 200 application/json <ClientResponse(https://door.casambi.com/v1/networks/[id]/units/1/state) [200 OK]>
<CIMultiDictProxy('Date': 'Tue, 26 Jul 2022 07:42:22 GMT', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'POST,GET,OPTIONS,PUT,DELETE,HEAD', 'Access-Control-Allow-Headers': '*', 'Access-Control-Max-Age': '728000', 'Access-Control-Allow-Credentials': 'true', 'Content-Type': 'application/json; charset=UTF-8', 'Content-Length': '213', 'Server': 'Jetty(9.2.11.v20150529)')>
2022-07-26 09:42:22 ERROR (MainThread) [aiocasambi.controller] init_unit_state_controls failed to get unit state for unit: [id]-1 data: []
2022-07-26 09:42:22 ERROR (MainThread) [custom_components.casambi.light] configuration.yaml setup: Unknown Casambi communication error occurred!
hellqvio86 commented 2 years ago

Have you altered data in the event? 2022-07-26 09:42:22 ERROR (MainThread) [aiocasambi.controller] init_unit_state_controls failed to get unit state for unit: [id]-1 data: []

antonsarg commented 2 years ago

No, data has been empty and not altered. I only replaced the unit id since I am not sure if it might be possible to get access from outside with the unit id.

hellqvio86 commented 2 years ago

Its not possible, what you need to protect is your network name and your credentials. unit id starts from 1 and is incremented by each unit.

What I can see is that the integration excepts controls to be part of the unit information of unit 1 and its not in the response. Controls are used by Casambis api to see what kind of light it is, if its support dimming, support color etc.

I have released a new version v0.89, I want to see what get_unit_state_controls gets when it calls get_unit_state, its expecting controls to be apart of the dict, but its not there.

antonsarg commented 2 years ago

Got it. Thanks for trying to solve the problem!

hellqvio86 commented 2 years ago

I would not want to share my mac address as well, its logged by the integration, cannot really be used by an attacker, they need to be in bluetooth range, but I don't need it. You can mail me the log if you don't want it in public, but I don't want any credentials either way :slightly_smiling_face:

antonsarg commented 2 years ago

I think I have a guess why controls is not part of the dict. I have an Occhio Air Controller within my Casambi network. Might it be that the controller is not supported by the integration and it doesn't know what to do with it except throwing an error? Maybe it is possible to ignore the controller since it is showing up in HA but I can't do anything with it anyways.

I will install the update and check the logs again.

hellqvio86 commented 2 years ago

The integration think its a light, it should just ignore it, but I need unit information so we can look into how to ignore it

antonsarg commented 2 years ago

My suspicion does not seem to be confirmed, since the function call outputs a luminaire.

2022-07-26 10:22:54 DEBUG (MainThread) [aiocasambi.controller] request: 200 application/json <ClientResponse(https://door.casambi.com/v1/networks/[id]/units/1/state) [200 OK]>
<CIMultiDictProxy('Date': 'Tue, 26 Jul 2022 08:22:53 GMT', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'POST,GET,OPTIONS,PUT,DELETE,HEAD', 'Access-Control-Allow-Headers': '*', 'Access-Control-Max-Age': '728000', 'Access-Control-Allow-Credentials': 'true', 'Content-Type': 'application/json; charset=UTF-8', 'Content-Length': '213', 'Server': 'Jetty(9.2.11.v20150529)')>

2022-07-26 10:22:54 DEBUG (MainThread) [aiocasambi.controller] get_unit_state_controls data: {'activeSceneId': 0,
 'address': 'fa3a0f1b614b',
 'condition': 0,
 'firmwareVersion': '26.24',
 'fixtureId': 3098,
 'groupId': 1,
 'id': 1,
 'name': 'Mito sospeso',
 'on': False,
 'online': False,
 'position': 5,
 'priority': 0,
 'type': 'Luminaire'}
2022-07-26 10:22:54 ERROR (MainThread) [aiocasambi.controller] init_unit_state_controls failed to get unit state for unit: [id]-1 data: []
2022-07-26 10:22:54 ERROR (MainThread) [custom_components.casambi.light] configuration.yaml setup: Unknown Casambi communication error occurred!
hellqvio86 commented 2 years ago

I have released a new version (0.90), it will not throw an exception when controls isn't part of the dict.

But the Occhio Air Controller shoud just be ignored, the integration is only supporting lights right now.

antonsarg commented 2 years ago

The error doesn't appear anymore and it looks quite good in general now. I will watch it a little further and see if it stays like this. I will give you an update in a few days and close this issue if everything works fine. Thank you!

hellqvio86 commented 2 years ago

The exception handling is misleading in this case, its not really a network error, the integration expected controls to be present for every unit. That is really not the case, so it just skips to add controls for units with no controls.

But glad it worked out!

hellqvio86 commented 2 years ago

The exception handling is misleading in this case, its not really a network error, the integration expected controls to be present for every unit. That is really not the case, so it just skips to add controls for units with no controls.

But glad it worked out!

Edit: closing the issue, feel free to open a new one if you fi d something else 🙂