From 202ee0cd3d7cbf9bd9cfc10a7a04d026c7bb937a Mon Sep 17 00:00:00 2001 From: Sander Jochems Date: Sat, 12 Feb 2022 01:04:50 +0100 Subject: [PATCH] Add device info to Solax (#65244) --- homeassistant/components/solax/const.py | 2 ++ homeassistant/components/solax/sensor.py | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/solax/const.py b/homeassistant/components/solax/const.py index bf8abe19af1..65894013adc 100644 --- a/homeassistant/components/solax/const.py +++ b/homeassistant/components/solax/const.py @@ -2,3 +2,5 @@ DOMAIN = "solax" + +MANUFACTURER = "SolaX Power" diff --git a/homeassistant/components/solax/sensor.py b/homeassistant/components/solax/sensor.py index 83c1ace569d..6f1b5ef6cf3 100644 --- a/homeassistant/components/solax/sensor.py +++ b/homeassistant/components/solax/sensor.py @@ -19,11 +19,12 @@ from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT, TEMP_CELSIUS from homeassistant.core import HomeAssistant from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -from .const import DOMAIN +from .const import DOMAIN, MANUFACTURER _LOGGER = logging.getLogger(__name__) @@ -46,6 +47,7 @@ async def async_setup_entry( api = hass.data[DOMAIN][entry.entry_id] resp = await api.get_data() serial = resp.serial_number + version = resp.version endpoint = RealTimeDataEndpoint(hass, api) hass.async_add_job(endpoint.async_refresh) async_track_time_interval(hass, endpoint.async_refresh, SCAN_INTERVAL) @@ -72,7 +74,9 @@ async def async_setup_entry( device_class = SensorDeviceClass.BATTERY state_class = SensorStateClass.MEASUREMENT uid = f"{serial}-{idx}" - devices.append(Inverter(uid, serial, sensor, unit, state_class, device_class)) + devices.append( + Inverter(uid, serial, version, sensor, unit, state_class, device_class) + ) endpoint.sensors = devices async_add_entities(devices) @@ -140,6 +144,7 @@ class Inverter(SensorEntity): self, uid, serial, + version, key, unit, state_class=None, @@ -151,6 +156,12 @@ class Inverter(SensorEntity): self._attr_native_unit_of_measurement = unit self._attr_state_class = state_class self._attr_device_class = device_class + self._attr_device_info = DeviceInfo( + identifiers={(DOMAIN, serial)}, + manufacturer=MANUFACTURER, + name=f"Solax {serial}", + sw_version=version, + ) self.key = key self.value = None