Time since last platform update

Hi

I created a fairly simple dashboard that shows some info from my PC.
It’s using the OpenHardwareMonitor integration.

Here is my configuration for this Lovelace view.

views:

  - title: PC
    path: pc
    panel: true ### Alt placeres i èt kort (horizontal-stack), som optager hele bredden ###
    cards:
      - type: horizontal-stack ### Èn uendelig lang kolonne der fylder hele bredden af siden (når panel = true) ###
        cards:

          - type: custom:button-card ### SPACING før kolonne 1 ###
            tap_action:
              action: none
            styles:
              card:
              - width: 10px
            style: |
              ha-card {
                --ha-card-background: rgba(0, 0, 0, 0.0);
                border-style: none;
              }              

          - type: vertical-stack ### Kolonne 1 ###
            cards:

              - type: grid
                title: Temperatur
                columns: 3
                square: false
                cards:
                  - type: entity
                    entity: sensor.ryzen_amd_ryzen_5_5600x_temperatures_core_tctl_tdie
                    name: CPU
                  - type: entity
                    entity: sensor.ryzen_nvidia_geforce_rtx_3080_temperatures_gpu_core
                    name: GPU

              - type: grid
                columns: 3
                square: false
                cards:
                  - type: entity
                    entity: sensor.ryzen_team_tm8fp3128g_temperatures_temperature
                    name: 128 GB TEAMGROUP NVMe
                  - type: entity
                    entity: sensor.ryzen_samsung_mzvl22t0hblb_00b00_temperatures_temperature
                    name: 2 TB Samsung NVMe
                  - type: entity
                    entity: sensor.ryzen_samsung_ssd_870_qvo_4tb_temperatures_temperature
                    name: 4 TB Samsung SSD

              - type: grid
                title: Blæsere
                columns: 3
                square: false
                cards:
                  - type: entity
                    entity: sensor.ryzen_asrock_b550_phantom_gaming_4_nuvoton_nct6796d_r_fans_aio_push
                    name: AIO Push
                    icon: mdi:fan
                  - type: entity
                    entity: sensor.ryzen_asrock_b550_phantom_gaming_4_nuvoton_nct6796d_r_fans_aio_pull
                    name: AIO Pull
                    icon: mdi:fan

              - type: grid
                columns: 3
                square: false
                cards:
                  - type: entity
                    entity: sensor.ryzen_asrock_b550_phantom_gaming_4_nuvoton_nct6796d_r_fans_top
                    name: Top
                    icon: mdi:fan
                  - type: entity
                    entity: sensor.ryzen_asrock_b550_phantom_gaming_4_nuvoton_nct6796d_r_fans_bagside
                    name: Bagside
                    icon: mdi:fan
                  - type: entity
                    entity: sensor.ryzen_nvidia_geforce_rtx_3080_fans_gpu_fan_1
                    name: GPU
                    icon: mdi:fan

              - type: grid
                title: Strøm
                columns: 3
                square: false
                cards:
                  - type: entity
                    entity: sensor.ryzen_amd_ryzen_5_5600x_powers_package
                    name: CPU
                    icon: mdi:lightning-bolt
                  - type: entity
                    entity: sensor.ryzen_nvidia_geforce_rtx_3080_powers_gpu_package
                    name: GPU
                    icon: mdi:lightning-bolt

              - type: grid
                title: Hukommelse
                columns: 3
                square: false
                cards:
                  - type: entity
                    entity: sensor.ryzen_nvidia_geforce_rtx_3080_data_gpu_memory_used
                    name: GPU brugt
                    icon: mdi:memory
                  - type: entity
                    entity: sensor.ryzen_nvidia_geforce_rtx_3080_data_gpu_memory_total
                    name: GPU total
                    icon: mdi:memory

          - type: custom:button-card ### SPACING efter kolonne 1 ###
            tap_action:
              action: none
            styles:
              card:
              - width: 10px
            style: |
              ha-card {
                --ha-card-background: rgba(0, 0, 0, 0.0);
                border-style: none;
              }

I have found that the lowest scan interval for the OpenHardwareMonitor is 15 seconds, so all the sensors update simultaneously every 15 seconds, which is fine.

  - platform: openhardwaremonitor
    scan_interval: 15
    host: x.x.x.x

I was wondering if there is any way to somehow display the last time the platform performed an update?

Either in the form of date and time or some sort of timer that resets at every platform update and counts up from 0 seconds.

something like this?

sensor:
  - platform: template
    sensors:
      time_since_update:
        friendly_name: "Time Since Update"
        value_template: >
          {% if states.sensor.your_hardware_sensor_name.last_updated %}
            {% set time_diff = as_timestamp(now()) - as_timestamp(states.sensor.your_hardware_sensor_name.last_updated) %}
            {{ time_diff | timestamp_custom('%H:%M:%S', false) }}
          {% else %}
            N/A
          {% endif %}

Thank you for the reply.

Now that I have a better understanding of how Home Assistant works, I have created a new topic, asking more or less the same question, but in a simpler way.