Counter decreases when internet resets

Everytime my internet drops, a helper counter I have setup to subtract a dishwasher pod, subtracts… How do I stop this from happening?

Post the automation that performs the subtraction.

alias: Dishwasher Complete
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.dishwasher_current
    for:
      hours: 0
      minutes: 15
      seconds: 0
    below: "0.09"
condition: []
action:
  - service: counter.decrement
    data: {}
    target:
      entity_id: counter.dishwasher_pods
  - service: notify.mobile_app_sm_g998u
    data:
      message: Dishes are done.
mode: single

Please edit your post and format your pasted config correctly.

What’s the state of sensor.dishwasher_current look like around the time when you encounter this issue?

And which integration supplies sensor.dishwasher_current?

The state is .02. If I unplug my router and plug it back in, it happens. The integration is tp-link kasa, dishwasher kp115(us)

Ok just making sure you weren’t using a template sensor that could be adjusted.

You could try this trigger:

trigger:
  - platform: numeric_state
    entity_id: sensor.dishwasher_current
    for:
      hours: 0
      minutes: 15
      seconds: 0
    below: 0.09
    above: 0.02

However I suspect what is really happening is that it goes 0.02 → unavailable (when unplugged) → 0.02 when plugged back in. To prevent this use this trigger and condition:

trigger:
  - platform: numeric_state
    entity_id: sensor.dishwasher_current
    for:
      hours: 0
      minutes: 15
      seconds: 0
    below: 0.09
condition:
  condition: template
  value_template: "{{ trigger.from_state.state not in ['unavailable', 'unknown'] }}"
action:
etc...

I will give the condition template a try. Thanks for your time and help.

1 Like

Let us know how it goes.

Sorry that I haven’t updated, I had a family emergency. When I have the template enabled, it no longer counts down.

Its because you are using the below as a trigger. So, when the system restarts, it is below and triggers the automation.
I have mine set up to turn on an input boolean when the power gets above a threshold. Then, when I open the door, it looks for that boolean to be on and then decrements the counter.
You could do the same but have it trigger the decrement of the counter when the power gets below your threshold if you dont use a door sensor… It would look for the boolean to be on and then decrement the counter.

Except that when it restarts the state is from “unknown” so the condition prevents it triggering.

I think I finally have this working. I changed the trigger to above 500 and then set a wait trigger to below 4 for 20 mins. I also changed to a sonoff plug but the problem still existed until this.

alias: Dishwasher Finished
description: subtract 1 pod at the end of a cycle
trigger:
  - platform: numeric_state
    entity_id: sensor.sonoff_1001711cc2_power
    for:
      hours: 0
      minutes: 0
      seconds: 0
    above: 500
condition: []
action:
  - wait_for_trigger:
      - platform: numeric_state
        entity_id: sensor.sonoff_1001711cc2_power
        for:
          hours: 0
          minutes: 20
          seconds: 0
        below: 4
  - service: counter.decrement
    data: {}
    target:
      entity_id: counter.dishwasher_pods
  - service: notify.mobile_app_sm_g998u
    data:
      message: Dishes are done.
mode: single