def tick(self, now): scheduled = StateChange.get_current(now) if scheduled is None: scheduled = StateChangeRepeating.get_current(now) self.set_AC_target(scheduled.AC_target) self.set_fan(scheduled.fan) self.set_heater_target(scheduled.heater_target)
def add_schedule(): result = StateChange.from_dictionary(request.get_json(force=True)).save() return Response(json.dumps({"data": result}, default=json_util.default), mimetype='application/json')
def remove_schedule(): to_remove = StateChange.from_dictionary(request.get_json(force=True)) result = schedule.remove({"_id": to_remove.id}) return Response(json.dumps({"data": result}, default=json_util.default), mimetype='application/json')
def get_schedule(): result = StateChange.get_all_dic() return Response(json.dumps({"data": result}, default=json_util.default), mimetype='application/json')