How to disable a motion sensor so my lights will stay on in an automation

helper template… go to settings → devices & services → helpers.
hit the button in the bottom right (create helper)

choose template. (screenshot 1)
choose binary sensor (screenshot 2)

1 Like

This is the one for my master bedroom. I created a timer of 20 minutes and I use a physical button press for this one. I have another one for my kitchen that also uses an input_boolean as a switch from the HA dashboard/Alexa voice routine. Those are just additional triggers in the automation. But this one is only 3 triggers and the best part there is no “remembering” to toggle the input_boolean back. It runs itself easily.

The flow is basically:

  1. If the button is pressed (trigger id switch_on)
    1a: Turn the lights on full brightness (scene)
    1b: Start the timer
    1c: Turn off the motion lighting automation
    1d: Speak a message (generated from Google Gemini and sent to an Alexa Show)
  2. If the button is pressed again (trigger id switch_off)
    2a: Stop the timer
  3. If the timer ends (either cancelled or timed out) (trigger id timer_off)
    3a: Turn the motion/lighting automation back on.
    3b: If there is motion (ie, someone is still in the room and the timer expired), Set the lights to whatever mode the house is in (scene). Otherwise just turn the lights off.
    3c: Speak another message
    3d: Turn off the switch again (because my button stays on otherwise)
alias: "Lighting: Master Bedroom Lights Override"
description: ""
trigger:
  - platform: state
    entity_id:
      - timer.master_bedroom_switch_timer
    from: active
    to: idle
    id: timer_off
  - platform: state
    entity_id:
      - switch.master_bedroom_light_switch_bottom
    from: "off"
    to: "on"
    id: switch_on
  - platform: state
    entity_id:
      - switch.master_bedroom_light_switch_bottom
    from: "on"
    to: "off"
    id: switch_off
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - switch_on
        sequence:
          - service: scene.turn_on
            metadata: {}
            target:
              entity_id: scene.master_bedroom_full_brightness
          - alias: Start the timer
            service: timer.start
            metadata: {}
            data: {}
            target:
              entity_id:
                - timer.master_bedroom_switch_timer
          - alias: Turn off automations
            service: automation.turn_off
            metadata: {}
            data:
              stop_actions: true
            target:
              entity_id: automation.lighting_master_bedroom_lights_on
          - alias: Speak the thing...
            service: script.generate_message_to_speaker
            metadata: {}
            data:
              title: Master Bedroom Lights Override Active
              prompt: >-
                Create a short announcement about that the master bedroom lights
                are remaining on for 20 minutes. It should be in the style of
                Star Wars. The announcement should be about 20 to 30 words long.
              devices:
                - media_player.master_bedroom_show
      - conditions:
          - condition: trigger
            id:
              - switch_off
        sequence:
          - alias: Cancel the timer
            service: timer.cancel
            metadata: {}
            data: {}
            target:
              entity_id:
                - timer.master_bedroom_switch_timer
      - conditions:
          - condition: trigger
            id:
              - timer_off
        sequence:
          - alias: Turn on automations
            service: automation.turn_on
            data: {}
            target:
              entity_id: automation.lighting_master_bedroom_lights_on
          - alias: Tune off the lights unless there is motion
            if:
              - condition: state
                entity_id: binary_sensor.master_bedroom_motion_sensor_occupancy
                state: "on"
                for:
                  hours: 0
                  minutes: 0
                  seconds: 0
            then:
              - service: script.turn_on_lights_by_mode
                metadata: {}
                data:
                  area: master_bedroom
            else:
              - service: scene.turn_on
                metadata: {}
                target:
                  entity_id: scene.master_bedroom_off
          - alias: Speak the thing...
            service: script.generate_message_to_speaker
            metadata: {}
            data:
              title: Master Bedroom Lights Override Deactivated
              prompt: >-
                Create a short announcement about that the master bedroom lights
                have returned to their normal operations. It should be in the
                style of Star Wars. The announcement should be about 30 words
                long.
              devices:
                - media_player.master_bedroom_show
          - service: switch.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: switch.master_bedroom_light_switch_bottom
            alias: Turn off the switch
mode: restart
1 Like

awesome!I will look into this as well. thank you!

1 Like

I was able to get it working. Thank you very much for the help. Again, all answers are valid here.

1 Like