Envoy Automation based on inverter state

Right now I have a defective inverter on one of my solar panels, and I did not realize it for months. I was hoping avoid this happening again by setting up an automation to check how long it has been since my inverters last reported. There is an entity for each inverter that seems to hold this timestamp in a state. If it has been more than 48 hours I want it to send me a notification.

Unfortunately I am new to automations, and can not seem to find a way to compare the state value to the current timestamp + 48 hours.

Here is some of the raw info from an example entity that I was thinking I should base the automation on

"state": {
              "entity_id": "sensor.inverter_sample1234_last_reported",
              "state": "2024-07-07T17:33:19+00:00",
              "attributes": {
                "device_class": "timestamp",
                "icon": "mdi:flash",
                "friendly_name": "Inverter sample1234 Last reported"
              },
              "last_changed": "2024-07-07T17:35:05.607841+00:00",
              "last_reported": "2024-07-07T17:35:05.607841+00:00",
              "last_updated": "2024-07-07T17:35:05.607841+00:00"

I have been reading through the automation docs and tried a bunch of ways, but sadly they all fail to work. Anyone know if a good way to do this? Thanks!!

If its state is a timestamp, you can make a straightforward state trigger:

trigger:
  - platform: state
    entity_id: sensor.inverter_sample1234_last_reported
    for:
      hours: 48

Not sure how this will deal with HA restarts…

Thanks for the reply, unfortunately this is always fires the notification even when the inverter was updated within the last few hours.

I also tried putting this as an if condition for the notification, but then it never fires even with a known down inverter.

So far the only way I have gotten this to work is to check the device rather than the entity. By having the automation always run at noon when the panels should be generating power, and check the device output, and notify if it’s under 1. Seems kinda hacky, but I suppose functional.

Totally open to better ways to do this monitoring though.

With a different state to before? Are you sure?

Another alternative with two simple automations, where you need to create a date+time helper called input_datetime.inverter_alert:

alias: "Record time of last inverter update plus 48h"
trigger:
  - platform: state
    entity_id: sensor.inverter_sample1234_last_reported
action:
  - service: input_datetime.set_datetime
    target:
      entity_id: input_datetime.inverter_alert
    data:
      timestamp: "{{ now()|as_timestamp + (48 * 3600) }}"

alias: "Notify when inverter appears down"
trigger:
  - platform: time
    at: input_datetime.inverter_alert
action:
[YOUR NOTIFICATION CODE]