Automation that continually checks a state and not just one time

I am trying to create an automation using the Everything Presence One mmWave sensor that will turn the lights green if no presence is detected, and will turn the lights red if presence is detected. It’s meant to be a game to see how long you can hold still, so the automation needs to continually check the state such that the lights can go back and forth between green and red if presence is not detected or detected. I’m struggling to figure out how to have it continually run like this vs. a one-time check. I believe a Timer is required, but I cannot figure it out.

You don’t need to poll the state. Use two state triggers. One for movement, one for no movement. Then use a choose action to change the light states.

That was it, thank you!

1 Like

Care to share? I’d appreciate it :slight_smile:

Thank you!

alias: Motion Game
description: Turn the living room lamp green if still or red if moving
trigger:
  - platform: state
    entity_id:
      - binary_sensor.kitchen_ep1_sensor_mmwave
    to: "on"
  - platform: state
    entity_id:
      - binary_sensor.kitchen_ep1_sensor_mmwave
    to: "off"
condition:
  - condition: state
    entity_id: input_boolean.motion_game
    state: "on"
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: binary_sensor.kitchen_ep1_sensor_mmwave
            state: "on"
        sequence:
          - service: light.turn_on
            data:
              color_name: red
            target:
              entity_id: light.living_room_lamp
      - conditions:
          - condition: state
            entity_id: binary_sensor.kitchen_ep1_sensor_mmwave
            state: "off"
        sequence:
          - service: light.turn_on
            data:
              color_name: green
            target:
              entity_id: light.living_room_lamp
mode: single

1 Like