diff --git a/custom_components/hpprinter/binary_sensor.py b/custom_components/hpprinter/binary_sensor.py index 845ec5c..8eaab49 100644 --- a/custom_components/hpprinter/binary_sensor.py +++ b/custom_components/hpprinter/binary_sensor.py @@ -3,6 +3,8 @@ For more details about this platform, please refer to the documentation at https://home-assistant.io/components/binary_sensor.hp_printer/ """ +from __future__ import annotations + import logging from homeassistant.components.binary_sensor import BinarySensorEntity @@ -47,7 +49,7 @@ def is_on(self): return bool(self.entity.state) @property - def device_class(self) -> BinarySensorDeviceClass: + def device_class(self) -> BinarySensorDeviceClass | str | None: """Return the class of this sensor.""" return self.entity.binary_sensor_device_class diff --git a/custom_components/hpprinter/models/entity_data.py b/custom_components/hpprinter/models/entity_data.py index 7dd56bb..db2b398 100644 --- a/custom_components/hpprinter/models/entity_data.py +++ b/custom_components/hpprinter/models/entity_data.py @@ -24,8 +24,8 @@ def __init__(self): self.device_name = "" self.status = ENTITY_STATUS_CREATED self.disabled = False - self.binary_sensor_device_class: None - self.sensor_device_class: None + self.binary_sensor_device_class = None + self.sensor_device_class = None def __repr__(self): obj = { diff --git a/custom_components/hpprinter/sensor.py b/custom_components/hpprinter/sensor.py index 493046b..487e593 100644 --- a/custom_components/hpprinter/sensor.py +++ b/custom_components/hpprinter/sensor.py @@ -3,8 +3,11 @@ For more details about this platform, please refer to the documentation at https://home-assistant.io/components/binary_sensor.hp_printer/ """ +from __future__ import annotations + import logging +from homeassistant.components.sensor import SensorEntity from homeassistant.core import HomeAssistant from .helpers.const import * @@ -36,7 +39,7 @@ async def async_unload_entry(hass, config_entry): return True -class HPPrinterSensor(HPPrinterEntity): +class HPPrinterSensor(SensorEntity, HPPrinterEntity): """Representation a binary sensor that is updated by HP Printer.""" @property @@ -45,7 +48,7 @@ def native_value(self): return self.entity.state @property - def device_class(self) -> SensorDeviceClass: + def device_class(self) -> SensorDeviceClass | str | None: """Return the class of this sensor.""" return self.entity.sensor_device_class