Good morning everyone, I’m trying to make a counter of the openings of the house gate. I’ll try to describe below what I realised to know where I’m wrong in your opinion.
I connected the contact of the button of my intercom to a relay driven by a NODEMCU (on which ESPEasy runs). via MQTT I operate the contact from HOMEASSISTANT. The gate is programmed that when the contact closes it opens and closes after 40 seconds alone. If I close the contact of the relay with the gate at the opening, the gate continues to open, while if the gate is closing it reopens. Now I would like to add a metre that indicates the number of gate openings.
This is the switch code to open the gate
- platform: mqtt
name: "ESP-CITOFONO-CARRAIO RESIDENCE"
qos: 1
state_topic: "/ESP-CITOFONO/Switch4"
command_topic: "/ESP-CITOFONO/Switch4/gpio/15/cmd"
payload_on: "Pulse,15,0,500"
payload_off: "Pulse,15,0,500"
#optimistic: false
type or paste code here
While this is the sensor that should count the openings
Of course, the metre on the web interface does not increase, I guess it has to create some link between the switch and the sensor but I don’t sincerely know how.
As always, I trust some advice from the community.
Are you storing history for the switch using recorder? History_stats requires history(from the recorder integration) to be stored for that device. By default, home assistant stores a history for everything unless you told it not to. I also noticed you’re using a start of 0. One thing you should keep in mind, this will only count what’s in your history. By default, history only keeps a rolling 10 days of information. Therefore, the count will only include 10 days of information.
It provides a solution to count the times an automation has run. If you track the automation that fires when your gate opens you have a more robust solution.
it doesn’t magically add 15 days worth of data. It purges after it receives 15 days of data. So if you just turned this on for sensors, you have to wait until the data is collected.