Hi everybody,
one of the things I still need to get into deeper when it comes to Home Assistant are scripts. I use some, but notice that I usually just write (repetitive) automations rather than using scripts.
Is this possible:
Somehow script both the trigger and the action (and, if applicable, the condition(s))?
Here is an example of what I think off; this isn’t actual code that would work in Home Assistant, but I believe this might get the point across better than me trying to explain it…
service:
explain:
sequence:
trigger:
- platform: state
entity_id: {{ my_trigger_entity }}
state: {{ my_trigger_state }}
action:
- service: {{ my_wanted_service }}
entity_id: {{ my_service_entity }}
So if I do this
- my_trigger_entity: binary_sensor.motion_01
- my_trigger_state: “on”
- my_wanted_service: light.turn_on
- my_service_entity: light.something_01
then light.something_01
will turn on, if binary_sensor.motion_01
switches to on
. However, if I changed any of those variables, I could still have the same basic structure of automation, but easily create different scenarios.
Of course, I can set up multiple automations with different triggers, then execute a script through the action
part of the automation, I was just curious, if it was possible to script automations even more.
Thank you for your input