Skip to content

Commit

Permalink
Use unique_id instead of mac address for #22
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre0512 committed Apr 15, 2023
1 parent 83c5e34 commit d91b3ed
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions custom_components/hon/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non
coordinators = hass.data[DOMAIN]["coordinators"]
appliances = []
for device in hon.appliances:
if device.mac_address in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.mac_address]
if device.unique_id in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.unique_id]
else:
coordinator = HonCoordinator(hass, device)
hass.data[DOMAIN]["coordinators"][device.mac_address] = coordinator
hass.data[DOMAIN]["coordinators"][device.unique_id] = coordinator
await coordinator.async_config_entry_first_refresh()

if descriptions := BINARY_SENSORS.get(device.appliance_type):
Expand Down
6 changes: 3 additions & 3 deletions custom_components/hon/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non
coordinators = hass.data[DOMAIN]["coordinators"]
appliances = []
for device in hon.appliances:
if device.mac_address in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.mac_address]
if device.unique_id in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.unique_id]
else:
coordinator = HonCoordinator(hass, device)
hass.data[DOMAIN]["coordinators"][device.mac_address] = coordinator
hass.data[DOMAIN]["coordinators"][device.unique_id] = coordinator
await coordinator.async_config_entry_first_refresh()

if descriptions := BUTTONS.get(device.appliance_type):
Expand Down
6 changes: 3 additions & 3 deletions custom_components/hon/hon.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ def __init__(self, hass, entry, coordinator, device: HonAppliance) -> None:
self._hass = hass
self._device = device

self._attr_unique_id = self._device.mac_address
self._attr_unique_id = self._device.unique_id

@property
def device_info(self):
return DeviceInfo(
identifiers={(DOMAIN, self._device.mac_address)},
identifiers={(DOMAIN, self._device.unique_id)},
manufacturer=self._device.get("brand", ""),
name=self._device.nick_name
if self._device.nick_name
Expand All @@ -43,7 +43,7 @@ def __init__(self, hass, device: HonAppliance):
super().__init__(
hass,
_LOGGER,
name=device.mac_address,
name=device.unique_id,
update_interval=timedelta(seconds=30),
)
self._device = device
Expand Down
4 changes: 2 additions & 2 deletions custom_components/hon/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"documentation": "https://github.com/Andre0512/hon/",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/Andre0512/hon/issues",
"requirements": ["pyhOn==0.8.0b2"],
"version": "0.6.0-beta.1"
"requirements": ["pyhOn==0.8.0b3"],
"version": "0.6.0-beta.2"
}
6 changes: 3 additions & 3 deletions custom_components/hon/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non
coordinators = hass.data[DOMAIN]["coordinators"]
appliances = []
for device in hon.appliances:
if device.mac_address in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.mac_address]
if device.unique_id in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.unique_id]
else:
coordinator = HonCoordinator(hass, device)
hass.data[DOMAIN]["coordinators"][device.mac_address] = coordinator
hass.data[DOMAIN]["coordinators"][device.unique_id] = coordinator
await coordinator.async_config_entry_first_refresh()

if descriptions := NUMBERS.get(device.appliance_type):
Expand Down
6 changes: 3 additions & 3 deletions custom_components/hon/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non
coordinators = hass.data[DOMAIN]["coordinators"]
appliances = []
for device in hon.appliances:
if device.mac_address in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.mac_address]
if device.unique_id in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.unique_id]
else:
coordinator = HonCoordinator(hass, device)
hass.data[DOMAIN]["coordinators"][device.mac_address] = coordinator
hass.data[DOMAIN]["coordinators"][device.unique_id] = coordinator
await coordinator.async_config_entry_first_refresh()

if descriptions := SELECTS.get(device.appliance_type):
Expand Down
6 changes: 3 additions & 3 deletions custom_components/hon/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non
coordinators = hass.data[DOMAIN]["coordinators"]
appliances = []
for device in hon.appliances:
if device.mac_address in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.mac_address]
if device.unique_id in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.unique_id]
else:
coordinator = HonCoordinator(hass, device)
hass.data[DOMAIN]["coordinators"][device.mac_address] = coordinator
hass.data[DOMAIN]["coordinators"][device.unique_id] = coordinator
await coordinator.async_config_entry_first_refresh()

if descriptions := SENSORS.get(device.appliance_type):
Expand Down
6 changes: 3 additions & 3 deletions custom_components/hon/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non
coordinators = hass.data[DOMAIN]["coordinators"]
appliances = []
for device in hon.appliances:
if device.mac_address in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.mac_address]
if device.unique_id in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.unique_id]
else:
coordinator = HonCoordinator(hass, device)
hass.data[DOMAIN]["coordinators"][device.mac_address] = coordinator
hass.data[DOMAIN]["coordinators"][device.unique_id] = coordinator
await coordinator.async_config_entry_first_refresh()

if descriptions := SWITCHES.get(device.appliance_type):
Expand Down

0 comments on commit d91b3ed

Please sign in to comment.