Allow update entities on add_entities callback (#4114)

* Allow udpate entities on add_entities callback

* fix wrong position

* update force_update to update_before_add

* add unittest for update_befor_add

* fix unittest

* change mocking
This commit is contained in:
Pascal Vizeli authored and Paulus Schoutsen committed 2016-10-29 15:33:11 -07:00
1 parent 5d43d3eb1c
commit 9c0455e3dc
5 files changed
+50 -31

No files matched your search

+1 -7
View File
@@ -70,7 +70,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
_LOGGER.error("No switches added")
return False
hass.loop.create_task(async_add_devices(switches))
hass.loop.create_task(async_add_devices(switches, True))
return True
@@ -90,8 +90,6 @@ class SwitchTemplate(SwitchDevice):
self._off_script = Script(hass, off_action)
self._state = False
self._async_render()
@callback
def template_switch_state_listener(entity, old_state, new_state):
"""Called when the target device changes state."""
@@ -131,10 +129,6 @@ class SwitchTemplate(SwitchDevice):
@asyncio.coroutine
def async_update(self):
"""Update the state from the template."""
self._async_render()
def _async_render(self):
"""Render the state from the template."""
try:
state = self._template.async_render().lower()