hellqvio86 / home_assistant_casambi

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

HA device creation fails with network session #42

Closed fschwarz86 closed 2 years ago

fschwarz86 commented 2 years ago

Hi there,

following up on this issue I tried to setup a Casambi device in HA using the latest v0.68 of home_assistant_casambi. According to the logs, the creation of a user session fails, but network session seems to succeed. However, creating the device fails with an error message ("invalid credentials").

2022-05-26 14:37:42 DEBUG (MainThread) [custom_components.casambi.config_flow] async_step_user user_input: {'email': 'EMAIL', 'api_key': 'API_KEY', 'user_password': 'USER_PASSWORD', 'network_password': 'NETWORK_PASSWORD'}
2022-05-26 14:37:42 DEBUG (MainThread) [aiocasambi.helper]  headers: {'Content-type': 'application/json', 'X-Casambi-Key': 'API_KEY'} auth: {'email': 'EMAIL', 'password': 'NETWORK_PASSWORD'}
2022-05-26 14:37:42 DEBUG (MainThread) [aiocasambi.helper] request url: https://door.casambi.com/v1/users/session
2022-05-26 14:37:42 DEBUG (MainThread) [aiocasambi.helper] request: 401 text/html <ClientResponse(https://door.casambi.com/v1/users/session) [401 Unauthorized]>
<CIMultiDictProxy('Date': 'Thu, 26 May 2022 12:37:42 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': 'text/html; charset=ISO-8859-1', 'Cache-Control': 'must-revalidate,no-cache,no-store', 'Content-Length': '148', 'Server': 'Jetty(9.2.11.v20150529)')>

2022-05-26 14:37:42 DEBUG (MainThread) [aiocasambi.helper] headers: {'Content-type': 'application/json', 'X-Casambi-Key': 'API_KEY'} auth: {'email': 'EMAIL', 'password': 'PASSWORD'}
2022-05-26 14:37:42 DEBUG (MainThread) [aiocasambi.helper] request url: https://door.casambi.com/v1/networks/session
2022-05-26 14:37:42 DEBUG (MainThread) [aiocasambi.helper] request: 200 application/json <ClientResponse(https://door.casambi.com/v1/networks/session) [200 OK]>
<CIMultiDictProxy('Date': 'Thu, 26 May 2022 12:37:42 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': '285', 'Server': 'Jetty(9.2.11.v20150529)')>

2022-05-26 14:37:42 DEBUG (MainThread) [aiocasambi.helper] create_network_session data from request {'ID': {'id': 'ID', 'mac': '63ca83axxx51', 'address': '63ca83axxx51', 'name': 'Steinreye', 'type': 'PROTECTED', 'grade': 'EVOLUTION', 'sessionId': 'SESSION_ID'}}

What's the best way to further debug this?

Thanks a ton for your support, Florian

hellqvio86 commented 2 years ago

Your user credentials are invalid, have you created a site? https://support.casambi.com/support/solutions/articles/12000041325-how-to-create-a-site

A workaround is to define the lights in the configuration.yaml, like:

light:
  - platform: casambi
    email: !secret casambi_email
    api_key: !secret casambi_api_key
    network_password: !secret casambi_network_password
    user_password: !secret casambi_user_password # The site password for your user

Set the user password to "", that will be converted to None.

But what you should do is to fix the site user password. I have released a new version which hopefully helps with the workaround (version 0.69).

hellqvio86 commented 2 years ago

You can also debug the credentials through CURL:

curl -X POST "https://door.casambi.com/v1/users/session"
-H "Content-Type: application/json"
-H "X-Casambi-Key:API-KEY-HERE"
-d "{\"email\":\"EMAIL-HERE\",\"password\":\"PASSWORD-HERE\"}"
curl -X POST "https://door.casambi.com/v1/networks/session"
-H "Content-Type: application/json"
-H "X-Casambi-Key:API-KEY-HERE"
-d "{\"email\":\"EMAIL-HERE\",\"password\":\"NETWORK-PASSWORD-HERE\"}"

You can find more curl examples in Casambis documentation: https://developer.casambi.com/#rest-api

fschwarz86 commented 2 years ago

Please excuse my belated response, I've been swamped with other things... Actually I really missed creating a site in the first place. This is because in the the app I use for my device (Occhio), the site functionallity seems to be removed. I've now moved over to the original Casambi app and successfully created a site.

The CURL commands work just fine and with the latest version 0.70 of your integration, I can successfully complete the device setup process, however no entity is being created. The logs are also showing some errors:

2022-06-05 14:19:55 DEBUG (MainThread) [custom_components.casambi.config_flow] async_step_user user_input: {'email': 'E_MAIL', 'api_key': 'API_KEY', 'user_password': 'PASSWORD', 'network_password': 'PASSWORD'}
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.helper] headers: {'Content-type': 'application/json', 'X-Casambi-Key': 'API_KEY'} auth: {'email': 'E_MAIL', 'password': 'PASSWORD'}
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.helper] request url: https://door.casambi.com/v1/users/session
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.helper] request: 200 application/json <ClientResponse(https://door.casambi.com/v1/users/session) [200 OK]>
<CIMultiDictProxy('Date': 'Sun, 05 Jun 2022 12:19:55 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': '616', 'Server': 'Jetty(9.2.11.v20150529)')>
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.helper] create_user_session data from request {'sessionId': 'U-Qv6bL9ULpNFSs0p1fS-VMxxxxYFVxHJMG54IcqdCLxxxxrqbnkS1MUVSs2ojR.PQNsNfmzoLmyWFYcAWqdGg__', 'sites': {'PRCv6w2QIQ8GbNEBwdjPxN3TbBlWR6CE': {'name': 'Steinreye', 'address': '', 'role': 'ADMIN', 'networks': {'TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU': {'id': 'TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU', 'mac': '63ca83acba51', 'address': '63ca83acba51', 'name': 'Steinreye', 'type': 'PROTECTED', 'grade': 'EVOLUTION', 'role': 'ADMIN'}}}}, 'networks': {'TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU': {'id': 'TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU', 'mac': '63ca83acba51', 'address': '63ca83acba51', 'name': 'Steinreye', 'type': 'PROTECTED', 'grade': 'EVOLUTION', 'role': 'ADMIN'}}}
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.helper] headers: {'Content-type': 'application/json', 'X-Casambi-Key': 'API_KEY'} auth: {'email': 'E_MAIL', 'password': 'PASSWORD'}
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.helper] request url: https://door.casambi.com/v1/networks/session
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.helper] request: 200 application/json <ClientResponse(https://door.casambi.com/v1/networks/session) [200 OK]>
<CIMultiDictProxy('Date': 'Sun, 05 Jun 2022 12:19:55 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': '567', 'Server': 'Jetty(9.2.11.v20150529)')>
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.helper] create_network_session data from request {'Oaf8v6B8ul7HZnAdDw86lXm5n2biaOqE': {'id': 'Oaf8v6B8ul7HZnAdDw86lXm5n2biaOqE', 'mac': '76691b2fdf02', 'address': '76691b2fdf02', 'name': 'Steinreye', 'type': 'PROTECTED', 'grade': 'CLASSIC', 'sessionId': '0YUpJyrkMJp9xxxxxjj5TSGM2bYc9t-ohvCTKssAa55e5IixxxTH.YslAdO-Iqmu0eAXLmb9QyQi012G1UQQxA__'}, 'TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU': {'id': 'TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU', 'mac': '63ca83acba51', 'address': '63ca83acba51', 'name': 'Steinreye', 'type': 'PROTECTED', 'grade': 'EVOLUTION', 'sessionId': 'fGxxxxxrGUhwNzgOSqjOZP5P4.2Lhk2aehbQBd1S7xxxxpTDSwf2sx20cyfFtE8kzvOieYgRlFThRLbNPGt4w__'}}
2022-06-05 14:19:55 INFO (MainThread) [homeassistant.setup] Setting up casambi
2022-06-05 14:19:55 INFO (MainThread) [homeassistant.setup] Setup of domain casambi took 0.0 seconds
2022-06-05 14:19:55 INFO (MainThread) [homeassistant.components.light] Setting up light.casambi
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] Create session called!
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] Creating user session
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] headers: {'Content-type': 'application/json',
'X-Casambi-Key': 'API_KEY'} auth: {'email': 'E_MAIL', 'password': 'PASSWORD'}
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] Not sending websocket ping, current_time: 1654431595.4973826, last websocket ping: 1654431595.495485
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] request url: https://door.casambi.com/v1/users/session
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] request: 200 application/json <ClientResponse(https://door.casambi.com/v1/users/session) [200 OK]>
<CIMultiDictProxy('Date': 'Sun, 05 Jun 2022 12:19:55 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': '616', 'Server': 'Jetty(9.2.11.v20150529)')>
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] create_user_session data from request {'sessionId': '9QeaK89ZLwpxxxxY7HTIdWhWw57mx6AhPA1RT-m3lm22XyipsNxxxxGnScvh08676HoDRt.zh8M05NrNzL2itw__', 'sites': {'PRCv6w2QIQ8GbNEBwdjPxN3TbBlWR6CE': {'name': 'Steinreye', 'address': '', 'role': 'ADMIN', 'networks': {'TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU': {'id': 'TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU', 'mac': '63ca83acba51', 'address': '63ca83acba51', 'name': 'Steinreye', 'type': 'PROTECTED', 'grade': 'EVOLUTION', 'role': 'ADMIN'}}}}, 'networks': {'TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU': {'id': 'TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU', 'mac': '63ca83acba51', 'address': '63ca83acba51', 'name': 'Steinreye', 'type': 'PROTECTED', 'grade': 'EVOLUTION', 'role': 'ADMIN'}}}
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] user_session_id: 9Qxxx89ZLwp50BjY7HTIdWhWw57mx6Ahxxxx-m3lm22XyipsN2rb4GnSxxx08676HoDRt.zh8M05NrNzL2itw__
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] Creating network session
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] headers: {'Content-type': 'application/json', 'X-Casambi-Key': 'API_KEY'} auth: {'email': 'E_MAIL', 'password': 'PASSWORD'}
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] Not sending websocket ping, current_time: 1654431595.5722396, last websocket ping: 1654431595.495485
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] request url: https://door.casambi.com/v1/networks/session
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] request: 200 application/json <ClientResponse(https://door.casambi.com/v1/networks/session) [200 OK]>
<CIMultiDictProxy('Date': 'Sun, 05 Jun 2022 12:19:55 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': '567', 'Server': 'Jetty(9.2.11.v20150529)')>
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] create_network_session data from request {'Oaf8v6B8ul7HZnAdDw86lXm5n2biaOqE': {'address': '76691b2fdf02',
'grade': 'CLASSIC',
'id': 'Oaf8v6B8ul7HZnAdDw86lXm5n2biaOqE',
'mac': '76691b2fdf02',
'name': 'Steinreye',
'sessionId': '5ARxxxyrpwJYy7Hf1xxx-HmF18AgmUu39kSKDxxBxxxWkUg59SU9pii.9jBVi6PEyfq9Y9gokiel0yfljGmJQg__',
'type': 'PROTECTED'},
'TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU': {'address': '63ca83acba51',
'grade': 'EVOLUTION',
'id': 'TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU',
'mac': '63ca83acba51',
'name': 'Steinreye',
'sessionId': 'q.xxxxTli2jsIY78a8NXODnlrq6a8YHxxx-qWMtDshHEk0a.oOiPHCcN5jOGTWuxXufP1J6-TxxxvgHp3t-RvA__',
'type': 'PROTECTED'}}
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] network_id: Oaf8v6B8ul7HZnAdDw86lXm5n2biaOqE session_id: 5ARxxxyrpwJYy7Hf1xxx-HmF18AgmUu39kSKDxxBxxxWkUg59SU9pii.9jBVi6PEyfq9Y9gokiel0yfljGmJQg__
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] start_websocket: api_key: API_KEY, network_id: Oaf8v6B8ul7HZnAdDw86lXm5n2biaOqE, user_session_id: 5ARxxxyrpwJYy7Hf1xxx-HmF18AgmUu39kSKDxxBxxxWkUg59SU9pii.9jBVi6PEyfq9Y9gokiel0yfljGmJQg__, wire_id: 9
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.websocket] websocket.start state None
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.websocket] websocket.state starting
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] session_handler is handlingSIGNAL_CONNECTION_STATE: state
2022-06-05 14:19:55 DEBUG (MainThread) [custom_components.casambi.light] signalling_callback signal: state data: starting
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] get_network_information request <url: https://door.casambi.com/v1/networks/Oaf8v6B8ul7HZnAdDw86lXm5n2biaOqE headers= {'Content-type': 'application/json', 'X-Casambi-Key': 'API_KEY', 'X-Casambi-Session': '9Qxxx89ZLwp50BjY7HTIdWhWw57mx6Ahxxxx-m3lm22XyipsN2rb4GnSxxx08676HoDRt.zh8M05NrNzL2itw__'}>
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] Not sending websocket ping, current_time: 1654431595.5930994, last websocket ping: 1654431595.5928042
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] request url: https://door.casambi.com/v1/networks/Oaf8v6B8ul7HZnAdDw86lXm5n2biaOqE
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.websocket] websocket opening session
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] request: 401 text/html <ClientResponse(https://door.casambi.com/v1/networks/Oaf8v6B8ul7HZnAdDw86lXm5n2biaOqE) [401 Unauthorized]>
<CIMultiDictProxy('Date': 'Sun, 05 Jun 2022 12:19:55 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': 'text/html; charset=ISO-8859-1', 'Cache-Control': 'must-revalidate,no-cache,no-store', 'Content-Length': '148', 'Server': 'Jetty(9.2.11.v20150529)')>
2022-06-05 14:19:55 ERROR (MainThread) [aiocasambi.controller] get_network_information caught LoginRequired exception
2022-06-05 14:19:55 ERROR (MainThread) [homeassistant.components.light] Error while setting up casambi platform for light
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/casambi/light.py", line 153, in async_setup_entry
await controller.initialize()
File "/usr/local/lib/python3.9/site-packages/aiocasambi/controller.py", line 298, in initialize
network_information = await self.get_network_information()
File "/usr/local/lib/python3.9/site-packages/aiocasambi/controller.py", line 176, in get_network_information
raise err
File "/usr/local/lib/python3.9/site-packages/aiocasambi/controller.py", line 173, in get_network_information
data = await self.request("get", url=url, headers=self.headers)
File "/usr/local/lib/python3.9/site-packages/aiocasambi/controller.py", line 659, in request
raise LoginRequired(f"Call {url} received 401 Unauthorized")
aiocasambi.errors.LoginRequired: Call https://door.casambi.com/v1/networks/Oaf8v6B8ul7HZnAdDw86lXm5n2biaOqE received 401 Unauthorized
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.websocket] websocket.state running
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] session_handler is handlingSIGNAL_CONNECTION_STATE: state
2022-06-05 14:19:55 DEBUG (MainThread) [custom_components.casambi.light] signalling_callback signal: state data: running
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.websocket] websocket running: wire_id: 9 msg: WSMessage(type=<WSMsgType.BINARY: 2>, data=b'{"ref":"cf26f978-e4c9-11ec-ba2c-dca63241d10c","wireStatus":"openWireSucceed"}', extra='')
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] session_handler is handling SIGNAL_DATA: data
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.controller] message_handler recieved websocket message: {'ref': 'cf26f978-e4c9-11ec-ba2c-dca63241d10c', 'wireStatus': 'openWireSucceed'}
2022-06-05 14:19:55 DEBUG (MainThread) [aiocasambi.websocket] websocket recived msg.type: aiohttp.WSMsgType.BINARY data: {'ref': 'cf26f978-e4c9-11ec-ba2c-dca63241d10c', 'wireStatus': 'openWireSucceed'}

