1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Extract helpers.event from core + misc cleanup

This commit is contained in:
Paulus Schoutsen
2015-07-26 10:45:49 +02:00
parent 0c56fde5a9
commit e0468f8b8e
5 changed files with 477 additions and 361 deletions

View File

@@ -30,7 +30,16 @@ class TrackStates(object):
return self.states
def __exit__(self, exc_type, exc_value, traceback):
self.states.extend(self.hass.states.get_since(self.now))
self.states.extend(get_changed_since(self.hass.states.all(), self.now))
def get_changed_since(states, utc_point_in_time):
"""
Returns all states that have been changed since utc_point_in_time.
"""
point_in_time = dt_util.strip_microseconds(utc_point_in_time)
return [state for state in states if state.last_updated >= point_in_time]
def reproduce_state(hass, states, blocking=False):