diff --git a/homeassistant/components/aqualogic/sensor.py b/homeassistant/components/aqualogic/sensor.py index 1608f6173d8..01f31757c9d 100644 --- a/homeassistant/components/aqualogic/sensor.py +++ b/homeassistant/components/aqualogic/sensor.py @@ -69,46 +69,14 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= class AquaLogicSensor(SensorEntity): """Sensor implementation for the AquaLogic component.""" + _attr_should_poll = False + def __init__(self, processor, sensor_type): """Initialize sensor.""" self._processor = processor self._type = sensor_type - self._state = None - - @property - def state(self): - """Return the state of the sensor.""" - return self._state - - @property - def name(self): - """Return the name of the sensor.""" - return f"AquaLogic {SENSOR_TYPES[self._type][0]}" - - @property - def unit_of_measurement(self): - """Return the unit of measurement the value is expressed in.""" - panel = self._processor.panel - if panel is None: - return None - if panel.is_metric: - return SENSOR_TYPES[self._type][1][0] - return SENSOR_TYPES[self._type][1][1] - - @property - def should_poll(self): - """Return the polling state.""" - return False - - @property - def device_class(self): - """Return the class of this device, from component DEVICE_CLASSES.""" - return SENSOR_TYPES[self._type][3] - - @property - def icon(self): - """Icon to use in the frontend, if any.""" - return SENSOR_TYPES[self._type][2] + self._attr_name = f"AquaLogic {SENSOR_TYPES[sensor_type][0]}" + self._attr_icon = SENSOR_TYPES[sensor_type][2] async def async_added_to_hass(self): """Register callbacks.""" @@ -123,5 +91,11 @@ class AquaLogicSensor(SensorEntity): """Update callback.""" panel = self._processor.panel if panel is not None: - self._state = getattr(panel, self._type) - self.async_write_ha_state() + if panel.is_metric: + self._attr_unit_of_measurement = SENSOR_TYPES[self._type][1][0] + self._attr_state = getattr(panel, self._type) + self.async_write_ha_state() + else: + self._attr_unit_of_measurement = SENSOR_TYPES[self._type][1][1] + else: + self._attr_unit_of_measurement = None diff --git a/homeassistant/components/aqualogic/switch.py b/homeassistant/components/aqualogic/switch.py index 08bba4cbd2d..c05bacc5f03 100644 --- a/homeassistant/components/aqualogic/switch.py +++ b/homeassistant/components/aqualogic/switch.py @@ -44,10 +44,11 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= class AquaLogicSwitch(SwitchEntity): """Switch implementation for the AquaLogic component.""" + _attr_should_poll = False + def __init__(self, processor, switch_type): """Initialize switch.""" self._processor = processor - self._type = switch_type self._state_name = { "lights": States.LIGHTS, "filter": States.FILTER, @@ -60,16 +61,7 @@ class AquaLogicSwitch(SwitchEntity): "aux_6": States.AUX_6, "aux_7": States.AUX_7, }[switch_type] - - @property - def name(self): - """Return the name of the switch.""" - return f"AquaLogic {SWITCH_TYPES[self._type]}" - - @property - def should_poll(self): - """Return the polling state.""" - return False + self._attr_name = f"AquaLogic {SWITCH_TYPES[switch_type]}" @property def is_on(self):