mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Code cleanup fibaro switch and binary sensor (#73386)
This commit is contained in:
parent
670bf0641a
commit
483406dea5
@ -1,6 +1,8 @@
|
||||
"""Support for Fibaro binary sensors."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
ENTITY_ID_FORMAT,
|
||||
BinarySensorDeviceClass,
|
||||
@ -49,7 +51,7 @@ async def async_setup_entry(
|
||||
class FibaroBinarySensor(FibaroDevice, BinarySensorEntity):
|
||||
"""Representation of a Fibaro Binary Sensor."""
|
||||
|
||||
def __init__(self, fibaro_device):
|
||||
def __init__(self, fibaro_device: Any) -> None:
|
||||
"""Initialize the binary_sensor."""
|
||||
super().__init__(fibaro_device)
|
||||
self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
|
||||
@ -62,6 +64,6 @@ class FibaroBinarySensor(FibaroDevice, BinarySensorEntity):
|
||||
self._attr_device_class = SENSOR_TYPES[stype][2]
|
||||
self._attr_icon = SENSOR_TYPES[stype][1]
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Get the latest data and update the state."""
|
||||
self._attr_is_on = self.current_binary_state
|
||||
|
@ -1,6 +1,8 @@
|
||||
"""Support for Fibaro switches."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.switch import ENTITY_ID_FORMAT, SwitchEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
@ -31,27 +33,21 @@ async def async_setup_entry(
|
||||
class FibaroSwitch(FibaroDevice, SwitchEntity):
|
||||
"""Representation of a Fibaro Switch."""
|
||||
|
||||
def __init__(self, fibaro_device):
|
||||
def __init__(self, fibaro_device: Any) -> None:
|
||||
"""Initialize the Fibaro device."""
|
||||
self._state = False
|
||||
super().__init__(fibaro_device)
|
||||
self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn device on."""
|
||||
self.call_turn_on()
|
||||
self._state = True
|
||||
self._attr_is_on = True
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn device off."""
|
||||
self.call_turn_off()
|
||||
self._state = False
|
||||
self._attr_is_on = False
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if device is on."""
|
||||
return self._state
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update device state."""
|
||||
self._state = self.current_binary_state
|
||||
self._attr_is_on = self.current_binary_state
|
||||
|
Loading…
x
Reference in New Issue
Block a user