1 """Support for Tellstick."""
6 from tellcore.constants
import TELLSTICK_DIM, TELLSTICK_TURNOFF, TELLSTICK_TURNON
7 from tellcore.library
import TelldusError
12 from .const
import SIGNAL_TELLCORE_CALLBACK
14 _LOGGER = logging.getLogger(__name__)
18 TELLSTICK_LOCK = threading.RLock()
22 """Representation of a Tellstick device.
24 Contains the common logic for all Tellstick devices.
27 _attr_assumed_state =
True
28 _attr_should_poll =
False
30 def __init__(self, tellcore_device, signal_repetitions):
31 """Init the Tellstick device."""
44 """Register callbacks."""
53 """Return true if the device is on."""
57 """Turn the value from HA into something useful."""
58 raise NotImplementedError
61 """Turn the value received from tellcore into something useful."""
62 raise NotImplementedError
65 """Update the device entity state to match the arguments."""
66 raise NotImplementedError
69 """Let tellcore update the actual device to the requested state."""
70 raise NotImplementedError
73 """Send a tellstick command once and decrease the repeat count."""
82 except TelldusError
as err:
86 """Turn on or off the device."""
104 """Turn the switch on."""
108 """Turn the switch off."""
112 """Update the model, from a sent tellcore command and data."""
114 if tellcore_command
not in [TELLSTICK_TURNON, TELLSTICK_TURNOFF, TELLSTICK_DIM]:
115 _LOGGER.debug(
"Unhandled tellstick command: %d", tellcore_command)
119 tellcore_command != TELLSTICK_TURNOFF,
124 """Handle updates from the tellcore callback."""
137 """Read the current state of the device from the tellcore library."""
142 TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_DIM
146 except TelldusError
as err:
150 """Poll the current state of the device."""
def _update_from_tellcore(self)
def __init__(self, tellcore_device, signal_repetitions)
def _change_device_state(self, new_state, data)
def async_added_to_hass(self)
def _send_device_command(self, requested_state, requested_data)
def _update_model_from_command(self, tellcore_command, tellcore_data)
def _update_model(self, new_state, data)
def turn_on(self, **kwargs)
def update_from_callback(self, tellcore_id, tellcore_command, tellcore_data)
def _parse_ha_data(self, kwargs)
def _parse_tellcore_data(self, tellcore_data)
def _send_repeated_command(self)
def turn_off(self, **kwargs)
None async_on_remove(self, CALLBACK_TYPE func)
None schedule_update_ha_state(self, bool force_refresh=False)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)