def __init__(self, event_type, data=None, origin=EventOrigin.local, time_fired=None): self.event_type = event_type self.data = data or {} self.origin = origin self.time_fired = util.strip_microseconds( time_fired or dt.datetime.now())
def get_since(self, point_in_time): """ Returns all states that have been changed since point_in_time. """ point_in_time = util.strip_microseconds(point_in_time) with self._lock: return [state for state in self._states.values() if state.last_updated >= point_in_time]
def get_since(self, point_in_time): """ Returns all states that have been changed since point_in_time. """ point_in_time = util.strip_microseconds(point_in_time) with self._lock: return [state for state in self._states.values() if state.last_updated >= point_in_time]
def get_since(self, point_in_time): """ Returns all states that have been changed since point_in_time. Note: States keep track of last_changed -without- microseconds. Therefore your point_in_time will also be stripped of microseconds. """ point_in_time = util.strip_microseconds(point_in_time) with self._lock: return [state for state in self._states.values() if state.last_changed >= point_in_time]
def __init__(self, entity_id, state, attributes=None, last_changed=None): if not ENTITY_ID_PATTERN.match(entity_id): raise InvalidEntityFormatError(( "Invalid entity id encountered: {}. " "Format should be <domain>.<entity>").format(entity_id)) self.entity_id = entity_id self.state = state self.attributes = attributes or {} # Strip microsecond from last_changed else we cannot guarantee # state == State.from_dict(state.as_dict()) # This behavior occurs because to_dict uses datetime_to_str # which does not preserve microseconds self.last_changed = util.strip_microseconds( last_changed or dt.datetime.now())
def __init__(self, entity_id, state, attributes=None, last_changed=None): if not ENTITY_ID_PATTERN.match(entity_id): raise InvalidEntityFormatError( ("Invalid entity id encountered: {}. " "Format should be <domain>.<object_id>").format(entity_id)) self.entity_id = entity_id self.state = state self.attributes = attributes or {} self.last_updated = dt.datetime.now() # Strip microsecond from last_changed else we cannot guarantee # state == State.from_dict(state.as_dict()) # This behavior occurs because to_dict uses datetime_to_str # which does not preserve microseconds self.last_changed = util.strip_microseconds(last_changed or self.last_updated)