I’m looking for a way to show the number of pressed buttons in Home Assistant.
As an example, I would like to check whether all 4 keys have been hung up. How can I do this with ESP Home?
Ideally, I’d like to see the number of keys hanging.
I have a running Homeassistant OS on my raspberry Pi4. ESPhome is running with two esp32 cams etc.
I built a board that activates buttons for each key which is hung up. Now i want to know a way to show an entitiy in HA which shows the number of pressed buttons. I don’t want to know if key 1, 2 and 4 is on the Board. I just want to know “3 keys are hung up”.
I’ve done this with an ESP32 which shows me the value on a HTML-Page. But i want this integrated in my HA. My programming was quick’n’dirty so I have to restart this project anyway, but I don’t have any experience with ESPHome other than using existing sensors etc.
yes there is a relation but it’s not important.
Hook 1 = key 1 = GPIO_X of ESP, Hook 2 = key 2 = GPIO_Y of ESP.
There are currently 4 hooks. But I’m not interested in knowing which Hook/ button is pressed.
I only need the count of pressed buttons as entity value
You need an automation and a input_number. The triggers would be your 4 switchs. The action would be input_number.increment when a switch goes to on. Then input_number.decrement when a switch goes off.
I’m guessing your buttons are mapped to binary_sensors and show as such in HA.
Create an input_number in HA with an initial value of 0.
Automation
Trigger: state change on any of the 4 binary sensors
Choose:
Action: with condition trigger.to 1 - increments the input_number by 1
Action: with condition trigger.from 1 - decrements the input_number by 1