Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions custom_components/gree_custom/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Config flow to configure the Gree integration."""

from collections.abc import Mapping
import copy
from ipaddress import IPv4Address, IPv4Network, ip_address, ip_network
import logging
from typing import TYPE_CHECKING, Any, override
Expand Down Expand Up @@ -358,11 +359,13 @@ async def async_step_dhcp(

discover.remove(d)

# update data
new_data = dict(entry_match.data)
new_data[CONF_DEVICES][discovery_info.macaddress][
CONF_DEVICE_CONNECTION
][CONF_DEVICE_CONNECTION_LOCAL][CONF_HOST] = discovery_info.ip
# update data. Behind a gateway the DHCP MAC is the gateway,
# and the configured devices are its sub-units, so use the MAC
# of the discovered device. Copy deep, so the entry sees a change.
new_data = copy.deepcopy(dict(entry_match.data))
new_data[CONF_DEVICES][d.mac][CONF_DEVICE_CONNECTION][
CONF_DEVICE_CONNECTION_LOCAL
][CONF_HOST] = discovery_info.ip
# TODO: Check if this only returns True if the IP Changed
if (
self.hass.config_entries.async_update_entry(
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Open the device page and choose **Delete** from the three dot menu. The device i

Two mechanisms keep the stored IP address current when a device gets a new one from DHCP:

- Home Assistant reports DHCP leases of Gree devices to the integration. When the MAC matches a configured device, the stored IP is updated and the entry is reloaded. This only updates known devices. It does not start a setup flow for new ones.
- Home Assistant reports DHCP leases of Gree devices to the integration. When the MAC matches a configured device, or a gateway with configured sub-units (VRF, zone controller), the stored IP of those devices is updated and the entry is reloaded. This only updates known devices. It does not start a setup flow for new ones.
- When a poll fails, the integration runs a discovery, looks for the device MAC, and retries once with the new IP.

Both need the device to be on a network that Home Assistant can reach with a broadcast. Give the device a fixed IP when it is on another VLAN.
Expand Down
Loading