Automation: Keep checking every 1 min if NO presence, turn OFF light

Hello,

I purchased this presence sensor from AliExpress: ZigBee Human Presence Detector Millimeter Wave Radar

I have connected it to Home Assistant with Zigbee2MQTT and it works fine. However I need 1 automation that I cant figure out by myself.

I want HA to keep checking every 1 minute if a light is forgotten turned on. If This sensor shows as “AWAY” then turn of the light. Here is my automation, why is not working?

alias: "Home: check if there is no presence"
description: ""
trigger:
  - platform: time_pattern
    minutes: "1"
condition:
  - condition: state
    for:
      hours: 0
      minutes: 0
      seconds: 0
    entity_id: binary_sensor.diningroom_presence_sensor
    state: "off"
action:
  - service: light.turn_off
    data: {}
    target:
      entity_id: light.diningroom_stripe
mode: single

Try

trigger:
  - platform: time_pattern
    minutes: "/1"

Yes, it did work with that / but why? Can you explain what does the this “/” does? I made the automation with the UI and there is no way I would have known what you just told me. Please explain with a brief sentences. Thank you.

As explained in the Time Pattern Trigger docs:

minutes: "1" only fires on the minute of each hour who’s value is equal to 1… “12:01”, “01:01”, “18:01”.

minutes: "/1" fires on every minute who’s value is divisible by 1. All minute values are divisible by 1, so it fires every minute.

However continuous polling is an inefficient way to accomplish this automation. Is there a reason that using a State trigger based on the motion sensor will not work in your situation?

Thank you @Didgeridrew
I am trying to wrap my head around, I understand the “/” now, and without it, but cant understand the “*” in the documentation.

I understand why you are asking me this question about pulling every 1 min. The reason is in my apartment Livingroom and Diningroom are like 1 room, with a sofa that is dividing them. I initially made automation for state “home” to “away” (on/off) and it works fine. However, the switch is between both rooms and sometime can be triggered without the presence sensor detecting motion. (rarely). So for that occasion, I want to turn off the lights even when there is no detection of movement or presence. I bit hard to explain but this “/” made the situation possible.

Is it bad for my Home assistant? Does it pull a lot of resources or does it make prone to errors or any other negatives? Please share, I would love to know your opinion. Thank you.

The * are required when using the UI Automation editor because you can’t leave fields blank. For example, you can get the same results as my previous answer with:

The other place it is necessary is when want to trigger an automation repeatedly, but limit it to a specific hour, minute, or hour and minute. As far as I know, this is a pretty rare use case. For example, you could have an automation trigger once a second between 12:05:00 - 12:06:00 by using:

trigger:
    - platform: time_pattern
      hours: "12"
      minutes: "5"
      seconds: "*"

Probably not.

It uses more resources than other methods. But, if it solves a problem that you can’t solve another way with the sensors and equipment you have, then it’s fine.

We warn people about it because many users start out using relatively low powered systems and the Time Pattern trigger can be a seductively simple crutch if you don’t understand the use of State and Event based triggers. The combination of low powered hardware and Time Pattern overuse could lead to poor overall performance of Home Assistant.

Thank you for your explanation. I am feeling I get the information you provided better than the official article about it. I wish there were more practical examples to illustrate the purpose than the simple explanation the website provide. I am “see/do” guy and when given exact example is more easy to understand and apply to my own needs. Thank again

I am using old PC intel core 2 duo with 4GB of RAM. It shows I use 2% of CPU and 40% of RAM.