From c47749557f60b29c5132783123796272714f0d49 Mon Sep 17 00:00:00 2001 From: Fredrik Erlandsson Date: Tue, 27 Nov 2018 13:43:10 +0100 Subject: [PATCH] Add unique_id for Daikin entities --- homeassistant/components/climate/daikin.py | 5 +++++ homeassistant/components/daikin.py | 5 +++++ homeassistant/components/sensor/daikin.py | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/homeassistant/components/climate/daikin.py b/homeassistant/components/climate/daikin.py index 4a5c325889371f..38c78bfdb3d699 100644 --- a/homeassistant/components/climate/daikin.py +++ b/homeassistant/components/climate/daikin.py @@ -192,6 +192,11 @@ def name(self): """Return the name of the thermostat, if any.""" return self._api.name + @property + def unique_id(self): + """Return a unique ID.""" + return self._api.mac + @property def temperature_unit(self): """Return the unit of measurement which this thermostat uses.""" diff --git a/homeassistant/components/daikin.py b/homeassistant/components/daikin.py index 4fcd33bee26da4..e2e4572939d24c 100644 --- a/homeassistant/components/daikin.py +++ b/homeassistant/components/daikin.py @@ -132,3 +132,8 @@ def update(self, **kwargs): _LOGGER.warning( "Connection failed for %s", self.ip_address ) + + @property + def mac(self): + """Return mac-address of device.""" + return self.device.values.get('mac') diff --git a/homeassistant/components/sensor/daikin.py b/homeassistant/components/sensor/daikin.py index 3445eb531aa239..eae0c6e96147bd 100644 --- a/homeassistant/components/sensor/daikin.py +++ b/homeassistant/components/sensor/daikin.py @@ -71,6 +71,11 @@ def __init__(self, api, monitored_state, units: UnitSystem, if self._sensor[CONF_TYPE] == SENSOR_TYPE_TEMPERATURE: self._unit_of_measurement = units.temperature_unit + @property + def unique_id(self): + """Return a unique ID.""" + return "{}-{}".format(self._api.mac, self._device_attribute) + def get(self, key): """Retrieve device settings from API library cache.""" value = None