diff --git a/homeassistant/components/aurora_abb_powerone/sensor.py b/homeassistant/components/aurora_abb_powerone/sensor.py index cd4a71d1b31..9c798b8e6d4 100644 --- a/homeassistant/components/aurora_abb_powerone/sensor.py +++ b/homeassistant/components/aurora_abb_powerone/sensor.py @@ -51,32 +51,13 @@ class AuroraABBSolarPVMonitorSensor(SensorEntity): """Representation of a Sensor.""" _attr_state_class = STATE_CLASS_MEASUREMENT + _attr_unit_of_measurement = POWER_WATT + _attr_device_class = DEVICE_CLASS_POWER def __init__(self, client, name, typename): """Initialize the sensor.""" - self._name = f"{name} {typename}" + self._attr_name = f"{name} {typename}" self.client = client - self._state = None - - @property - def name(self): - """Return the name of the sensor.""" - return self._name - - @property - def state(self): - """Return the state of the sensor.""" - return self._state - - @property - def unit_of_measurement(self): - """Return the unit of measurement.""" - return POWER_WATT - - @property - def device_class(self): - """Return the device class.""" - return DEVICE_CLASS_POWER def update(self): """Fetch new state data for the sensor. @@ -87,8 +68,7 @@ class AuroraABBSolarPVMonitorSensor(SensorEntity): self.client.connect() # read ADC channel 3 (grid power output) power_watts = self.client.measure(3, True) - self._state = round(power_watts, 1) - # _LOGGER.debug("Got reading %fW" % self._state) + self._attr_state = round(power_watts, 1) except AuroraError as error: # aurorapy does not have different exceptions (yet) for dealing # with timeout vs other comms errors. @@ -102,7 +82,7 @@ class AuroraABBSolarPVMonitorSensor(SensorEntity): _LOGGER.debug("No response from inverter (could be dark)") else: raise error - self._state = None + self._attr_state = None finally: if self.client.serline.isOpen(): self.client.close()