home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.8k stars 30.89k forks source link

Gree Climate: No device found on the network #127796

Open wosiu opened 1 month ago

wosiu commented 1 month ago

The problem

I'm running latest stable HA. When I'm trying to add my Gree AC via bultin Gree integration I'm getting: image

FWIW The host running HA container is in the same subnet as Gree devices. Ping from the host to devices IP works fine.

This is all I get from tail -f home-assistant.log | grep -i gree:

2024-10-07 09:52:07.859 INFO (MainThread) [greeclimate.discovery] Scanning for Gree devices ...
2024-10-07 09:52:07.860 DEBUG (MainThread) [greeclimate.discovery] Listening for devices on 255.255.255.255
2024-10-07 09:52:07.863 DEBUG (MainThread) [greeclimate.network] Sending packet:

So I started to run manually the discovery task gree.py script as described at the end here from different hosts in my network. Depending on the setup I get in a console:

case 1: some firewall rules which seems to break the auto-discovery broadcast thing (basically blocking incoming traffic it seems):

python gree.py --discovery
asyncio - DEBUG - Using selector: EpollSelector
__main__ - DEBUG - Scanning network for Gree devices
greeclimate.discovery - INFO - Scanning for Gree devices ...
greeclimate.discovery - DEBUG - Listening for devices on 192.168.1.255
greeclimate.discovery - DEBUG - Listening for devices on 172.18.255.255
greeclimate.discovery - DEBUG - Listening for devices on 172.17.255.255
greeclimate.discovery - DEBUG - Listening for devices on 172.22.255.255
greeclimate.discovery - DEBUG - Listening for devices on 172.20.255.255
greeclimate.network - DEBUG - Sending packet:
-> {"t": "scan"}
greeclimate.network - DEBUG - Sending packet:
-> {"t": "scan"}
greeclimate.network - DEBUG - Sending packet:
-> {"t": "scan"}
greeclimate.network - DEBUG - Sending packet:
-> {"t": "scan"}
greeclimate.network - DEBUG - Sending packet:
-> {"t": "scan"}
__main__ - INFO - Done discovering devices

BUT when I send the packet manually to my Gree AC device (its IP is 192.168.1.129) using netcat, it works fine:

nc -u 192.168.1.129 7000
{"t": "scan"}
{"t":"pack","i":1,"uid":0,"cid":"","tcid":"","pack":"[anonymised]"}

case 2: Added entry to my firewall to whitelist all incoming traffic from one of the AC devices to whole machine (which I don't like):

gree.py --discovery
asyncio - DEBUG - Using selector: EpollSelector
__main__ - DEBUG - Scanning network for Gree devices
greeclimate.discovery - INFO - Scanning for Gree devices ...
greeclimate.discovery - DEBUG - Listening for devices on 192.168.1.255
greeclimate.discovery - DEBUG - Listening for devices on 172.18.255.255
greeclimate.discovery - DEBUG - Listening for devices on 172.17.255.255
greeclimate.discovery - DEBUG - Listening for devices on 172.22.255.255
greeclimate.discovery - DEBUG - Listening for devices on 172.20.255.255
greeclimate.network - DEBUG - Sending packet:
-> {"t": "scan"}
greeclimate.network - DEBUG - Sending packet:
-> {"t": "scan"}
greeclimate.network - DEBUG - Sending packet:
-> {"t": "scan"}
greeclimate.network - DEBUG - Sending packet:
-> {"t": "scan"}
greeclimate.network - DEBUG - Sending packet:
-> {"t": "scan"}
greeclimate.cipher - DEBUG - Decrypting data: [anonymised]
greeclimate.cipher - DEBUG - Decrypted data: {"t":"dev","cid":"9424b8bb5e79","bc":"00000000000000000000000000000000","brand":"gree","catalog":"gree","mac":" [anonymised]","mid":"10001","model":"gree","name":"","lock":0,"series":"gree","vender":"1","ver":"V2.0.0","ModelType":"32792","hid":"362001065279+U-WB05RT13V1.23.bin"}
greeclimate.network - DEBUG - Received packet from 192.168.1.129:
<- {"t": "pack", "i": 1, "uid": 0, "cid": "", "tcid": "", "pack": {"t": "dev", "cid": " [anonymised]", "bc": "00000000000000000000000000000000", "brand": "gree", "catalog": "gree", "mac": "[anonymised]", "mid": "10001", "model": "gree", "name": "", "lock": 0, "series": "gree", "vender": "1", "ver": "V2.0.0", "ModelType": "32792", "hid": "362001065279+U-WB05RT13V1.23.bin"}}
greeclimate.discovery - INFO - Found gree device Device:  [anonymised] @ 192.168.1.129:7000 (mac:  [anonymised])
__main__ - INFO - Done discovering devices

That said, even with this hole in my firewall and the script returning the above entry, my home-assistant did not discover the device after the first run of adding the Gree integration in the UI. I had to run it for the second time for the device to be discovered.

And just to make it clear - I prefer I do not make this hole in my firewall. I've got plenty other wifi devices which works just fine without any extra holes in the firewall. I also tried to narrow the hole to dst port of my home assistant UI, but then the discovery breaks, because it seems different ports are used for autodiscovery - this is tcpdump on a host running HA during the autodiscovery:

sudo tcpdump -i any host 192.168.1.129
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked v1), capture size 262144 bytes

