Time since hass start?

I’ve seen a few suggestions but none of them has worked for me, I want to know time, preferably sec since hass start/restart. Not since the Pi booted but time since hass started.

Why do I need this? I have some automations which triggers at restart which I don’t like.
So if I could say don’t trigger until 30sec after start up everything would be fine.

You can trigger an automation when hass starts https://github.com/Danielhiversen/home-assistant_config/blob/master/automation/general.yaml#L1
Then check when it last triggered

Good ide, but how do I know when it triggered?

I’ll answer my own question so that if anyone else needs this info it’s here.

automation

## HA Started
- alias: "HA Started"
  trigger:
      platform: event
      event_type: homeassistant_start
  action:
    - service: notify.iOSapp
      data:
        message: 'Server just started.'
        title: 'Home Assistant'

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 %}'
3 Likes

For the completeness of the topic:
The code above has been depreciated. Below is the (new) working code.

- id: homeassistant_last_boot
  alias: Last boot Home Assistant
  trigger:
      platform: homeassistant
      event: start
  action:
  - service: notify.smtp
    data:
      message: 'Server just started.'
      title: 'Home Assistant reboot'