It seems like I'm still unauthorized to do something, but no idea what this is.

hellqvio86 commented 2 years ago

It fails on Request network information: https://developer.casambi.com/#rest-api-request-network-information

Curl for doing it:

curl "https://door.casambi.com/v1/networks/NETWORK-ID-HERE"
-H "X-Casambi-Session:SESSION-ID-HERE"
-H "X-Casambi-Key:API-KEY-HERE"

Using the casambi api:

import casambi
import time

from pprint import pformat

api_key = 'REPLACEME'
email = 'replaceme@replace.com'
network_password = 'REPLACEME'
user_password = 'REPLACEME'

worker = casambi.Casambi(api_key=api_key, email=email, user_password=user_password, network_password=network_password)
worker.create_user_session()
worker.create_network_session()
data = worker.get_network_information()

print(f"Network information: {pformat(data)}")

Try those out, if that doesn't work, mail support@casambi.com and ask them why you are getting 401.

hellqvio86 commented 2 years ago

You also have two networks listed:

{'Oaf8v6B8ul7HZnAdDw86lXm5n2biaOqE': {'address': '76691b2fdf02',
'grade': 'CLASSIC',
'id': 'Oaf8v6B8ul7HZnAdDw86lXm5n2biaOqE',
'mac': '76691b2fdf02',
'name': 'Steinreye',
'sessionId': '5ARxxxyrpwJYy7Hf1xxx-HmF18AgmUu39kSKDxxBxxxWkUg59SU9pii.9jBVi6PEyfq9Y9gokiel0yfljGmJQg__',
'type': 'PROTECTED'},
'TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU': {'address': '63ca83acba51',
'grade': 'EVOLUTION',
'id': 'TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU',
'mac': '63ca83acba51',
'name': 'Steinreye',
'sessionId': 'q.xxxxTli2jsIY78a8NXODnlrq6a8YHxxx-qWMtDshHEk0a.oOiPHCcN5jOGTWuxXufP1J6-TxxxvgHp3t-RvA__',
'type': 'PROTECTED'}}

