Homeassistant Start/Stop States Entity?

Hello,

what is the name of the entity that stores this states


and
image

and if it is not entiti itself, how can i get these states in Node Red?

The task is it detect if HA was restarted from software command or rebooted because of electricity down.
I thought to check on start if the last state was stop - it means that it was soft restarted, if last state after start is also start (and not stop) - i assume it was hard reboot.

Thanks a lot!

Hi,

I don’t think entities exist for these but they can be found as events under Developer Tools …

image

1 Like

Thanks, o saw this, but so how can i get the history (last and previous states) of them on Node Red?

I don’t know about Node Red as I don’t use it, however in an automation you would create a trigger as below:

image

However, I am not sure this will achieve what you want as how can you tell if the start/stop was due to a power fail verses a manual operation.

I have an APC UPS which cost around £65 and this keeps my HA hardware powered up for about 40mins, it also sends me a notification that the power has failed because it is able to do so since it is still running.

image

1 Like

In all cases Node Red or not - i would like to get history of this states, and not just trigger. Because HA startst faster as Node Red and it will be trigged before Node Red starts.

OK, then I think you will need to wait and see if someone with more knowledge of this responds.

Sorry I can’t be of more help.

1 Like

A SQL Sensor might do the trick

Thanks. Sure i can, but which query, where it is located in db, this - homeassistant start and stop?\

PS
It would not help! I made a Query

SELECT * FROM "states" GROUP BY domain

There is no Homassisatnt Domain :disappointed_relieved:

Made it. I mean i got datimetime of last start and last stop of HA with custom sensors!

sensor:

  - platform: sql
    queries:
      - name: Hassio Last Stop Date Time
        query: "SELECT * FROM 'events' WHERE event_type = 'homeassistant_stop' ORDER BY event_id DESC LIMIT 1;"
        column: 'time_fired'
          
  - platform: sql
    queries:
      - name: Hassio Last Start Date Time
        query: "SELECT * FROM 'events' WHERE event_type = 'homeassistant_started' ORDER BY event_id DESC LIMIT 1;"
        column: 'time_fired'
1 Like