1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-08 17:49:37 +01:00

Use shorthand attribute in danfoss_air switch (#163486)

This commit is contained in:
epenet
2026-02-19 14:29:39 +01:00
committed by GitHub
parent 5794189f8d
commit 6ebf19c4ba
+3 -14
View File
@@ -59,21 +59,10 @@ class DanfossAir(SwitchEntity):
def __init__(self, data, name, state_command, on_command, off_command):
"""Initialize the switch."""
self._data = data
self._name = name
self._attr_name = name
self._state_command = state_command
self._on_command = on_command
self._off_command = off_command
self._state = None
@property
def name(self):
"""Return the name of the switch."""
return self._name
@property
def is_on(self):
"""Return true if switch is on."""
return self._state
def turn_on(self, **kwargs: Any) -> None:
"""Turn the switch on."""
@@ -89,6 +78,6 @@ class DanfossAir(SwitchEntity):
"""Update the switch's state."""
self._data.update()
self._state = self._data.get_value(self._state_command)
if self._state is None:
self._attr_is_on = self._data.get_value(self._state_command)
if self._attr_is_on is None:
_LOGGER.debug("Could not get data for %s", self._state_command)