The api is trying the first one (Oaf8v6B8ul7HZnAdDw86lXm5n2biaOqE), please try to do the call on the second network TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU.

hellqvio86 commented 2 years ago

I have updated the casambi integration so it handles multiple network ids, that might help in this case, I think you don't see any device since you have multiple networks with the same name and the integration was ignoring every network but the first. Now it tries to connect to every network

fschwarz86 commented 2 years ago

Thanks so much for your support! I've finally found the time to test your changes. The light is now detected, however I can't control it. It seems like it's first being detected correctly with state=on and shorty after the state changes to off:

2022-06-12 *17:41:31* DEBUG (MainThread) [custom_components.casambi.light] async_update <Casambi light Mito volo: unit=<Unit Mito volo:unit_id=1 address=4202226b11c2 value=0.9411764705882353 distribution=0.4627450980392157 *state=on* online=True network_id=TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU wire_id=56 supports_brightness=True supports_distribution=True supports_color_temperature=True supports_rgb=False supports_rgbw=False controls={'Dimmer': {'name': 'dimmer0', 'type': 'Dimmer', 'value': 0.9411764705882353}, 'Vertical': {'name': 'vertical', 'type': 'Vertical', 'value': 0.4627450980392157}, 'CCT': {'min': 2700, 'max': 4000, 'level': 0.9538461538461539, 'name': 'temperature', 'type': 'CCT', 'value': 3940.0}} >
[...]
2022-06-12 17:41:36 DEBUG (MainThread) [custom_components.casambi.light] signalling_callback signal: unit pull update data: ['TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU-1']
2022-06-12 *17:41:36* DEBUG (MainThread) [custom_components.casambi.light] update_unit_state: unit: TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU-1 units: {'TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU-1': <Casambi light Mito volo: unit=<Unit Mito volo:unit_id=1 address=4202226b11c2 value=0.9411764705882353 distribution=0.4627450980392157 state=on online=True network_id=TYqGirRLwKrArqkOQVtXcw1QOgdLIjkU wire_id=56 supports_brightness=True supports_distribution=True supports_color_temperature=True supports_rgb=False supports_rgbw=False controls={'Dimmer': {'name': 'dimmer0', 'type': 'Dimmer', 'value': 0.9411764705882353}, 'Vertical': {'name': 'vertical', 'type': 'Vertical', 'value': 0.4627450980392157}, 'CCT': {'min': 2700, 'max': 4000, 'level': 0.9538461538461539, 'name': 'temperature', 'type': 'CCT', 'value': 3940.0}} >, 'Oaf8v6B8ul7HZnAdDw86lXm5n2biaOqE-1': <Casambi light Mito volo: unit=<Unit Mito volo:unit_id=1 address=4202226b11c2 value=0 distribution=0 *state=off* online=False network_id=Oaf8v6B8ul7HZnAdDw86lXm5n2biaOqE wire_id=73 >}

