Try to make the connection to the tellcore library more stable

pull/433/head
Stefan Jonasson 2015-09-23 08:26:40 +02:00
parent 6437f6f6b4
commit a0c1202ad6
2 changed files with 19 additions and 3 deletions

View File

@ -41,9 +41,17 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Called from the TelldusCore library to update one device """
for light_device in lights:
if light_device.tellstick_device.id == id_:
# Execute the update in another thread
threading.Thread(target=light_device.update_ha_state, daemon=False, args=(True,)).start()
light_device.update_ha_state(True)
core.register_device_event(_device_event_callback)
callback_id = core.register_device_event(_device_event_callback)
def unload_telldus_lib():
if callback_id is not None:
core.unregister_callback(callback_id)
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, unload_telldus_lib)
add_devices_callback(lights)

View File

@ -52,9 +52,17 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Called from the TelldusCore library to update one device """
for switch_device in switches:
if switch_device.tellstick_device.id == id_:
switch_device.update_ha_state(True)
# Execute the update in another thread
threading.Thread(target=switch_device.update_ha_state, daemon=False).start()
break
core.register_device_event(_device_event_callback)
callback_id = core.register_device_event(_device_event_callback)
def unload_telldus_lib():
if callback_id is not None:
core.unregister_callback(callback_id)
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, unload_telldus_lib)
add_devices_callback(switches)