11:52:59.892295 IP 192.168.1.129.afs3-fileserver > m-hplap.33874:  rx type 105 (439)
11:53:07.880321 IP 192.168.1.129.afs3-fileserver > m-hplap.46474:  rx type 105 (439)
11:53:07.884924 IP m-hplap.41233 > 192.168.1.129.afs3-fileserver:  rx type 49 (145)
11:53:12.937872 ARP, Request who-has 192.168.1.129 tell m-hplap, length 28
11:53:12.999731 ARP, Reply 192.168.1.129 is-at 94:24:b8:bb:5e:79 (oui Unknown), length 50
11:53:17.887673 IP m-hplap.41233 > 192.168.1.129.afs3-fileserver:  rx type 49 (180)
11:53:17.925179 IP 192.168.1.129.afs3-fileserver > m-hplap.41233:  rx type 122 (195)
11:53:17.927115 IP m-hplap.41233 > 192.168.1.129.afs3-fileserver:  rx type 48 (500)
11:53:17.943335 IP 192.168.1.129.afs3-fileserver > m-hplap.41233:  rx type 79 (619)

Once the autodiscovery is completed, I was able to remove a hole from my firewall, and controling the AC from HA seems to work fine. Not sure how it will behave in a long term [EDIT] was working for a bit and then devices become unavailable and HA.

So I guess we really need this: https://github.com/home-assistant/core/issues/83048 to be added to the integration as an option. I think many people use static IPs via MAC binding for the IoT devices anyway. And I prefer static IP in the HA config too and avoid any extra broadcasting in my network if not neccessary.

What version of Home Assistant Core has the issue?

core-2024.10.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Gree Climate

Link to integration documentation on our website

https://www.home-assistant.io/integrations/gree/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 month ago

Hey there @cmroche, mind taking a look at this issue as it has been labeled with an integration (gree) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `gree` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign gree` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


gree documentation gree source (message by IssueLinks)

mag2352 commented 1 month ago

I have the exact same issue. Gree AC devices were working fine for months. Yesterday, they all simultaneously dropped from the network, with behavior described exactly as the original post. I will run the discovery outside of HA with different firewall settings to confirm as well. In the meantime, I am using https://github.com/rapi3/HA-OS-Gree, which allows manual IP definitions, but even then, 2 of my 5 units partially work (switches available, but climate unavailable). Does anyone know a way to fix that issue?

wosiu commented 1 month ago

So even though I was able to workaround adding them as described in my main post, all the devices become eventually unavailable. So I can only guess that the discovery process is run from time to time? And if devices do not respond during the discovery, they are dropped (?)