Exemple #1
0
    def on_light_switch_press(self, entity, attribute, old, new, kwargs):
        if new != "on":
            return

        common.update_last_action()

        sleep_light = "light.sleep_light"
        if self.get_state(sleep_light) == "on":
            self.turn_off(sleep_light)
        else:
            self.turn_on(sleep_light)
Exemple #2
0
  def on_light_switch_press(self, entity, attribute, old, new, kwargs):
    if new != "on":
      return

    common.update_last_action()
    self.cancel_auto_lights_off_timer()

    if self.get_state(self.lights[0]) == "on":
      self.turn_lights_off()
    else:
      self.turn_lights_on()
Exemple #3
0
  def on_light_switch_press(self, entity, attribute, old, new, kwargs):
    common.update_last_action()

    if new == "on":
      if self.get_state(self.main_light) == "off":
        self.turn_on(self.main_light)
      else:
        self.turn_off(self.main_light)
    elif new == "off":
      if self.get_state(self.corner_light) == "off":
        self.turn_on(self.corner_light)
      else:
        self.turn_off(self.corner_light)
Exemple #4
0
  def on_main_door_contact(self, entity, attribute, old, new, kwargs):
    if self.sun_up():
      return

    if new == "on":
      since_last_action=datetime.now() - common.last_action
      self.log(f"Someone opened the door. Last action happend {int(since_last_action.total_seconds())}s ago.")
      if since_last_action > timedelta(seconds = 300) \
      and self.get_state(self.lights[0]) == "off":
        self.turn_lights_on()
        self.cancel_auto_lights_off_timer()
        self.auto_lights_off_handle = self.run_in(self.turn_lights_off, 300)

    common.update_last_action()