Vacation lights, ie replay from history

Hi,
So there has been many things written about replay from history sensor, however all of those are touching on using “ON” state, and nothing more. There is a lot of kung-fu with node red etc … But can somebody please explain how to for example use history sensor with basic automation script firing every minute (or other interval), to set light to given state, brightness and colour ?

A ready script would be nice, but I think we all would like to learn more about history_stats and how to use it for other things and documentation is not very helpful here.

What is a “history sensor”?

You could use an SQL sensor to get the state of an entity x days ago (where x is less than your purge_keep_days, which is 10 days by default). You would need one of these sensors for every entity you want to control. Then the automation would look like this:

trigger:
  - platform: state
    entity_id: 
      - sensor.my_light_3_days_ago
      - sensor.my_switch_3_days_ago
      - etc...
    not_to:
      - unknown
      - unavailable
action:
  - service: "light.turn_{{ states('sensor.my_light_3_days_ago') }}"
    target:
      entity_id: light.my_light
  - service: "switch.turn_{{ states('sensor.my_switch_3_days_ago') }}"
    target:
      entity_id: switch.my_switch
  - service: etc...

This is the closest thing I know of using HA configuration to accomplish it. I used it as a basis for what I’m currently using:

or there’s an integration that I tried. I like the one I’m using better but it looks like it works OK too:

you can install it via HACS.

1 Like