Added signal repetitions to tellstick light
parent
05978ad88d
commit
b6d7cacc61
|
@ -10,6 +10,7 @@ from homeassistant.components.light import Light, ATTR_BRIGHTNESS
|
|||
from homeassistant.const import (EVENT_HOMEASSISTANT_STOP,
|
||||
ATTR_FRIENDLY_NAME)
|
||||
REQUIREMENTS = ['tellcore-py==1.1.2']
|
||||
SIGNAL_REPETITIONS = 1
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
|
@ -21,13 +22,14 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||
import tellcore.constants as tellcore_constants
|
||||
|
||||
core = telldus.TelldusCore(callback_dispatcher=DirectCallbackDispatcher())
|
||||
signal_repetitions = config.get('signal_repetitions', SIGNAL_REPETITIONS)
|
||||
|
||||
switches_and_lights = core.devices()
|
||||
lights = []
|
||||
|
||||
for switch in switches_and_lights:
|
||||
if switch.methods(tellcore_constants.TELLSTICK_DIM):
|
||||
lights.append(TellstickLight(switch))
|
||||
lights.append(TellstickLight(switch, signal_repetitions))
|
||||
|
||||
def _device_event_callback(id_, method, data, cid):
|
||||
""" Called from the TelldusCore library to update one device """
|
||||
|
@ -52,11 +54,12 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||
class TellstickLight(Light):
|
||||
""" Represents a Tellstick light. """
|
||||
|
||||
def __init__(self, tellstick_device):
|
||||
def __init__(self, tellstick_device, signal_repetitions):
|
||||
import tellcore.constants as tellcore_constants
|
||||
|
||||
self.tellstick_device = tellstick_device
|
||||
self.state_attr = {ATTR_FRIENDLY_NAME: tellstick_device.name}
|
||||
self.signal_repetitions = signal_repetitions
|
||||
self._brightness = 0
|
||||
|
||||
self.last_sent_command_mask = (tellcore_constants.TELLSTICK_TURNON |
|
||||
|
@ -82,7 +85,8 @@ class TellstickLight(Light):
|
|||
|
||||
def turn_off(self, **kwargs):
|
||||
""" Turns the switch off. """
|
||||
self.tellstick_device.turn_off()
|
||||
for _ in range(self.signal_repetitions):
|
||||
self.tellstick_device.turn_off()
|
||||
self._brightness = 0
|
||||
self.update_ha_state()
|
||||
|
||||
|
@ -95,7 +99,8 @@ class TellstickLight(Light):
|
|||
else:
|
||||
self._brightness = brightness
|
||||
|
||||
self.tellstick_device.dim(self._brightness)
|
||||
for _ in range(self.signal_repetitions):
|
||||
self.tellstick_device.dim(self._brightness)
|
||||
self.update_ha_state()
|
||||
|
||||
def update(self):
|
||||
|
|
Loading…
Reference in New Issue