diff --git a/homeassistant/components/raspyrfm/switch.py b/homeassistant/components/raspyrfm/switch.py index a609ddb27d3..19a1b724c48 100644 --- a/homeassistant/components/raspyrfm/switch.py +++ b/homeassistant/components/raspyrfm/switch.py @@ -2,6 +2,8 @@ from __future__ import annotations +from typing import Any + from raspyrfm_client import RaspyRFMClient from raspyrfm_client.device_implementations.controlunit.actions import Action from raspyrfm_client.device_implementations.controlunit.controlunit_constants import ( @@ -100,41 +102,27 @@ def setup_platform( class RaspyRFMSwitch(SwitchEntity): """Representation of a RaspyRFM switch.""" + _attr_assumed_state = True _attr_should_poll = False def __init__(self, raspyrfm_client, name: str, gateway, controlunit) -> None: """Initialize the switch.""" self._raspyrfm_client = raspyrfm_client - self._name = name + self._attr_name = name self._gateway = gateway self._controlunit = controlunit - self._state = None + self._attr_is_on = None - @property - def name(self): - """Return the name of the device if any.""" - return self._name - - @property - def assumed_state(self) -> bool: - """Return True when the current state cannot be queried.""" - return True - - @property - def is_on(self): - """Return true if switch is on.""" - return self._state - - def turn_on(self, **kwargs): + def turn_on(self, **kwargs: Any) -> None: """Turn the switch on.""" self._raspyrfm_client.send(self._gateway, self._controlunit, Action.ON) - self._state = True + self._attr_is_on = True self.schedule_update_ha_state() - def turn_off(self, **kwargs): + def turn_off(self, **kwargs: Any) -> None: """Turn the switch off.""" if Action.OFF in self._controlunit.get_supported_actions(): @@ -142,5 +130,5 @@ class RaspyRFMSwitch(SwitchEntity): else: self._raspyrfm_client.send(self._gateway, self._controlunit, Action.ON) - self._state = False + self._attr_is_on = False self.schedule_update_ha_state()