mirror of
https://github.com/home-assistant/core.git
synced 2026-02-28 05:46:00 +00:00
Use shorthand attribute in tellstick toggle entities (#163443)
This commit is contained in:
@@ -30,7 +30,6 @@ class TellstickDevice(Entity):
|
||||
def __init__(self, tellcore_device, signal_repetitions):
|
||||
"""Init the Tellstick device."""
|
||||
self._signal_repetitions = signal_repetitions
|
||||
self._state = None
|
||||
self._requested_state = None
|
||||
self._requested_data = None
|
||||
self._repeats_left = 0
|
||||
@@ -48,11 +47,6 @@ class TellstickDevice(Entity):
|
||||
)
|
||||
)
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if the device is on."""
|
||||
return self._state
|
||||
|
||||
def _parse_ha_data(self, kwargs):
|
||||
"""Turn the value from HA into something useful."""
|
||||
raise NotImplementedError
|
||||
|
||||
@@ -74,11 +74,11 @@ class TellstickLight(TellstickDevice, LightEntity):
|
||||
|
||||
# _brightness is not defined when called from super
|
||||
try:
|
||||
self._state = self._brightness > 0
|
||||
self._attr_is_on = self._brightness > 0
|
||||
except AttributeError:
|
||||
self._state = True
|
||||
self._attr_is_on = True
|
||||
else:
|
||||
self._state = False
|
||||
self._attr_is_on = False
|
||||
|
||||
def _send_device_command(self, requested_state, requested_data):
|
||||
"""Let tellcore update the actual device to the requested state."""
|
||||
|
||||
@@ -53,7 +53,7 @@ class TellstickSwitch(TellstickDevice, SwitchEntity):
|
||||
|
||||
def _update_model(self, new_state, data):
|
||||
"""Update the device entity state to match the arguments."""
|
||||
self._state = new_state
|
||||
self._attr_is_on = new_state
|
||||
|
||||
def _send_device_command(self, requested_state, requested_data):
|
||||
"""Let tellcore update the actual device to the requested state."""
|
||||
|
||||
Reference in New Issue
Block a user