Start automation every 10 minutes

I would like to restart an automation every 10 minutes. This means that an action is triggered when the conditions are met. As an example. If the outside temperature is over 25 degrees and the inside temperature is also 25 degrees, then the roller shutter should close at 30%. If a condition is no longer met, the roller shutter should open again. That’s why I would like to restart the automation every 10 minutes without a trigger. The 10 minutes during the trigger. Is that possible. Haven’t found anything about this.

1 Like
automation:
  trigger:
    - platform: time_pattern
      # You can also match on interval. This will match every 10 minutes
      minutes: "/10"
2 Likes

Or, instead of needlessly triggering every 10 minutes, trigger another automation when these numeric states are met: inside temp < 25, outside temp < 25. Adding both as numeric triggers and conditions will cause the automation to only execute the action when both states are < 25. Then open your shutter 100% in the actions.

2 Likes

And it will happen as these triggers and conditions are correct, not “any minute now”, “wait for it”, “it will happen soon”, “just wait a little longer and you will see the shutters come down”, “it should happen very soon now”.
That’s not very impressive in my opinion. A smart home should react to events and states not on timed intervals.

2 Likes

The /10 minutes solved my problem. The automation works as intended. Thanks

I have a related question: How do I shift this 10 min interval?
I don’t want to trigger two automations at a time and therefore the second one should be shifted.
In Cron I would use something like 5-59/10

ChatGPT gave me this answer, but I haven’t tested it yet:

automation:
  - alias: "Automation 1"
    trigger:
      platform: time_pattern
      minutes: "/10"
    action:
      # Add the actions you want to run for Automation 1 here
  - alias: "Automation 2"
    trigger:
      platform: time_pattern
      minutes: "/10"
      seconds: "30"
    action:
      # Add the actions you want to run for Automation 2 here
    - delay: "00:05:00"
1 Like

I can understand the question, and off course it would be most nice if things would be automated on changing states. The thing is that is not always works with states as how you would like. For as far as I did notice is that HA only look at the trigger of a automation one time and if not complied on all conditions it won’t execute the rest of the automation.

Example:
Trigger : Battery >90
Condition : Boiler is off
Or : Boiler is on and Solar is >4000
Action : Turn spa heating on

This automation will only trigger when the battery go from 90 to 91% and not if battery go from 92 to 93% or backwards.

In my case it works better to check the automation every minute with a trigger on the time, and then check if all conditions are okey. Like: is battery >90 and boiler off, or …

If there are other methodes that would work better, I would like to know.

1 Like

The battery isn’t going to sneak above 90% without HA noticing. The only time that’ll happen is if you restart the system or potentially reload automations. To work with that situation:

trigger:
  - platform: numeric_state
    entity: sensor.battery_level
    above: 90
  - platform: homeassistant
    event: start
condition:
  - condition: numeric_state
    entity: sensor.battery_level
    above: 90

That will trigger when the battery crosses 90; and also if it snuck above 90 whilst the system was offline.

Here’s a battery charger manager automation I use:

- alias: Misc - kitchen display charge manager

  description: >-
    Maintain kitchen display battery SoC between 35 and 80%.

  id: 6cef7c4e-2074-4406-8bf1-4f563247e9f2

  trigger:
    - platform: numeric_state
      entity_id: sensor.kitchen_display_battery_level
      above: '80'
      for:
        minutes: 1
    - platform: numeric_state
      entity_id: sensor.kitchen_display_battery_level
      below: '35'
      for:
        minutes: 1
    - platform: homeassistant
      event: start
    - platform: event
      event_type: automation_reloaded

  action:
    - service: switch.turn_{{ iif(states('sensor.kitchen_display_battery_level')|int(0)>=80,'off','on') }} 
      entity_id: switch.sinilink_usb_switch

No inefficient checking every minute.

Only if the battery is already above the 90, the automation will not trigger, what can happen if at the moment the battery jumps to 91, and the second conditions are false.
Automation:
Trigger : Battery >90
Condition : Boiler is off
Or : Boiler is on and Solar is >4000
Action : Turn spa heating on

What will happen when when the battery jumps to 91% and the boiler is ON, and solar is <4000, the automation is stopped because of the second condition. But if a few seconds later the boiler turned off, or if for example the solar production comes above the 4000 then the automation would not be triggered again because of the battery that is already >90.

… or the triggers need to be : T1 = Battery >90 OR T2 = Boiler change state OR T3 = Solar production >4000 , … and then the conditions as before.

and then in the end, … I want that things are scheduled based on time, solar prediction etc.

For example, if its a sunny the pool heating can be on if the battery is below the 90, but not in the afternoon, depending on the time, charge state and expected solar production. and more of those things.

But anyway, its nice puzzling :wink:

Exactly: create separate triggers for all of the things, and matching conditions as needed. Here’s another one of mine, with five separate triggers and a more complex condition block:

- alias: Lights - hall lamp on

  description: >-
    Turns the hall light on if the house is occupied and it gets dark enough,
    or if the house is unoccupied and the sun goes below the horizon.

  id: fd2d110d-b8ef-42c5-8da5-30fc5a046c35

  trigger:
    - platform: state
      entity_id: sun.sun
      from: 'above_horizon'
      to: 'below_horizon'
    - platform: homeassistant
      event: start
    - platform: state
      entity_id: binary_sensor.occupied
    - platform: state
      entity_id: binary_sensor.wfh_solo
    - platform: state
      entity_id: binary_sensor.hall_light
      to: 'on'
      for:
        minutes: 2

  condition:
    - condition: state
      entity_id: light.hall_light_plug
      state: 'off'
    - or:
        - and:
            - condition: state
              entity_id: binary_sensor.occupied
              state: 'on'
            - condition: state
              entity_id: binary_sensor.wfh_solo
              state: 'off'
            - condition: state
              entity_id: binary_sensor.hall_light
              state: 'on'
        - and:
            - condition: state
              entity_id: binary_sensor.occupied
              state: 'off'
            - condition: state
              entity_id: sun.sun
              state: 'below_horizon'

  action:
    - service: light.turn_on
      entity_id: light.hall_light_plug