Skip to content

Commit

Permalink
Upgraded code to support breaking changes of HA v2012.12.0 - Addition…
Browse files Browse the repository at this point in the history
…al fixes
  • Loading branch information
elad-bar committed Dec 11, 2021
1 parent d150520 commit 9e413fc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion custom_components/hpprinter/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions custom_components/hpprinter/models/entity_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
7 changes: 5 additions & 2 deletions custom_components/hpprinter/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 9e413fc

Please sign in to comment.