From e5487722a8bde0da183b18458942a500819aaa11 Mon Sep 17 00:00:00 2001 From: Fredrik Erlandsson Date: Wed, 19 Dec 2018 08:18:40 +0100 Subject: [PATCH] Add device_info to Daikin (#19372) * add device_info to Daikin * Use the constant CONNECTION_NETWORK_MAC from the device registry helper. --- homeassistant/components/climate/daikin.py | 5 +++++ homeassistant/components/daikin/__init__.py | 16 +++++++++++++++- homeassistant/components/sensor/daikin.py | 5 +++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/climate/daikin.py b/homeassistant/components/climate/daikin.py index fa7d886e6cd..45589c12864 100644 --- a/homeassistant/components/climate/daikin.py +++ b/homeassistant/components/climate/daikin.py @@ -265,3 +265,8 @@ class DaikinClimate(ClimateDevice): def update(self): """Retrieve latest state.""" self._api.update() + + @property + def device_info(self): + """Return a device description for device registry.""" + return self._api.device_info diff --git a/homeassistant/components/daikin/__init__.py b/homeassistant/components/daikin/__init__.py index 6607f712537..86ad6c0a160 100644 --- a/homeassistant/components/daikin/__init__.py +++ b/homeassistant/components/daikin/__init__.py @@ -15,6 +15,7 @@ import voluptuous as vol from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_HOSTS import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC from homeassistant.helpers.typing import HomeAssistantType from homeassistant.util import Throttle @@ -129,4 +130,17 @@ class DaikinApi: @property def mac(self): """Return mac-address of device.""" - return self.device.values.get('mac') + return self.device.values.get(CONNECTION_NETWORK_MAC) + + @property + def device_info(self): + """Return a device description for device registry.""" + info = self.device.values + return { + 'connections': {(CONNECTION_NETWORK_MAC, self.mac)}, + 'identifieres': self.mac, + 'manufacturer': 'Daikin', + 'model': info.get('model'), + 'name': info.get('name'), + 'sw_version': info.get('ver').replace('_', '.'), + } diff --git a/homeassistant/components/sensor/daikin.py b/homeassistant/components/sensor/daikin.py index 55b04dc1a68..f887ccf64a0 100644 --- a/homeassistant/components/sensor/daikin.py +++ b/homeassistant/components/sensor/daikin.py @@ -104,3 +104,8 @@ class DaikinClimateSensor(Entity): def update(self): """Retrieve latest state.""" self._api.update() + + @property + def device_info(self): + """Return a device description for device registry.""" + return self._api.device_info