Open benyaming opened 2 months 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!
(message by CodeOwnersMention)
gree documentation gree source (message by IssueLinks)
Feel free to open a PR
The problem
The integration fails to find any devices when I attempt to set it up. (I've added the devices to the Gree+ app, and they appear in my router's admin panel.)
However, after experimenting with the
greeclimate
package locally, I noticed that executingdiscovery.scan(0)
initially returns 0 entries. Yet, if I run the same command again, it successfully locates all my devices. By increasing thewait_for
parameter to 1, the devices are detected immediately.The issue arises during the integration setup, where the device scan is conducted only once with a wait time of 0 seconds, resulting in no devices being found.
I'm not entirely clear on how the scanning process works. Therefore, I'm inquiring if it's possible to either extend the
wait_for
duration or introduce an option to manually adjust this parameter through the config flow?Examples
With
wait_for
set to 0:>>> from greeclimate.discovery import Discovery >>> d = Discovery(8) >>> await d.scan(0, bcast_ifaces=['255.255.255.255']) greeclimate.discovery - INFO - Scanning for Gree devices ... greeclimate.discovery - DEBUG - Listening for devices on 255.255.255.255 greeclimate.network - DEBUG - Sending packet: {"t": "scan"} [] >>> await d.scan(0, bcast_ifaces=['255.255.255.255']) greeclimate.discovery - INFO - Scanning for Gree devices ... greeclimate.network - DEBUG - Received packet from 192.168.1.228: {"t": "pack", "i": 1, "uid": 0, "cid": "", "tcid": "", "pack": {"t": "dev", "cid": "", "bc": "00000000000000000000000000000000", "brand": "gree", "catalog": "gree", "mac": "9424b87fc7f5", "mid": "10001", "model": "gree", "name": "", "lock": 0, "series": "gree", "vender": "1", "ver": "V3.0.0", "hid": "362001065279+U-WB05RT13V1.16.bin"}} greeclimate.discovery - DEBUG - Listening for devices on 255.255.255.255 greeclimate.network - DEBUG - Sending packet: {"t": "scan"} greeclimate.discovery - INFO - Found gree device Device: 9424b87fc7f5 @ 192.168.1.228:7000 (mac: 9424b87fc7f5) greeclimate.network - DEBUG - Received packet from 192.168.1.224: {"t": "pack", "i": 1, "uid": 0, "cid": "", "tcid": "", "pack": {"t": "dev", "cid": "", "bc": "00000000000000000000000000000000", "brand": "gree", "catalog": "gree", "mac": "9424b87fc63c", "mid": "10001", "model": "gree", "name": "", "lock": 0, "series": "gree", "vender": "1", "ver": "V3.0.0", "hid": "362001065279+U-WB05RT13V1.16.bin"}} greeclimate.discovery - INFO - Found gree device Device: 9424b87fc63c @ 192.168.1.224:7000 (mac: 9424b87fc63c) greeclimate.network - DEBUG - Received packet from 192.168.1.93: {"t": "pack", "i": 1, "uid": 0, "cid": "", "tcid": "", "pack": {"t": "dev", "cid": "", "bc": "00000000000000000000000000000000", "brand": "gree", "catalog": "gree", "mac": "9424b87fe5e3", "mid": "10001", "model": "gree", "name": "", "lock": 0, "series": "gree", "vender": "1", "ver": "V3.0.0", "hid": "362001065279+U-WB05RT13V1.16.bin"}} greeclimate.discovery - INFO - Found gree device Device: 9424b87fe5e3 @ 192.168.1.93:7000 (mac: 9424b87fe5e3) [<greeclimate.device.DeviceInfo object at 0x106682910>, <greeclimate.device.DeviceInfo object at 0x106683050>, <greeclimate.device.DeviceInfo object at 0x106683410>]
With
wait_for
set to 1:from greeclimate.discovery import Discovery >>> d = Discovery(8) >>> await d.scan(1, bcast_ifaces=['255.255.255.255']) greeclimate.discovery - INFO - Scanning for Gree devices ... greeclimate.network - DEBUG - Received packet from 192.168.1.228: {"t": "pack", "i": 1, "uid": 0, "cid": "", "tcid": "", "pack": {"t": "dev", "cid": "", "bc": "00000000000000000000000000000000", "brand": "gree", "catalog": "gree", "mac": "9424b87fc7f5", "mid": "10001", "model": "gree", "name": "", "lock": 0, "series": "gree", "vender": "1", "ver": "V3.0.0", "hid": "362001065279+U-WB05RT13V1.16.bin"}} greeclimate.discovery - DEBUG - Listening for devices on 255.255.255.255 greeclimate.network - DEBUG - Received packet from 192.168.1.224: {"t": "pack", "i": 1, "uid": 0, "cid": "", "tcid": "", "pack": {"t": "dev", "cid": "", "bc": "00000000000000000000000000000000", "brand": "gree", "catalog": "gree", "mac": "9424b87fc63c", "mid": "10001", "model": "gree", "name": "", "lock": 0, "series": "gree", "vender": "1", "ver": "V3.0.0", "hid": "362001065279+U-WB05RT13V1.16.bin"}} greeclimate.network - DEBUG - Received packet from 192.168.1.93: {"t": "pack", "i": 1, "uid": 0, "cid": "", "tcid": "", "pack": {"t": "dev", "cid": "", "bc": "00000000000000000000000000000000", "brand": "gree", "catalog": "gree", "mac": "9424b87fe5e3", "mid": "10001", "model": "gree", "name": "", "lock": 0, "series": "gree", "vender": "1", "ver": "V3.0.0", "hid": "362001065279+U-WB05RT13V1.16.bin"}} greeclimate.network - DEBUG - Sending packet: {"t": "scan"} greeclimate.network - DEBUG - Received packet from 192.168.1.224: {"t": "pack", "i": 1, "uid": 0, "cid": "", "tcid": "", "pack": {"t": "dev", "cid": "", "bc": "00000000000000000000000000000000", "brand": "gree", "catalog": "gree", "mac": "9424b87fc63c", "mid": "10001", "model": "gree", "name": "", "lock": 0, "series": "gree", "vender": "1", "ver": "V3.0.0", "hid": "362001065279+U-WB05RT13V1.16.bin"}} greeclimate.discovery - INFO - Found gree device Device: 9424b87fc63c @ 192.168.1.224:7000 (mac: 9424b87fc63c) greeclimate.network - DEBUG - Received packet from 192.168.1.93: {"t": "pack", "i": 1, "uid": 0, "cid": "", "tcid": "", "pack": {"t": "dev", "cid": "", "bc": "00000000000000000000000000000000", "brand": "gree", "catalog": "gree", "mac": "9424b87fe5e3", "mid": "10001", "model": "gree", "name": "", "lock": 0, "series": "gree", "vender": "1", "ver": "V3.0.0", "hid": "362001065279+U-WB05RT13V1.16.bin"}} greeclimate.discovery - INFO - Found gree device Device: 9424b87fe5e3 @ 192.168.1.93:7000 (mac: 9424b87fe5e3) greeclimate.network - DEBUG - Received packet from 192.168.1.228: {"t": "pack", "i": 1, "uid": 0, "cid": "", "tcid": "", "pack": {"t": "dev", "cid": "", "bc": "00000000000000000000000000000000", "brand": "gree", "catalog": "gree", "mac": "9424b87fc7f5", "mid": "10001", "model": "gree", "name": "", "lock": 0, "series": "gree", "vender": "1", "ver": "V3.0.0", "hid": "362001065279+U-WB05RT13V1.16.bin"}} greeclimate.discovery - INFO - Found gree device Device: 9424b87fc7f5 @ 192.168.1.228:7000 (mac: 9424b87fc7f5) [<greeclimate.device.DeviceInfo object at 0x106683c90>, <greeclimate.device.DeviceInfo object at 0x106683510>, <greeclimate.device.DeviceInfo object at 0x106682b50>]
What version of Home Assistant Core has the issue?
2024.4.0
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Supervised
Integration causing the issue
gree+
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
I can confirm, that @benyaming mentioned problem, and his solution also works for me, with the important addition: For me the default wait never works! Just with the extended one...
You are our man! Please PR it, in case of you already find the call in the source...
(Interesingly the discover.py has one timeout parameter, but for me that doesn't work)
Interestingly changing it in the 'Gree' (HA) component's __init__.py
for me did not work:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Gree Climate from a config entry."""
hass.data.setdefault(DOMAIN, {})
gree_discovery = DiscoveryService(hass)
hass.data[DATA_DISCOVERY_SERVICE] = gree_discovery
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
async def _async_scan_update(_=None):
bcast_addr = list(await async_get_ipv4_broadcast_addresses(hass))
#await gree_discovery.discovery.scan(0, bcast_ifaces=bcast_addr)
await gree_discovery.discovery.scan(1, bcast_ifaces=['255.255.255.255'])
But directly in the 'greeclimate' (Python) module's discovery.py
finally solved my long-term problem:
# Discovery
#async def scan(self, wait_for: int=0, bcast_ifaces: List[IPv4Address] | None=None) -> List[DeviceInfo]:
async def scan(self, wait_for: int=1, bcast_ifaces: List[IPv4Address] | None=None) -> List[DeviceInfo]:
"""Sends a discovery broadcast packet on each network interface to
locate Gree units on the network
Args:
wait_for (int): Optionally wait this many seconds for discovery
and return the devices found.
Returns:
List[DeviceInfo]: List of devices found during this scan
"""
You are definitely my/our man!!! Thanks!
UPDATE:
Sadly just with fixed IP address in discovery.py
, but at least it works now, and for me it is more than fine!
I have the same issue. How can I install this integration manually and fix the files ?
same issue... can we have some help please? 🙏🏻
@HarveyDent1 @martinblq !
In case of using Docker container based HA - Core, you have to oursource your 'greeclimate' Python package to a Docker volume, as I did with the corresponding Docker compose YAML (Python version in the path depends on you HA version):
volumes:
- 'ha-python_package-greeclimate:/usr/local/lib/python3.12/site-packages/greeclimate/'
and
ha-python_package-greeclimate:
name: 'HA-Python_package-GreeClimate'
driver: 'local'
driver_opts:
type: 'none'
o: 'bind'
device: '{path of your corresponding outsourced folder}'
After a fresh ~ docker compose up
(to apply these changes), from this point, if you change any of files of that folder, HA will use it. If you do not have files in the folder, before the config change you have to copy the current ones from the living container.
Then you can change the discovery.py
, to the earlier mentioned mutation:
.
.
.
# Discovery
# ebola: Corrected wait time from 0 to 1
#async def scan(self, wait_for: int=0, bcast_ifaces: List[IPv4Address] | None=None) -> List[DeviceInfo]:
async def scan(self, wait_for: int=1, bcast_ifaces: List[IPv4Address] | None=None) -> List[DeviceInfo]:
"""Sends a discovery broadcast packet on each network interface to
locate Gree units on the network
Args:
wait_for (int): Optionally wait this many seconds for discovery
and return the devices found.
Returns:
List[DeviceInfo]: List of devices found during this scan
"""
_LOGGER.info("Scanning for Gree devices ...")
await self.search_devices(bcast_ifaces)
if wait_for:
await asyncio.sleep(wait_for)
await asyncio.gather(*self.tasks, return_exceptions=True)
return self._device_infos
.
.
.
async def search_on_interface(self, bcast_iface: IPv4Address) -> None:
"""Search for devices on a specific interface."""
_LOGGER.debug(
"Listening for devices on %s",
bcast_iface,
)
if self._transport is None:
self._transport, _ = await self._loop.create_datagram_endpoint(
lambda: self, local_addr=("0.0.0.0", 0), allow_broadcast=True
)
# ebola: We have to refer directly to the device
#await self.send({"t": "scan"}, (str(bcast_iface), 7000))
await self.send({"t": "scan"}, ("{IP address of your climate}", 7000))
.
.
.
If you do not use HA - Core, sadly I can not help...
Is there a way to work around this issue in HA installed in VM in Proxmox? I cannot find the greeclimate/discovery.py
file anywhere...
@Tamas-Toth-ebola unfortunately I use HAOS, not a docker container :/
Enabling wait_for is not really the correct solution here. The module shouldn't be blocking HASS startup for any period of time. It's normal that discover is empty on first call, the point is to not wait and block startup while devices respond over the network.
Please enable debug logs and attach them so I can investigate why HASS is not handling those notifications when they do arrive.
Hey @cmroche, I enabled debug logging in the Gree integration and here's the log:
2024-06-27 14:04:18.463 DEBUG (MainThread) [homeassistant.components.gree] Scanning network for Gree devices
2024-06-27 14:04:18.463 INFO (MainThread) [greeclimate.discovery] Scanning for Gree devices ...
2024-06-27 14:04:18.463 DEBUG (MainThread) [greeclimate.discovery] Listening for devices on 255.255.255.255
2024-06-27 14:04:18.465 DEBUG (MainThread) [greeclimate.discovery] Listening for devices on 192.168.9.255
2024-06-27 14:04:18.467 DEBUG (MainThread) [greeclimate.discovery] Listening for devices on 192.168.163.255
2024-06-27 14:04:18.468 DEBUG (MainThread) [greeclimate.network] Sending packet:
{"t": "scan"}
2024-06-27 14:04:18.469 DEBUG (MainThread) [greeclimate.network] Sending packet:
{"t": "scan"}
2024-06-27 14:04:18.469 DEBUG (MainThread) [greeclimate.network] Sending packet:
{"t": "scan"}
2024-06-27 14:04:21.254 DEBUG (MainThread) [homeassistant.components.gree] Scanning network for Gree devices
2024-06-27 14:04:21.254 INFO (MainThread) [greeclimate.discovery] Scanning for Gree devices ...
2024-06-27 14:04:21.254 DEBUG (MainThread) [greeclimate.discovery] Listening for devices on 255.255.255.255
2024-06-27 14:04:21.254 DEBUG (MainThread) [greeclimate.discovery] Listening for devices on 192.168.9.255
2024-06-27 14:04:21.255 DEBUG (MainThread) [greeclimate.discovery] Listening for devices on 192.168.163.255
2024-06-27 14:04:21.257 DEBUG (MainThread) [greeclimate.network] Sending packet:
{"t": "scan"}
2024-06-27 14:04:21.257 DEBUG (MainThread) [greeclimate.network] Sending packet:
{"t": "scan"}
2024-06-27 14:04:21.258 DEBUG (MainThread) [greeclimate.network] Sending packet:
{"t": "scan"}
My HAOS is added to two VLANs — the default LAN 192.168.160.0/21
and IOT vlan 192.168.9.0/24
. Gree unit has IP 192.168.9.17
@jmatraszek If you set your HASS interfaces to only use your IoT vlan, so it's only scanning one, does that address the issue?
@jmatraszek Also, check if BCast storm protections are enabled on your switches and try turning them off.
The problem
The integration fails to find any devices when I attempt to set it up. (I've added the devices to the Gree+ app, and they appear in my router's admin panel.)
However, after experimenting with the
greeclimate
package locally, I noticed that executingdiscovery.scan(0)
initially returns 0 entries. Yet, if I run the same command again, it successfully locates all my devices. By increasing thewait_for
parameter to 1, the devices are detected immediately.The issue arises during the integration setup, where the device scan is conducted only once with a wait time of 0 seconds, resulting in no devices being found.
I'm not entirely clear on how the scanning process works. Therefore, I'm inquiring if it's possible to either extend the
wait_for
duration or introduce an option to manually adjust this parameter through the config flow?Examples
With
wait_for
set to 0:With
wait_for
set to 1:What version of Home Assistant Core has the issue?
2024.4.0
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Supervised
Integration causing the issue
gree+
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