diff --git a/homeassistant/components/plaato/binary_sensor.py b/homeassistant/components/plaato/binary_sensor.py index a8b7dc51c1e..e8fbaa5d6f1 100644 --- a/homeassistant/components/plaato/binary_sensor.py +++ b/homeassistant/components/plaato/binary_sensor.py @@ -39,20 +39,17 @@ async def async_setup_entry( class PlaatoBinarySensor(PlaatoEntity, BinarySensorEntity): """Representation of a Binary Sensor.""" + def __init__(self, data, sensor_type, coordinator=None) -> None: + """Initialize plaato binary sensor.""" + super().__init__(data, sensor_type, coordinator) + if sensor_type is PlaatoKeg.Pins.LEAK_DETECTION: + self._attr_device_class = BinarySensorDeviceClass.PROBLEM + elif sensor_type is PlaatoKeg.Pins.POURING: + self._attr_device_class = BinarySensorDeviceClass.OPENING + @property def is_on(self): """Return true if the binary sensor is on.""" if self._coordinator is not None: return self._coordinator.data.binary_sensors.get(self._sensor_type) return False - - @property - def device_class(self) -> BinarySensorDeviceClass | None: - """Return the class of this device, from BinarySensorDeviceClass.""" - if self._coordinator is None: - return None - if self._sensor_type is PlaatoKeg.Pins.LEAK_DETECTION: - return BinarySensorDeviceClass.PROBLEM - if self._sensor_type is PlaatoKeg.Pins.POURING: - return BinarySensorDeviceClass.OPENING - return None diff --git a/homeassistant/components/plaato/sensor.py b/homeassistant/components/plaato/sensor.py index b43e18e52f6..f3d9a5c3e41 100644 --- a/homeassistant/components/plaato/sensor.py +++ b/homeassistant/components/plaato/sensor.py @@ -72,17 +72,11 @@ async def async_setup_entry( class PlaatoSensor(PlaatoEntity, SensorEntity): """Representation of a Plaato Sensor.""" - @property - def device_class(self) -> SensorDeviceClass | None: - """Return the class of this device, from SensorDeviceClass.""" - if ( - self._coordinator is not None - and self._sensor_type == PlaatoKeg.Pins.TEMPERATURE - ): - return SensorDeviceClass.TEMPERATURE - if self._sensor_type == ATTR_TEMP: - return SensorDeviceClass.TEMPERATURE - return None + def __init__(self, data, sensor_type, coordinator=None) -> None: + """Initialize plaato sensor.""" + super().__init__(data, sensor_type, coordinator) + if sensor_type is PlaatoKeg.Pins.TEMPERATURE or sensor_type == ATTR_TEMP: + self._attr_device_class = SensorDeviceClass.TEMPERATURE @property def native_value(self):