Resetting counters - how does it work?

Hello everybody,

I’d like to count the number of times, when the motion sensor sees me, but decides to not switch on the light, just because it’s already bright enough in the room.

So, I’ve created a counter, using the helper entites and basically it works nicely. Each time the sensor sees me during the day, the number is incremented by 1.

But then I wanted to reset this counter each night at 03:00h. I’ve done something similar in the past and so I’ve chosen the utility meter to reset my counter … and this does not work. My first counter has been created directly in the configuration.yaml and this works. The new one has been created using the UI … and resetting does not work. Of course I could create an automation and reset the counter this way, but on one hand, I don’t want to have my lists of automations spammed by too many ‘tidy up scripts’ and secondly I would like to understand, why it worked for the first counter and not for the second one.

configuration.yaml:

#counters
counter:
  my_custom_counter:
    name: myFirstCounter
    initial: 1
    step: 1


utility_meter:
  counter_meter:
    name: ReadCounter
    source: counter.my_custom_counter
    cycle: daily
  room1_too_bright:
    name: room1_too_bright
    #created with UI
    source: counter.room1TooBright
    cycle: daily
    offset: "03:00:00"

So my expectation was that this utility_meter, although it has been designed to do something different, would reset my simple counter, but it doesn’t.

I would be nice if someone could tell me what I did wrong.

Thanks,
Fridolin

You answered your own question. I don’t understand why you would try this. You’re trying to use something (utility meter) for something that has nothing to do with it’s purpose.

If you want to reset the counter at 03:00 then create an automation that triggers at 03:00 and reset the counter. Easy peasy.

- service: counter.reset
  entity_id: counter.my_custom_counter

Hmm…but why is it working for the first counter? Where is the difference? Creating an automation to reset the counter is clear, but I would like to understand why it is working fine for my_customer_counter and not for room1_too_bright.

Is your counter called “room1_too_bright” or “room1TooBright”?

Thank you for the idea, but I’ve copied the name of the counter, just to make no mistakes and even after double checking right now, there is no typo. :frowning:

I see the configuration for three of the four entities. Show us the configuration for the fourth entity:

counter.room1TooBright
1 Like