michaelarnauts / home-assistant-comfoconnect

Home Assistant integration for Zehnder ComfoAir trough a Zehnder ComfoConnect LAN C.
Other
28 stars 13 forks source link

Automatic discovery #3

Closed tombartosz closed 1 year ago

tombartosz commented 1 year ago

I have the following problem: My poor DHCP server is assigning random IP at boot (for a few second) and next reads static list and assign correct static ip. So if electricity power goes down and up ir brings up Zehnder and poor router at the same time and Zehnder receives random IP. If I manually restarts Zehnder after a while it will get correct static ip. Of course in that scenario, after power goes up - Home Assistant integration is not working. In old pycomfoconnect 0.3 I've solved that problem by modifying i think Bridge.py and adding code: if host ip is null - try to discover Zehner ip and use bridge[0] and also I've added corresponding code to integration etc.

I'm not a Python developer (I'm a Java one) so that stuff is far from perfect but it worked with old Home Assistant quite good. I'll attach my code here, and it would be very nice for me to add this feature to the branch.

pyconfoconnect-mod.tar.gz comfoconnect.tar.gz

P.S I've also added bypass support there (for 1 h only) and bypass sensor that works like this: If I click to open bypass, it will make sensor state = on for a while and after that sensor state is on if bypass > 0% It is also there.

Perfectly for me it would be adding 3rd option when adding integration (1st is discovered Zhender ip, 2nd - manuall, 3rd - Auto (only for one Zhender in network) )

michaelarnauts commented 1 year ago

@tombartosz you have a quite specific use case with your dhcp server. One of the features I wanted to have is to be able to configure a 2nd bridge, and that won't work well with your autodetection logic.

I would actually suggest to look into your dhcp server issue, since that could easily give other issues as wel (other hosts in your network that got a wrong IP).

The bypass support and sensors are already in the new code. I could create a service call to be able to specify the timeout you want when opening the bypass, but you could as wel add an automation to disable it after one hour.

tombartosz commented 1 year ago

@michaelarnauts I don't know it that issue is related to Comfoconnect or to router (Ubiquity Edgerouter X). I think it is not possible to set static ip in Comfoconnect and it is only one device in my home that uses DHCP and wired connection (and starts quickly - PC does not count). Maybe consider once again adding that feature, for command line interface I don't need to put IP, the same for Comfoconnect App. Also I think most of integrations will have only one bridge. Or maybe if you need to identify bridge, allow to use UUID or MAC address, not only ip ?

tombartosz commented 1 year ago

I've just implemented solution and created PR for that: https://github.com/michaelarnauts/home-assistant-comfoconnect/pull/4 . I know this is dirty (I'm not a python programmer) but maybe it will be usefull.

michaelarnauts commented 1 year ago

This is definitely still on my TODO list :)

michaelarnauts commented 1 year ago

@tombartosz I've created a fix for this here: https://github.com/michaelarnauts/home-assistant-comfoconnect/commit/cd9d1c3b6cd7c493f4f8522f643c6755fe3cc8a4

Basically, when it fails to connect to the bridge, it will try a discovery and see if it can find a bridge with the same UUID. If it can find one, it will use that IP address and update the config entry so it will now try connecting to that IP.

Thanks for your patience! :)