Skip to content

Commit

Permalink
Merge pull request #100 from danielrivard/65-support-airleaf
Browse files Browse the repository at this point in the history
Use different unique id when serial is empty
  • Loading branch information
danielrivard authored Feb 4, 2023
2 parents ce385da + 834b7f3 commit 065fe85
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions custom_components/innova/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ def name(self):

@property
def unique_id(self):
"""Return the serial number of the system"""
return self.coordinator.innova.serial
"""Return the unique id of the unit"""
return self._device_info.unique_id

@property
def precision(self):
Expand Down
9 changes: 8 additions & 1 deletion custom_components/innova/device_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ class InnovaDeviceInfo:
def __init__(self, innova: Innova) -> None:
"""Initialize the DeviceInfo."""
self._innova = innova
self._unique_id = self._innova.serial
if not self._unique_id:
self._unique_id = self._innova.uid

@property
def device_info(self) -> DeviceInfo:
"""Provides a device specific attributes."""
return DeviceInfo(
identifiers={(DOMAIN, self._innova.serial)},
identifiers={(DOMAIN, self._unique_id)},
name=self._innova.name,
connections={(CONNECTION_NETWORK_MAC, self._innova.uid)},
manufacturer=MANUFACTURER,
Expand All @@ -26,3 +29,7 @@ def device_info(self) -> DeviceInfo:
@property
def name(self) -> str:
return self._innova.name

@property
def unique_id(self) -> str:
return self._unique_id
2 changes: 1 addition & 1 deletion custom_components/innova/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "innova",
"name": "Innova",
"version": "1.3.0",
"version": "1.3.1",
"config_flow": true,
"documentation": "https://github.com/danielrivard/homeassistant-innova/blob/main/README.md",
"issue_tracker": "https://github.com/danielrivard/homeassistant-innova/issues",
Expand Down
4 changes: 2 additions & 2 deletions custom_components/innova/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def native_value(self) -> int:

@property
def unique_id(self) -> str | None:
return f"{self._innova.serial}-{self.device_class}"
return f"{self._device_info.unique_id}-{self.device_class}"


class InnovaWaterSensor(InnovaTemperatureSensor):
Expand All @@ -83,4 +83,4 @@ def native_value(self) -> int:

@property
def unique_id(self) -> str | None:
return f"{self._innova.serial}-water-{self.device_class}"
return f"{self._device_info.unique_id}-water-{self.device_class}"

0 comments on commit 065fe85

Please sign in to comment.