I have 2 groups of entities. First is the sensors, second is the input_booleans. The purpose is that if anything triggers my sensors during alarm activation, the second set ( input booleans ) will switched to ‘on’ to register trigger until it is disabled manually, even if the sensors has reset itself to ‘off’.
the second group of ‘input_boolean’ will just have a prefix of ‘trigger_’ to the first group entities name ( sensors ) in the automation. And have it turn on. for example,
If the following are my sensors group
binary_sensors.door_1
binary_sensor.presence_5
and I defined the following input_booleans:
Input boolean:
input_boolean.trigger_door_1
initial: off
input_boolean.trigger_presence_5
initial: off
automation:
alias: ‘Trigger register while armed away’
trigger:
platform: state
entity_id:
- binary_sensor.door_1
- binary_sensor.presence_5
to: ‘on’
action:
I don’t seems to be able to get the second sets of equivalent ‘input_boolean.trigger_’ to turn on. I believe the problem lies in the last line but my experience in template couldn’t resolve it properly. thanks for any help on this.
For future reference, you should format your code to make it easier for others to read it and to detect any syntax errors. Select your code then click the </> icon to format it. Alternately, you can type three consecutive backquotes ``` on a separate line before your code and then another three, on a separate line, after your code.
From what I can see, the template is incorrect, mostly because it is using square brackets instead of braces.
Try this:
- alias: 'Trigger register while armed away'
trigger:
platform: state
entity_id:
- binary_sensor.door_1
- binary_sensor.presence_5
to: 'on'
action:
service: input_boolean.turn_on
data_template:
entity_id: "input_boolean.trigger_{{ trigger.to_state.object_id }}"
I have tested the template and it works perfectly. Apologise for the formatting issue as this is my first time using this forum. Will format my quote properly for future questions.
You’re welcome and I’m glad to hear that it helped solve the problem.
One more thing you may wish to do and that is to mark my post as the Solution. It’s not mandatory but there are benefits for other users. Only the author of a topic can select the post that was most helpful in resolving the problem. By marking the post with the Solution button, it will automatically do two things:
A check-mark will appear next to the topic’s title indicating to other users that the topic has an accepted solution.
A link will appear under the first post leading to the one containing the accepted solution. In the case the thread contains many posts, the link helps other users find the solution quickly.