Hi,
Currently, I can see several ways to expose multi click to HA from ESPHome:
- Using a binary sensor for each click type, and toggle them through on_multi_click
- Publishing different events or one event with different parameters using homeassistant.event
- Using a text sensor for each click type, and update its value
- MQTT topics
- …
What’s version will fit best with HA ?
I like the binary sensor one, because I can directly see the entities within the device dedicated page and it’s more user friendly when using the UI to create automation
But using YAML, I currently migrate to the event solution. It helps me to reduce some boilerplate and seems more intuitive.
Here a comparison with only 2 states.
trigger:
platform: event
event_type: esphome.event
event_data:
device_name: shelly_25_1
action:
choose:
conditions: "{{trigger.event.data.type == ’single’}}"
sequence:
service: light.toggle
target:
entity_id: light.living_room
conditions: "{{trigger.event.data.type == ’double’}}"
sequence:
service: light.toggle
target:
area_id: house
vs
trigger:
platform: state
entities:
- binary_sensor.shelly_25_1_single_click
- binary_sensor.shelly_25_1_double_click
to: "on"
action:
choose:
conditions: "{{trigger.entity_id == ’binary_sensor.shelly_25_1_single_click’}}"
sequence:
service: light.toggle
target:
entity_id: light.living_room
conditions: "{{trigger.entity_id == ’binary_sensor.shelly_25_1_double_click’}}"
sequence:
service: light.toggle
target:
area_id: house
What do you think?