lkempf/casambi-bt

Changed password, network no longer reachable

Closed this issue ยท 9 comments

I changed the password of my network. Now I get errors in the home assistant integration which still persists even when I change the password back to what it was.

2023-11-10 23:16:17.940 INFO (MainThread) [CasambiBt._casambi] Trying to connect to casambi network 41:...:F1...
2023-11-10 23:16:17.941 INFO (MainThread) [CasambiBt._keystore] Loading keys...
2023-11-10 23:16:17.943 INFO (MainThread) [CasambiBt._keystore] Loaded 1 keys.
2023-11-10 23:16:17.943 INFO (MainThread) [CasambiBt._network] Loading session...
2023-11-10 23:16:17.944 INFO (MainThread) [CasambiBt._network] Loading unit type cache...
2023-11-10 23:16:17.945 INFO (MainThread) [CasambiBt._network] Getting network id...
2023-11-10 23:16:18.159 INFO (MainThread) [CasambiBt._network] Got network id 64i...xD.
2023-11-10 23:16:18.159 INFO (MainThread) [CasambiBt._network] Updating network...
2023-11-10 23:16:18.162 INFO (MainThread) [CasambiBt._network] Loaded cached network. Revision: 24
2023-11-10 23:16:18.202 ERROR (MainThread) [CasambiBt._network] Update failed: 410
2023-11-10 23:16:18.202 ERROR (MainThread) [custom_components.casambi_bt.config_flow] Unexpected exception
File "/config/custom_components/casambi_bt/config_flow.py", line 139, in async_step_user
File "/config/custom_components/casambi_bt/config_flow.py", line 55, in _validate_input
File "/usr/local/lib/python3.11/site-packages/CasambiBt/_casambi.py", line 138, in connect
File "/usr/local/lib/python3.11/site-packages/CasambiBt/_network.py", line 197, in update
CasambiBt.errors.NetworkUpdateError: Could not update network!

Any idea how to fix it?
To be honest, the password flow in the casaba app is not that reliable. I changed the password, but it looks like it's not able to persist it, the field is empty after I store it.

lkempf commented

I think you invalidated your session or something and this isn't getting picked up. Is it fixable by deleting the cache?

I should probably implement cache invalidation when the login flow is redone.

The cache in my local browser, or somewhere in HA?

Would be nice if every error bubbles up to HA as hand full of exceptions.

lkempf commented

The casambi-bt-store folder that should be placed in your HA config folder.

And I agree that exception handling is quite messy currently.

Nice, deleting the network folder solved the issue. This should be done when integration is removed, no?

lkempf commented

I would say it should be done when the integration is configured. But there are two bugs here. Cache invalidation should be implemented but the library should also recognize that the session it is using is expired.

The location is determined in the library, right? I think it would be better if the ha integration would store its data in .storage/casambi-bt.` or something like that as it's done for some other integrations. That way we're not polluting the directory visible to the user.

lkempf commented

Yes the library just uses the CWD. I don't think hardcoding a dependency to a HA path is a good idea so the path would have to be customizeable

Yes, defaulting to cwd is fine, but would be nice if this could be changed in HA.

Thank you for this! I was encountering the same issue, and deleting the casambi-bt-store directory in config was the thing that fixed it.