Time triggers for multiple times a day (like cron?)

While away for the holiday my router freaked out and stopped updating my DDNS. I was still receiving the occasional notification email from HA, but was unable to connect directly without the IP. This has happened before, which has made me decide to setup a “System Update” email to be sent to me 4x per day when I’m traveling. The email will have External IP address and current states of a few sensors (temp, security lights, etc.) My thought being that if I lose contact via DNS, within a few hours I will have the IP address so I can VPN in and reboot.

Ideally I’d like the email sent at 00:00, 06:00, 12:00, and 18:00. Can somebody point me to how I do this? I tried:

trigger:
- platform: time
hours: ‘/6’
minutes: ‘00’
seconds: ‘00’
but HA did not seem to like it. It sent me 6 emails immediately and then nothing after.

Also, I often find that I build something new in HA to fill a need of mine just to find out later that there is a core component/feature that does the exact thing I just built. So I’ll ask, is there a better way for me to accomplish my goal?

I do not see why this do not work.
But here is my automation for changed ip: https://github.com/Danielhiversen/home-assistant_config/blob/2c9c028fd0a0ec41d9c39528d03b61187d4a2fda/automation/general.yaml#L517

1 Like

Thank you for sharing your automation.

So that I understand, you are using a rest sensor to get your external IP (as I am). Your automation triggers when the external IP address changes. How often does HA check the external IP address? Is there a default and can it be modified?

I’m also having trouble understanding the condition. Is it checking whether it has been 5 minutes since the attributes have been checked? Can you please help with the logic?

Hi Daniel,
I am getting error:
[after] is an invalid option for [automation]. Check: automation->trigger->0->after.

I am trying to use “After certain time” to turn off switch.

- id: 'Morning Coffee off'
  alias: 'Morning Coffee Off'
  trigger:
    - platform: time
      after: '09:41:00'
  condition:
      - condition: state
        entity_id: switch.fibaro_system_fgwpef_wall_plug_gen5_switch
        state: 'on'
  action:
    - service: homeassistant.turn_off
      entity_id: switch.fibaro_system_fgwpef_wall_plug_gen5_switch
    - service: notify.my_pushbullet
      data:
        title: "Coffee Maker has been turned off"
        message: "Coffee Maker has been turned off"

Any guidance your can provide?

~Bryan

Change after to at
A lot has changed in HA since December 2016 :slight_smile:

Thanks. Quick clarification – Does “at:” imply at that time or later?

Hi, can you explain the template of this condition?

   - condition: template
     value_template: '{% if states.automation.ha_started.attributes.last_triggered  %} {{(as_timestamp(now())-as_timestamp(states.automation.ha_started.attributes.last_triggered)) > 5*60 }}  {% else %}false{% endif %}'

Does it ADD a condition for starting ha?

Yes, it checks if it is more than 5 min since HA started.
Requires a separate ha_started automation:

Great! I have used it and works perfect. I was only curious about the 5*60 , why this format?

@Martinvdm I’d suggest that its because it’s cleaner.

5 lots of 60 seconds rather than 300