Any idea why that might happen?

hellqvio86 commented 2 years ago

It sounds like either its connectivity issues (network congestion, etc.) and the websocket to door.casambi.com breaks, thats how state is pushed to Home assistant (state is also pulled periodically) or the api is reporting that your device is offline.

Is that all the logs? a lot of logs seems to be missing

door.casambi.com is the address you want to sniff traffic for troubleshooting it.

fschwarz86 commented 2 years ago

With the latest version of your integration, I'm finally able to control my light! Thank you!!! It still a bit rough, but that's probably because I use my mobile phone as a Bluetooth gateway and it needs to be connected to the light when HA is starting. Maybe I'm gonna repurpose an old phone as a permanent gateway...

One last wish: I have a Occhio Mito Volo lamp, which can either distribute the light up or down. I think it's this object returned from the Casambi API:

[aiocasambi.websocket] websocket recived msg.type: aiohttp.WSMsgType.BINARY data: {'address': '4202226b11c2', 'controls': [{'name': 'dimmer0', 'type': 'Dimmer', 'value': 0.6588235294117647}, {'name': 'vertical', 'type': 'Vertical', 'value': 0.8666666666666667}, {'min': 2700, 'max': 4000, 'level': 0.11538461538461539, 'name': 'temperature', 'type': 'CCT', 'value': 2850.0}], 'method': 'unitChanged', 'fixtureId': 6660, 'priority': 3.0, 'condition': 0.0, 'wire': 88, 'activeSceneId': 0, 'sensors': {}, 'name': 'Mito volo', 'online': True, 'id': 1, 'dimLevel': 0.7627450980392156, 'on': True, 'status': 'ok'}

Do you see any chance to represent this in the HA entity?

Thanks again, Florian

hellqvio86 commented 2 years ago

Home assistant does not support the light type, but you can use the service exposed by the Casambi integration that was created by sMauldaeschle https://github.com/hellqvio86/aiocasambi/commit/9191f1913b4c0759e74c52395102bf62dd6ef6a3 , https://github.com/hellqvio86/home_assistant_casambi/commit/842d7d5e928259f2154e5eaeb0c19015de0b8ed8 and https://github.com/hellqvio86/home_assistant_casambi/commit/337b9f347d916742f510967afac8b9aeb50f8564 .

Other users have buttons that interacts with this service, so they have it exposed in the home assistant gui, I don't have any lamp with that functionality, so I don't myself have any example script sadly