Create notification when a physical meter is stuck

Hi everyone,

Currently my gasmeter stuck. So it needs to be replaced.
I want to create a notification when this happens again.

I have written some code to check it every day and send me a notification in home assistant when the condition is positieve.

But I’m struggling with the condition.
I want to send myself a notification when my gasmeter has the same result for more than 7 days. A flatline.

How can i compare the data from a week ago with the current number? For example 100 m3.

alias: Gasmeter
description: ""
trigger:
  - platform: time_pattern
    hours: "17"
    minutes: "00"
condition:
  - type: is_gas
    condition: device
    device_id: xxx
    entity_id: xxxx
    domain: sensor



action:
  - service: persistent_notification.create
    data:
      message: Flatline of gas meter. Check it!
mode: single

Thanks for your help.

Just a reply if people are searching for this problem.
Solution is relativily easy. Guess i’m just a noob :slight_smile:

Just created 2 scripts… 1 to set the actual value to an entity on the 25e day of the month and the other one and x days later to check if the entity value is equal to the actual value. If true give a notification.

I still need to fine tune the timing. These are just test times and dates

1: Write the actual to a entity:

alias: Gasmeter write to entity
description: weg schrijven waarde naar old_gas1
trigger:
  - platform: time
    at: "16:38:00"
condition:
  - condition: template
    value_template: "{{ (now().strftime(\"%d\") | int) == 25 }}"
action:
  - service: persistent_notification.create
    data:
      message: >-
        De volgende waarde is weg geschreven om mee te rekenen "{{
        states('sensor.gas_meter_gas_consumption') }}"
  - service: input_number.set_value
    data:
      value: "{{ states('sensor.gas_meter_gas_consumption')  | float(0) }}"
    target:
      entity_id: input_number.old_gas1
mode: single

2: Compare the value:

alias: Gasmeter check value
description: ""
trigger:
  - platform: time
    at: "17:23:00"
condition:
  - alias: Datum x en check waarde gasmeter gelijk
    and:
      - condition: template
        value_template: "{{ (now().strftime(\"%d\") | int) == 25 }}"
      - condition: template
        value_template: >-
          {{ states('input_number.old_gas1') | float ==
          states('sensor.gas_meter_gas_consumption') | float }}
action:
  - service: persistent_notification.create
    data:
      message: >-
        Gas meter check, value stuck at "{{
        states('sensor.gas_meter_gas_consumption') }}"
mode: single