mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Use attributes in rflink binary sensor (#77901)
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
This commit is contained in:
parent
bd84981ae0
commit
85beceb533
@ -1,11 +1,14 @@
|
|||||||
"""Support for Rflink binary sensors."""
|
"""Support for Rflink binary sensors."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
DEVICE_CLASSES_SCHEMA,
|
DEVICE_CLASSES_SCHEMA,
|
||||||
PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA,
|
||||||
|
BinarySensorDeviceClass,
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -73,12 +76,17 @@ class RflinkBinarySensor(RflinkDevice, BinarySensorEntity, RestoreEntity):
|
|||||||
"""Representation of an Rflink binary sensor."""
|
"""Representation of an Rflink binary sensor."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, device_id, device_class=None, force_update=False, off_delay=None, **kwargs
|
self,
|
||||||
):
|
device_id: str,
|
||||||
|
device_class: BinarySensorDeviceClass | None = None,
|
||||||
|
force_update: bool = False,
|
||||||
|
off_delay: int | None = None,
|
||||||
|
**kwargs: Any,
|
||||||
|
) -> None:
|
||||||
"""Handle sensor specific args and super init."""
|
"""Handle sensor specific args and super init."""
|
||||||
self._state = None
|
self._state = None
|
||||||
self._device_class = device_class
|
self._attr_device_class = device_class
|
||||||
self._force_update = force_update
|
self._attr_force_update = force_update
|
||||||
self._off_delay = off_delay
|
self._off_delay = off_delay
|
||||||
self._delay_listener = None
|
self._delay_listener = None
|
||||||
super().__init__(device_id, **kwargs)
|
super().__init__(device_id, **kwargs)
|
||||||
@ -119,13 +127,3 @@ class RflinkBinarySensor(RflinkDevice, BinarySensorEntity, RestoreEntity):
|
|||||||
def is_on(self):
|
def is_on(self):
|
||||||
"""Return true if the binary sensor is on."""
|
"""Return true if the binary sensor is on."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
@property
|
|
||||||
def device_class(self):
|
|
||||||
"""Return the class of this sensor."""
|
|
||||||
return self._device_class
|
|
||||||
|
|
||||||
@property
|
|
||||||
def force_update(self):
|
|
||||||
"""Force update."""
|
|
||||||
return self._force_update
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user