#Need help creating an automation to control computer monitors with FP2 presence sensor

1 messages · Page 1 of 1 (latest)

proven pasture
#

I’m trying to create an automation with the following behaviors:

Sits down
ON immediately
Stands up < 1 min
OFF immediately
Sits > 1 min, then stands up
Wait 5 min
Returns within 5 min
Stays ON
Stays away for 5 full min
Turns OFF

The issue is that when other people walk by my desk I need my screens to turn off. I don’t want to have to wait 3-5 seconds for my screens to turn on so I would rather they turn on and off when someone walks by. I could add a 1 second buffer but would prefer not to. This is what ChatGPT suggested but its not working correctly.

#
description: based on presence.
mode: restart

trigger:
  - platform: state
    entity_id: binary_sensor.miguel_presence_occupancy
    to: "on"
  - platform: state
    entity_id: binary_sensor.miguel_presence_occupancy
    to: "off"

action:
  - choose:
      # Sitting down → Turn ON presence boolean
      - conditions:
          - condition: state
            entity_id: binary_sensor.miguel_presence_occupancy
            state: "on"
        sequence:
          - service: input_boolean.turn_on
            target:
              entity_id: input_boolean.desk_presence_miguel

      # Stood up within 1 minute → Turn OFF immediately
      - conditions:
          - condition: state
            entity_id: binary_sensor.miguel_presence_occupancy
            state: "off"
          - condition: state
            entity_id: binary_sensor.miguel_presence_occupancy
            state: "on"
            for:
              minutes: 0
              seconds: 59  # Less than 1 minute
        sequence:
          - service: input_boolean.turn_off
            target:
              entity_id: input_boolean.desk_presence_miguel

      # Stood up after 1 minute → Wait 5 minutes, then turn OFF if still gone
      - conditions:
          - condition: state
            entity_id: binary_sensor.miguel_presence_occupancy
            state: "off"
            for: "00:00:01"  # Ensure it actually turned off before proceeding
        sequence:
          - wait_for_trigger:
              - platform: state
                entity_id: binary_sensor.miguel_presence_occupancy
                to: "on"
            timeout: "00:05:00"  # Wait 5 minutes to see if he returns
          - condition: state
            entity_id: binary_sensor.miguel_presence_occupancy
            state: "off"
            for: "00:05:00"  # Confirm he was gone the whole time
          - service: input_boolean.turn_off
            target:
              entity_id: input_boolean.desk_presence_miguel ```
maiden prairieBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

tranquil scarab
tranquil scarab
#

I added friendly names to a lot of the stages sop it should be fairly easy to follow what its doing even in the visual editor.
you should read over it and learn how it works (or is supposed to) and the building blocks of automation.
"just ask AI" is not a substitution for learning how things work.

proven pasture
#

Awesome thank you!

#

Quick question

#

Does it only check occupancy once at the end of the 5 min timer?

#

Or does it reset the 5 minutes timer every time occupancy is detected?

#

Because the fp2 is not very accurate. Sometimes if i leave and come back it wont pick me up so i prefer it to reset the timer to avoid accidentally shutting off if it doesn’t detect me at that end of the timer only.

tranquil scarab
#

when occupency clears it starts a wait which ends either after 5 minutes or when occupency is detected again
then after the wait finished it then checks to see if occupency is clear, if it is then it turns off the switch

#

so yes it will in essence reset the timer every time time occupency is detected

#

because it will end and start a new instance of the automation when it clears again

proven pasture
#

Thank you so much Michael. I can understand YAML but am clueless to writing it.

tranquil scarab
#

try using the visual editor. thats how i made it.