I’m using the pulse_counter
sensor and playing around with it to understand how it works. I’ve noticed that when I change the update_interval
value to be anything other than 60s the number of pulses is calculated against this. Here are some examples to show what I mean:
update_interval ==> output_value with one button press
1s ==> 60 pulses/min
5s ==> 12 pulses/min
10s ==> 6 pulses/min
30s ==> 2 pulses/min
60s ==> 1 pulses/min
This is the ESPHome yaml I’m using to test:
sensor:
- platform: pulse_counter
pin:
number: D3
mode: INPUT_PULLUP
name: 'Pulses'
id: pulses
count_mode:
rising_edge: DISABLE
falling_edge: INCREMENT
internal_filter: 13us
update_interval: XX
filters:
- debounce: 400ms
accuracy_decimals: 3
Where update_interval: XX
is set to 1s
, 5s
, 10s
, 30s
and 60s
.
With it set to 1s
this is the output when pressing the button slowly (less than 1 press per second) I get a value of 60 pulses/min:
[13:53:22][D][pulse_counter:159]: 'Pulses': Retrieved counter: 0.00 pulses/min
[13:53:22][D][sensor:092]: 'Pulses': Sending state 0.00000 in with 3 decimals of accuracy
[13:53:23][D][pulse_counter:159]: 'Pulses': Retrieved counter: 0.00 pulses/min
[13:53:23][D][sensor:092]: 'Pulses': Sending state 0.00000 in with 3 decimals of accuracy
[13:53:24][D][pulse_counter:159]: 'Pulses': Retrieved counter: 60.00 pulses/min
[13:53:24][D][sensor:092]: 'Pulses': Sending state 0.60000 in with 3 decimals of accuracy
[13:53:25][D][pulse_counter:159]: 'Pulses': Retrieved counter: 0.00 pulses/min
[13:53:25][D][sensor:092]: 'Pulses': Sending state 0.00000 in with 3 decimals of accuracy
[13:53:26][D][pulse_counter:159]: 'Pulses': Retrieved counter: 60.00 pulses/min
[13:53:26][D][sensor:092]: 'Pulses': Sending state 0.60000 in with 3 decimals of accuracy
[13:53:27][D][pulse_counter:159]: 'Pulses': Retrieved counter: 0.00 pulses/min
[13:53:27][D][sensor:092]: 'Pulses': Sending state 0.00000 in with 3 decimals of accuracy
[13:53:28][D][pulse_counter:159]: 'Pulses': Retrieved counter: 0.00 pulses/min
[13:53:28][D][sensor:092]: 'Pulses': Sending state 0.00000 in with 3 decimals of accuracy
[13:53:29][D][pulse_counter:159]: 'Pulses': Retrieved counter: 60.00 pulses/min
[13:53:29][D][sensor:092]: 'Pulses': Sending state 0.60000 in with 3 decimals of accuracy
With a value of 5s
I see 12 pulses/min (60 / 5 = 12
):
[13:58:14][D][pulse_counter:159]: 'Pulses': Retrieved counter: 12.00 pulses/min
[13:58:14][D][sensor:092]: 'Pulses': Sending state 0.12000 in with 3 decimals of accuracy
[13:58:19][D][pulse_counter:159]: 'Pulses': Retrieved counter: 12.00 pulses/min
[13:58:19][D][sensor:092]: 'Pulses': Sending state 0.12000 in with 3 decimals of accuracy
[13:58:24][D][pulse_counter:159]: 'Pulses': Retrieved counter: 24.00 pulses/min
[13:58:24][D][sensor:092]: 'Pulses': Sending state 0.24000 in with 3 decimals of accuracy
[13:58:29][D][pulse_counter:159]: 'Pulses': Retrieved counter: 12.00 pulses/min
[13:58:29][D][sensor:092]: 'Pulses': Sending state 0.12000 in with 3 decimals of accuracy
With a value of 10s
I see 6 pulses/min for each button press:
[14:00:07][D][pulse_counter:159]: 'Pulses': Retrieved counter: 0.00 pulses/min
[14:00:07][D][sensor:092]: 'Pulses': Sending state 0.00000 in with 3 decimals of accuracy
[14:00:17][D][pulse_counter:159]: 'Pulses': Retrieved counter: 6.00 pulses/min
[14:00:17][D][sensor:092]: 'Pulses': Sending state 0.06000 in with 3 decimals of accuracy
[14:00:27][D][pulse_counter:159]: 'Pulses': Retrieved counter: 6.00 pulses/min
[14:00:27][D][sensor:092]: 'Pulses': Sending state 0.06000 in with 3 decimals of accuracy
[14:00:37][D][pulse_counter:159]: 'Pulses': Retrieved counter: 0.00 pulses/min
[14:00:37][D][sensor:092]: 'Pulses': Sending state 0.00000 in with 3 decimals of accuracy
[14:00:47][D][pulse_counter:159]: 'Pulses': Retrieved counter: 0.00 pulses/min
[14:00:47][D][sensor:092]: 'Pulses': Sending state 0.00000 in with 3 decimals of accuracy
Maybe this is expected because it’s normalized to pulses/min but it seems like it should just report pulses…