diff --git a/homeassistant/components/solax/manifest.json b/homeassistant/components/solax/manifest.json index 70c017ef10e..97b01227606 100644 --- a/homeassistant/components/solax/manifest.json +++ b/homeassistant/components/solax/manifest.json @@ -3,7 +3,7 @@ "name": "Solax Inverter", "documentation": "https://www.home-assistant.io/components/solax", "requirements": [ - "solax==0.1.0" + "solax==0.1.1" ], "dependencies": [], "codeowners": ["@squishykid"] diff --git a/homeassistant/components/solax/sensor.py b/homeassistant/components/solax/sensor.py index 217d35d74ca..c834de1bd5a 100644 --- a/homeassistant/components/solax/sensor.py +++ b/homeassistant/components/solax/sensor.py @@ -32,14 +32,17 @@ async def async_setup_platform(hass, config, async_add_entities, api = solax.RealTimeAPI(config[CONF_IP_ADDRESS]) endpoint = RealTimeDataEndpoint(hass, api) + resp = await api.get_data() + serial = resp.serial_number hass.async_add_job(endpoint.async_refresh) async_track_time_interval(hass, endpoint.async_refresh, SCAN_INTERVAL) devices = [] for sensor in solax.INVERTER_SENSORS: - unit = solax.INVERTER_SENSORS[sensor][1] + idx, unit = solax.INVERTER_SENSORS[sensor] if unit == 'C': unit = TEMP_CELSIUS - devices.append(Inverter(sensor, unit)) + uid = '{}-{}'.format(serial, idx) + devices.append(Inverter(uid, serial, sensor, unit)) endpoint.sensors = devices async_add_entities(devices) @@ -79,8 +82,10 @@ class RealTimeDataEndpoint: class Inverter(Entity): """Class for a sensor.""" - def __init__(self, key, unit): + def __init__(self, uid, serial, key, unit): """Initialize an inverter sensor.""" + self.uid = uid + self.serial = serial self.key = key self.value = None self.unit = unit @@ -90,10 +95,15 @@ class Inverter(Entity): """State of this inverter attribute.""" return self.value + @property + def unique_id(self): + """Return unique id.""" + return self.uid + @property def name(self): """Name of this inverter attribute.""" - return self.key + return 'Solax {} {}'.format(self.serial, self.key) @property def unit_of_measurement(self): diff --git a/requirements_all.txt b/requirements_all.txt index 01d53584441..84b0b79fae6 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1703,7 +1703,7 @@ solaredge-local==0.1.4 solaredge==0.0.2 # homeassistant.components.solax -solax==0.1.0 +solax==0.1.1 # homeassistant.components.honeywell somecomfort==0.5.2