List entity_ids in config and only react to them (#2144)

* List entity_ids in config and only react to them

This allows us to define a list of entity_ids in the config to make the
template sensor, binary sensor and switch only react to state changes of
these entities instead of listening to all state changes.

* Forgot to import the track_state_change function

* Changed test for added entity_ids to config

* Use default MATCH_ALL and remove event_listener
This commit is contained in:
Bart274 authored and Paulus Schoutsen committed 2016-05-29 14:34:21 -07:00
1 parent 19522b1f39
commit 65fbba0e79
4 files changed
+38 -21

No files matched your search

@@ -29,7 +29,7 @@ class TestBinarySensorTemplate(unittest.TestCase):
result = template.setup_platform(hass, config, add_devices)
self.assertTrue(result)
mock_template.assert_called_once_with(hass, 'test', 'virtual thingy',
'motion', '{{ foo }}')
'motion', '{{ foo }}', None)
add_devices.assert_called_once_with([mock_template.return_value])
def test_setup_no_sensors(self):
@@ -77,7 +77,7 @@ class TestBinarySensorTemplate(unittest.TestCase):
""""Test the attributes."""
hass = mock.MagicMock()
vs = template.BinarySensorTemplate(hass, 'parent', 'Parent',
'motion', '{{ 1 > 1 }}')
'motion', '{{ 1 > 1 }}', None)
self.assertFalse(vs.should_poll)
self.assertEqual('motion', vs.sensor_class)
self.assertEqual('Parent', vs.name)
@@ -93,7 +93,7 @@ class TestBinarySensorTemplate(unittest.TestCase):
""""Test the event."""
hass = get_test_home_assistant()
vs = template.BinarySensorTemplate(hass, 'parent', 'Parent',
'motion', '{{ 1 > 1 }}')
'motion', '{{ 1 > 1 }}', None)
vs.update_ha_state()
hass.pool.block_till_done()
@@ -110,7 +110,7 @@ class TestBinarySensorTemplate(unittest.TestCase):
""""Test the template update error."""
hass = mock.MagicMock()
vs = template.BinarySensorTemplate(hass, 'parent', 'Parent',
'motion', '{{ 1 > 1 }}')
'motion', '{{ 1 > 1 }}', None)
mock_render.side_effect = TemplateError('foo')
vs.update()
mock_render.side_effect = TemplateError(