Duplicated counter and automation - one counter and automation are defined, but they each have a ghost

I have an automation that increments a counter once per minute, but it “fires” twice and seems to update a copy of the counter. The counter and its ghost maintain different values.

The Logbook shows events like these:
image

The Reset automation acts on only one of the counters, which goes to zero. The ghost counter keeps its value and keeps incrementing once per minute.

I renamed the counter and the automation in the configuration, thinking that the ghosts might retain the original name, but everything shows with the new names.

In the History, the line graph bounces between the two:

Here are my automations:

- alias: Reset HVAC Operation Minute Counter
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: sensor.hvac_operation
  action:
  - service: counter.reset
    entity_id: counter.hvac_operation_minute_counter

- alias: Increment HVAC Operation Minute Counter
  initial_state: 'on'
  trigger:
    platform: time_pattern
    minutes: '/1'
    seconds: '00'
  action:
  - service: counter.increment
    entity_id: counter.hvac_operation_minute_counter

Here is my counter:

counter:
  hvac_operation_minute_counter:
    icon: mdi:progress-clock
#    name: HVAC Operation Timer
    initial: 0
    step: 1

For completeness, here is the sensor that triggers the reset:

  - platform: template
    sensors:
      hvac_operation:
        friendly_name: HVAC Operation
        value_template: "{{ states.climate.springville_house.attributes.operation | capitalize }}"
        icon_template: >                                                                                                                                 
            {% if states.climate.springville_house.attributes.operation %}                                                                                     
                {% if states.climate.springville_house.attributes.operation == 'cool' %}                                                                             
                    mdi:air-conditioner                                                                                                                                
                {% elif states.climate.springville_house.attributes.operation == 'heat' %}                                                                             
                    mdi:radiator                                                                                                                       
                {% elif states.climate.springville_house.attributes.operation == 'fan' %}                                                                             
                    mdi:fan                                                                                                                     
                {% else %}                                                                                                                                   
                    mdi:fan-off                                                                                                                       
                {% endif %}                                                                                                                                  
            {% endif %}

Just one shows in Developer Tools:

image
Any idea what could be going on or what to look at?

By the way, I am running version 0.88.1.

This will be cold comfort but I tested your automations and counter and it didn’t produce a ‘ghost effect’ (using 0.88.1). The counter’s value is incremented, as one would expect, every minute without duplication.

counter

I copied your two automations and counter verbatim with only one minor alteration. For convenience to carry out the test, I used an input_boolean to trigger counter.reset. Any state-change of the input_boolean resets the counter.

I can’t explain why you’re getting the ‘ghost effect’ you described.

Thanks for trying it! I couldn’t imagine that there would be something in these configuration statements that would do this. Maybe my system has some kind of corruption elsewhere.

I have already tried the reload automations button, restart home assistant, and sudo reboot.

Maybe I should try turning off everything that I can elsewhere in the configuration to see if something is interacting.

Is there any kind of database or file where these objects get stored that could be reset, other than my configuration files?

I suggest you inspect the contents of these two files in the .storage directory (a sub-directory of your config directory)

  1. core.entity_registry
  2. core.restore_state

The first one contains a list of entities and the second contains entities whose state is recorded and restored after Home Assistant is re-started (like a counter). Check both files for duplicated entities. It’s possible that core.restore_state contains a duplicated counter.

  1. I checked the files for duplicates and did not find any.
  2. I commented out many of the optional components in the configuration.yaml file and used an updated automations.yaml file that only had the two automations.
  3. I deleted the core.entity_registry and core.restore_state files.
  4. I deleted the home-assistant_v2.db file.
  5. I upgraded to 0.88.2.

No change in the behavior so far.