Skip to content

Commit

Permalink
Add unique_id support
Browse files Browse the repository at this point in the history
  • Loading branch information
Petro31 committed May 29, 2021
1 parent d698a0d commit 275144e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion custom_components/multizone_controller/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the multizone sensor."""

unique_id = config.get(CONF_UNIQUE_ID)
name = config[CONF_NAME]
volume_min = config[CONF_VOLUME_MIN]
volume_max = config[CONF_VOLUME_MAX]
Expand Down Expand Up @@ -120,7 +121,14 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(
[
MultizoneSensor(
name, zones, all_zones, volume_min, volume_max, volume_inc, snap
unique_id,
name,
zones,
all_zones,
volume_min,
volume_max,
volume_inc,
snap,
)
]
)
Expand Down Expand Up @@ -173,6 +181,7 @@ class MultizoneSensor(SensorEntity):

def __init__(
self,
unique_id: str,
name: str,
zones: dict[str, Zone],
all_zones: AllZones,
Expand All @@ -181,6 +190,7 @@ def __init__(
volume_inc: int,
snap: bool,
):
self._unique_id = unique_id
self._name = name
self._zones = zones
self._all_zones = all_zones
Expand All @@ -205,6 +215,11 @@ async def async_added_to_hass(self):
)
)

@property
def unique_id(self):
"""Return the unique id of this sensor."""
return self._unique_id

@property
def state(self):
"""Return the state of the sensor."""
Expand Down

0 comments on commit 275144e

Please sign in to comment.