Both click and double_click work perfect, instead, long_click_press doesnât work as expected. I would like to long press the switch and toggle the light.
What happen is:
Long press: Light ON
Release: Light OFF
No way
It doesnât work well and from log I can see:
2018-04-13 21:35:06 ERROR (MainThread) [homeassistant.core] Invalid service data for light.toggle: Entity ID is an invalid entity id for dictionary value @ data[âentity_idâ]. Got ââ 2018-04-13 21:35:06 ERROR (MainThread) [homeassistant.helpers.service] Template rendered invalid service
Btw, I changed light.turn_off in light.toggle because I want Toggle both lights when long pressed. However light.turn_off works perfect and turn off both lights.
Hey. I was wondering why you put all the click types as triggers just to have to sort them in action!? Why not just write three simple automations instead of a complex one? I use mine like this:
- id: botao_sala1_single
alias: (bs1s) liga ou desliga o spot da sala
hide_entity: True
trigger:
platform: event
event_type: click
event_data:
entity_id: binary_sensor.switch_xxxx
click_type: single
action:
service: light.toggle
entity_id: light.rc1
- id: botao_sala1_double
alias: (bs1d) alterna profiles do spot da sala
hide_entity: True
trigger:
platform: event
event_type: click
event_data:
entity_id: binary_sensor.switch_xxxx
click_type: double
action:
- service: input_select.select_next
entity_id: input_select.cor_table
- service: light.turn_on
data_template:
entity_id: light.rc1
profile: >-
{{ states('input_select.cor_table') }}
- id: botao_sala1_hold
alias: (bs1h) hold sala
hide_entity: True
trigger:
platform: event
event_type: click
event_data:
entity_id: binary_sensor.switch_xxxx
click_type: hold
action:
service: light.toggle
entity_id: light.spot_sala
Yes sure, I can split the triggers in 3 IDs but for a clean GUI and for programming knowledge (Iâm already a programmer of other languages) I prefer to find a solution all in one!
Well, I adjusted my whole automation basing on your advices, and now it works fine, maybe I had somethings dirty on configuration. Many thanks for your help
this is awesome. I have just started to change all my xiaomi button automations to match your example⊠3 automations become 1! I dont quite understand the syntax of the template system yet so hopefully this will help me learn. Thank you!
Its just that I have a couple of Xiaomi buttons that currently have light toggle functions for single and double clicks but a completely different action for long press. Iâd love to be able to include the long press automation into the same one as the other two⊠but maybe thatâs not possible
awesome! thanks. Now⊠to complicate things my actual automation for the long_click_press is currently as per below. Is it possible to include additional actions for the long press like this?