Swamp-Ig / pizone

Python interface to iZone aircon controller.
GNU General Public License v3.0
12 stars 10 forks source link

Discovery issue with iZoneV2 #3

Closed njoc-dev closed 3 years ago

njoc-dev commented 4 years ago

Hi there.

Have just had iZone-enabled aircon installed, so haven't had any operating iZone integrations in homeassistant as yet. When i attempt to discover the iZone instance i get a response of "No iZone devices found on the network". The logs show that the iZone controller has responded, but the pizone detection hasn't picked it up.

Issue seems to be in the iZone descriptor sent back from the controller being "iZoneV2" instead of the expected "iZone". Code at line 379 in discovery.py is not expecting a V2: https://github.com/Swamp-Ig/pizone/blob/06735e0be9a2df92d2ff55725d9f58b392103d2a/pizone/discovery.py#L379

Logs below show the sending and receiving of discovery packets:

2020-01-15 16:01:36 INFO (MainThread) [pizone.discovery] Starting discovery protocol 2020-01-15 16:01:36 DEBUG (MainThread) [pizone.discovery] Sending discovery message to addr 192.168.X.255 2020-01-15 16:01:36 DEBUG (MainThread) [pizone.discovery] Sending discovery message to addr 192.168.X.255 2020-01-15 16:01:36 DEBUG (MainThread) [pizone.discovery] Sending discovery message to addr 172.30.X.255 2020-01-15 16:01:36 DEBUG (MainThread) [pizone.discovery] Sending discovery message to addr 172.17.255.255 2020-01-15 16:01:36 DEBUG (MainThread) [pizone.discovery] Datagram Recieved b'ASPort_12107,Mac_000032876,IP_192.168.X.Y,iZoneV2,iLight,iDrate' 2020-01-15 16:01:36 DEBUG (MainThread) [pizone.discovery] Datagram Recieved b'ASPort_12107,Mac_000032876,IP_192.168.X.Y,iZoneV2,iLight,iDrate' 2020-01-15 16:01:56 INFO (MainThread) [pizone.discovery] Close called on discovery service. 2020-01-15 16:01:56 DEBUG (MainThread) [pizone.discovery] Connection Lost 2020-01-15 16:01:56 DEBUG (MainThread) [homeassistant.components.izone.config_flow] No controllers found`

Looking first of all to make sure that i've interpretted this correctly, then to see if we can provide a solution. If i can spin up a dev instance i'll create a pull request.

Thanks, Nick

Swamp-Ig commented 4 years ago

Thanks for your report. I should be able to fix it this weekend.

njoc-dev commented 4 years ago

That's awesome. Let me know how I can help :)

Swamp-Ig commented 4 years ago

OK, I've pushed up a new version of the file. I'm not entirely sure it will work though, if the API version number has changed then it's very possible the API itself will be different.

In any case here's the file that replaces the existing discovery.py, which you can just overwrite to test it on your system.

If you're using hass.io, login to wherever it's running then execute this:

> docker exec -it homeassistant bash -l
> cd /usr/local/lib/python3.7/site-packages/pizone
> cat > discovery.py
**paste in the new file contents**
^C
> exit
> docker restart homeassistant

Then see how you go. If you need help getting it onto you system, ping me in the #homeassistant support channel on discord, @Penny

njoc-dev commented 4 years ago

@Swamp-Ig thanks - some progress, but seems to still have an issue in discovery.

Followed your instructions to update hassio

Screenshots and log attached

Screen Shot 2020-01-27 at 4 44 20 pm Screen Shot 2020-01-27 at 4 44 58 pm

Let me know what else i can do to test, and what other info you need. Thanks heaps for your efforts!

Nick

Swamp-Ig commented 4 years ago

I suspect like I was concerned about, the API has changed. It's going to be very hard for me to fix since I don't have a V2 unit at home.

njoc-dev commented 4 years ago

@Swamp-Ig understood. I've forked this and am working through it atm. Hope to report back soon with some feedback

Swamp-Ig commented 4 years ago

Awesome! Feel free to contact me on the discord.

njoc-dev commented 4 years ago

@Swamp-Ig i have no idea what i did wrong, but its all working now. I literally just added more debug logging to understand the flow, used your method above to overwrite the release version files, and the discovery worked a charm! I can only assume i stuffed up somehow.

Awesome work on this library - appreciate your efforts :)

Swamp-Ig commented 4 years ago

Oh great, I will update the HA version of the library and push up the new version.

Swamp-Ig commented 4 years ago

Hey,

So I've contacted the iZone people, it looks like the API has really just been extended for V2, The only exception would be for iSave if you have that option.

I will continue to discuss with them and see how we go.

Swamp-Ig commented 4 years ago

Just pushed up a PR to home assistant to fix this issue.

home-assistant/core#32552

njoc-dev commented 4 years ago

Awesome :) cheers @Swamp-Ig

Nick-Adams-AU commented 4 years ago

Hey @Swamp-Ig Any chance you can also push support to HA to manage AirMaxCommand? It would be handy for HA to be able to change the zone air flow. Thanks.

aarooren commented 4 years ago

Hey @Swamp-Ig I was a happy user of your iZone component until HA was upgraded to 0.107.x

Currently I am on 0.107.5, but my HA refuse to discover the iZone at all. I have pretty much tested with all 0.107.x versions and found that HA does not detect the iZone.

HA iZone

When I go back to my previous version 0.106.6, I can still see the HA detecting iZone and all my iZone automatons works fine.

Could you kindly check whether any changes on the component for 0.107.x has a negative impact on the pre-existing iZone devices please?

Thanks in advance.

ufu- commented 4 years ago

Hey @Swamp-Ig

same here, after 0.107.x all iZone devices are orphaned, if I remove and re-add the integration nothing is found on the network. As aarooren already pointed out, reverting to 0.106.6 fixes the issue and everything works.

Any advice would me much appreciated. Also I subscribe to @Nick-Adams-AU idea, airflow would be awesome to have.

Cheers,

Swamp-Ig commented 4 years ago

Hey, Sorry I'm definitely not going to have time to look at this for some time given the COVID situation. Once things have settled down I might get a chance. It works for 106.5 for me.

ufu- commented 4 years ago

@aarooren As a temporary solution, if you map the 0.106.6 iZone component folder to your HA installation it does fix the issue and everything works. I've tested it up to HA 0.109 dev

Nick-Adams-AU commented 4 years ago

@ufu- Do you use Docker? If so, check if this fixes your issue:

https://github.com/home-assistant/core/issues/32992#issuecomment-601608344

aarooren commented 4 years ago

@ufu- Based on your suggestion I have mapped the 0.106.6 iZone folder as a custom component - it worked for me. Many thanks.

SuraMendis commented 3 years ago

Is there documentation on the v2 API?

Swamp-Ig commented 3 years ago

Yeh there is, it's just extra stuff that isn't that useful for HA purposes though and isn't a radical change.

Have picked this issue up again, I have the fixes ready to go and will be pushing out soon.

Nick-Adams-AU commented 3 years ago

@Swamp-Ig Any chance we might be able to get a HA service to control the zone air-flow in those changes? Happy to help test and review where I can.

Swamp-Ig commented 3 years ago

Do you mean the max/min airflow? The current library does allow this, but it's not integrated into HA. There could be some custom services made for these. If you want to code them up I'd be happy to accept.

Nick-Adams-AU commented 3 years ago

Do you mean the max/min airflow? The current library does allow this, but it's not integrated into HA.

Sorry, yes, that's what I'm after :) At the moment I just turn the zone on and off in HA to control temperature. It would be much more effective to use the fine-grained zone airflow %.

There could be some custom services made for these. If you want to code them up I'd be happy to accept.

That would be awesome however I'm not much of a Python programmer unfortunately. I'm ok at testing and debugging. Let me know if I can be of assistance.

Swamp-Ig commented 3 years ago

That would be awesome however I'm not much of a Python programmer unfortunately. I'm ok at testing and debugging. Let me know if I can be of assistance.

OK well it's not a priority for me I'm afraid. Also please keep this on-topic. This question isn't anything to do with the issue.

Swamp-Ig commented 3 years ago

This is now PRed in HA for the next release.

Karl-Johns commented 2 years ago

Hi @Swamp-Ig late to this thread, but I am running HA 2022.7.3 and have just tried to install the iZone integration. I get the following:

2022-07-18 17:05:35 INFO (MainThread) [pizone.discovery] Starting discovery protocol 2022-07-18 17:05:35 DEBUG (MainThread) [pizone.discovery] Sending discovery message to addr 192.XXX.XX.255 2022-07-18 17:05:35 DEBUG (MainThread) [pizone.discovery] Sending discovery message to addr 172.XXX.XXX.255 2022-07-18 17:05:35 DEBUG (MainThread) [pizone.discovery] Sending discovery message to addr 172.XXX.XXX.255 2022-07-18 17:05:55 INFO (MainThread) [pizone.discovery] Close called on discovery service. 2022-07-18 17:05:55 DEBUG (MainThread) [pizone.discovery] Connection Lost 2022-07-18 17:05:55 DEBUG (MainThread) [homeassistant.components.izone.config_flow] No controllers found 2022-07-18 17:41:32 INFO (MainThread) [pizone.discovery] Starting discovery protocol 2022-07-18 17:41:32 DEBUG (MainThread) [pizone.discovery] Sending discovery message to addr 192.XXX.XXX.255 2022-07-18 17:41:32 DEBUG (MainThread) [pizone.discovery] Sending discovery message to addr 172.XXX.XXX.255 2022-07-18 17:41:32 DEBUG (MainThread) [pizone.discovery] Sending discovery message to addr 172.XXX.XXX.255 2022-07-18 17:41:52 INFO (MainThread) [pizone.discovery] Close called on discovery service. 2022-07-18 17:41:52 DEBUG (MainThread) [pizone.discovery] Connection Lost 2022-07-18 17:41:52 DEBUG (MainThread) [homeassistant.components.izone.config_flow] No controllers found

From the above thread, I assumed this was working. i did note that my iZone hub was on another subnet (I have another subnet for all edge and iot devices), but not sure if that would pose a problem, as my other devices get found with other integrations.

Any help would be awesome.

Nick-Adams-AU commented 2 years ago

I'm pretty sure that discovery will only work on the same subnet has they discovery packets are broadcast so won't be seen on another subnet.

Karl-Johns commented 2 years ago

@Nick-Adams-AU thanks nic. Interestingly however, the sonoff devices i use are on a different subnet to the HA server and it still finds them.

Nick-Adams-AU commented 2 years ago

I don't think Sonoff use broadcast packets for discovery which would explain the difference in behaviour.