I want to trigger an automation when i press a esphome switch. I just to do this with:
on_multi_click:
- timing:
- ON for at most 0.5s
- OFF for at least 0.6s
then:
- logger.log: "click"
- homeassistant.service:
service: automation.trigger
data:
entity_id: automation.badkamer_switch
but then I have a lot of automatons without a trigger. So I thought that I would use an input_button.
but in the documtation i found that:
Note
Buttons are designed to trigger an action on a device from Home Assistant, and have an unidirectional flow from Home Assistant to ESPHome. If you press a button using this action, no button press event will be triggered in Home Assistant. If you want to trigger an automation in Home Assistant, you should use a Home Assistant event instead.
so I thought that i use the service call:
- timing:
- ON for 1s to 3s
- OFF for at least 0.6s
then:
- homeassistant.service:
service: input_button.press
data:
entity_id: button_hoekwoonkamer_1_hold
- logger.log: "Single Long Clicked 1"
but this gives an error ( think it is this one because it is a strange one)
Logger: homeassistant
Source: core.py:1667
First occurred: 14:34:49 (2 occurrences)
Last logged: 14:34:49
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/core.py", line 1667, in async_call
processed_data: dict[str, Any] = handler.schema(service_data)
File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 229, in _run
return self._exec(self._compiled, value, path)
File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 355, in _exec
raise e if self.msg is None else AllInvalid(self.msg, path=path)
File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 353, in _exec
v = func(path, v)
File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable
return schema(data)
File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict
return base_validate(path, iteritems(data), out)
File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 433, in validate_mapping
raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: not a valid value for dictionary value @ data['entity_id']
and the target is not accepted in esphome
- timing:
- ON for 1s to 3s
- OFF for at least 0.6s
then:
- homeassistant.service:
service: input_button.press
target:
entity_id: button_hoekwoonkamer_1_hold
- logger.log: "Single Long Clicked 1"
I know i can work around this, but they do not trigger an input_button from home assistant?
note: I created the input_button in home assistant in the first place.