Counter and pulse counter help

I have a pulse counter on ESPHome it sends me data once a minute and is reset. How can I collect this data to the home assistant counter. I tried to use automation, but I don’t know how to increase the counter by the number of pulses received, and not by the default step. My script is not working. Maybe I need to use a different method? I will be very grateful for the help.

- id: '1567010738602'
  alias: Pulse count
  trigger:
  - event_data:
      entity_id: sensor.test_pulse_button
    event_type: state_changed
    platform: event
  condition:
  - above: '0'
    condition: numeric_state
    entity_id: sensor.test_pulse_button
  action:
  - alias: ''
    data:
      entity_id: counter.my_custom_counter
      step: '{{ state_attr(''sensor.test_pulse_button'') }}'
    service: counter.configure
  - alias: ''
    data:
      entity_id: counter.my_custom_counter
    service: counter.increment

Is the data being sent via MQTT?

If so, just create an MQTT sensor and use a template for the state, pulling the json value from the payload that you want to track. Then, create a history sensor that can count up all of the times that the state has changed to a specific state.

Thanks for the answer. Data is being sent via native ESPHome API. I have sensor data that counts pulses per minute and I want to summarize the pulses for the whole time. I can not understand how to use History Statistics Sensor for my task. I tried, but it doesn’t work for me. I do not know what to use as state.

  - platform: history_stats
    name: pulse count stats
    entity_id: sensor.test_pulse_button
    state: '>0'
    type: count
    start: '{{ 0 }}'
    end: '{{ now() }}'

Does the pulse carry the same value every time, or is it within the same range each pulse?

The state in your config needs to be a single value. So, if you have a pulse, like a heart monitor that measures values across a spectrum, you would need to pick a state value that’s recorded every time and just plug that in as the state value to watch. Then, set a start time and end time and you’ll get a count of the number of times that value is recorded.

You could also create a binary template sensor whose value is off when there’s no data being sent and on when there’s anything greater than 0 based upon the data coming in, then create a statistics sensor to measure that sensor to count the frequency over a given period of time.

The sensor values are different every minute. The range is from 0 to about 100. I found the statistics sensor component, it gives out a lot of different information, including the sum of the pulses, but I don’t know how to extract this attribute into the sensor template, what needs to be used as value_template:. Required attribute is total
Here is a link to the component https://www.home-assistant.io/components/statistics/

Hi, my case is very similar.
I have an old DSC alarm system with multiple door/window and motion sensors connected. On an ESP32S, I configured 8 binary sensors to get signals from channels. Since the outputs of channels are square wave with frequency of about 100 Hz, the sensor will toggle between ON and OFF at the same frequency when one door/window is opened. The system keeps writing DB file which becomes hundreds of megabytes very soon. Somebody have an idea to do a special “bouncing” ?