Persistent version of "last-changed" for the UI?

Made a simple version using a trigger based template sensor which stores the last change of all entities you list in the trigger.

template:
  - trigger:
      - platform: state
        entity_id:
          - input_boolean.test
        not_to:
          - unavailable
          - unknown
        not_from:
          - unavailable
          - unknown
    sensor:
      unique_id: dbf841e2-ae6f-4fc1-9534-a1046204945f
      name: Nominal Change History
      state: "OK"
      attributes:
        changes: >
          {% set current = this.attributes.get('changes', {}) %}
          {% set new = {trigger.entity_id: trigger.to_state.last_changed.isoformat()} %}
          {{ dict(current, **new) }}

To get it out as datetime, you need:

{{ state_attr('sensor.nominal_change_history', 'changes')['input_boolean.test'] | as_datetime }}
29 Likes