Simplify track_same_state (#9795)

This commit is contained in:
Paulus Schoutsen
2017-10-10 12:16:19 -07:00
committed by Pascal Vizeli
parent fc47e9443b
commit a97e7bb22d
5 changed files with 23 additions and 23 deletions

View File

@@ -135,7 +135,7 @@ class BinarySensorTemplate(BinarySensorDevice):
return False
@callback
def _async_render(self, *args):
def _async_render(self):
"""Get the state of template."""
try:
return self._template.async_render().lower() == 'true'
@@ -171,5 +171,5 @@ class BinarySensorTemplate(BinarySensorDevice):
period = self._delay_on if state else self._delay_off
async_track_same_state(
self.hass, state, period, set_state, entity_ids=self._entities,
async_check_func=self._async_render)
self.hass, period, set_state, entity_ids=self._entities,
async_check_same_func=lambda *args: self._async_render() == state)