def handle_event(self, event): if event.is_device_status_change(): device = Device.from_json_string(event.payload) self._log(device) owner = self.device_to_person_map[device.name] old_status = owner.status device_to_update = owner.get_device_by_name(device.name) device_to_update.status = device.status if old_status != owner.status: owner.last_status_change = datetime.now() # if user goes away between 22 and 7, # do not record event if owner.is_away() and \ is_date_between_hours(owner.last_status_change, 22, 7): return msg = owner.name + ' is now ' + owner.status notify_android('presence status', msg) self._log(owner)
def _notify_android(self, distance): msg = 'distance from home: ' + str(distance) + ' meters' notify_android('location information', msg)