Suspend Motion Sensor

I have a number of Hue lights in my kitchen group that have a number of motion sensor automations to trigger them on and off.

However, on occasion, I want to be able to override those automations using a Hue Remote.

Scenario, when Hue Remote ON button is pressed it turns on a light script and stops/suspends any motion automations in that area until the Hue Remote OFF button is pressed, at which point the motion sensor can resume.

I have no idea how to code this, if it’s possible, so any help appreciated.

Current example On and Off automations for the kitchen:

On:

- alias: Kitchen Lights On Day Low Light
  id: kitchen_lights_on_day_low_light
  trigger:
  - platform: state
    entity_id: binary_sensor.kitchen_sensor_motion
    to: 'on'
  condition:
    condition: and
    conditions:
    - condition: template
      value_template: '{{ states("sensor.kitchen_sensor_light_level") | float(0) <
        26 }}'
    - condition: time
      after: '06:00:00'
      before: '23:00:00'
  action:
  - variables:
      light_level: '{{ states("sensor.kitchen_sensor_light_level") }}'
  - service: script.kitchen_bright
  mode: single

Off:

- alias: Kitchen Lights Off Day
  id: kitchen_lights_off_day
  mode: single
  trigger:
  - platform: state
    entity_id: binary_sensor.kitchen_sensor_motion
    to: 'off'
    for:
      minutes: 1
  condition:
  - condition: time
    after: '06:00:00'
    before: '23:00:00'
  action:
  - service: script.kitchen_off

A general approach for this is to use an Input boolean helper as a condition in your motion automation(s). You will also need to create an automation that is triggered by the Hue remote, so that the boolean is switched appropriately. It can be useful to have additional automations (or clauses in existing automations) to reset motion detection nightly, when the house goes from unoccupied to occupied, and/or after prolonged periods of no motion.

- alias: Kitchen Lights On Day Low Light
  id: kitchen_lights_on_day_low_light
  trigger:
    - platform: state
      entity_id: binary_sensor.kitchen_sensor_motion
      to: 'on'
  condition:
    - condition: template
      value_template: '{{ states("sensor.kitchen_sensor_light_level") | float(0) <
        26 }}'
    - condition: time
      after: '06:00:00'
      before: '23:00:00'
    - condition: state
      entity_id: input_boolean.kitchen_motion_enabled
      state: 'on'
  action:
    - variables:
        light_level: '{{ states("sensor.kitchen_sensor_light_level") }}'
    - service: script.kitchen_bright
  mode: single

- alias: Kitchen Lights Off Day
  id: kitchen_lights_off_day
  mode: single
  trigger:
    - platform: state
      entity_id: binary_sensor.kitchen_sensor_motion
      to: 'off'
      for:
        minutes: 1
  condition:
    - condition: state
      entity_id: input_boolean.kitchen_motion_enabled
      state: 'on'
    - condition: time
      after: '06:00:00'
      before: '23:00:00'
  action:
    - service: script.kitchen_off
1 Like

That’s great thank you. I haven’t tried it yet because I’m currently in the middle of changing my router and HA device from Raspberry Pi to NUC. But once that’s all sorted I’ll try and implement your code and see how it goes.

Thanks again.

You can simply switch the motion sensor on or off as part of your automation.

There should be an entity (in your case) called something like:

“switch.hue_motion_sensor_kitchen_motion” or “switch.hue_motion_sensor_1_motion_4”…

You can set that switch to on/off in your automation as part of the actions and thereby enable/disable the motion sensing.

4 Likes

Nice and simple. Thanks for this!

1 Like