no matter how much I play around with yaml, I am not getting used to the jinja stuff. Maybe someone can help me on this, I just do not find the solution:
I try to build very general automations and did set up multiple booleans with the “same name” as an existing light in the following scheme:
light.sofa → input_boolean.light_sofa
Using a dict as reference table, I assign a physical switch, e.g. doubleswitch_1
If doubleswitch_1 is pressed, I want to set the boolean to on.
To make it as efficient as possible, I came up with the following idea:
I would check that trigger.entity_id is what you think it is when the automation fires and that it’s present as a key in your table. It might help to share the whole automation. Last, maybe try playing with the whitespace options like this:
Rob, thank you for your comments. Yes, it is for sure in the table, because I just set it up with one device for now, for testing. The strange thing in Home assistant is, the entity_id itself is not included in the automation trigger, in case of the switch e.g. sensor.doubleswitch1_action:
Taras, thank you, but this is not working…
Error message:
Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘to_state’
I assume because I would additionally need the “conversion” from light.sofa to light_sofa.
Unfortunately, I cannot create input_booleans with periods in it, like “input_boolean.light.sofa”.
What kind of trigger are you using in your automation? If it employs a State Trigger then trigger.to_state.object_id exists.
Please post the entire automation so we can provide you with better assistance. The template you posted contains unnecessary steps and can be refined. However, seeing the entire automation ensures we can provide you with more accurate suggestions.
As trigger I use a physical Aqara / Xiaomi switch over mqtt.
As I said, for strange reasons, the entity name of the switch I use is switch.doubleswitch1_action, but in the automation I created with the UI, this entity name is not used…
Ok thank you for that information, now I already learned something new, I thought there are just triggers.
And how do I use them? I mean, how do I know what values they have, like e.g. trigger.entity_id?
I just read the home assistant pages for mqtt device triggers and for automation triggers, but it is not clear to me…
EDIT: I just found that on the page Automation Templating they explain what values the triggers have, don’t know why it is not on the page for Automation Triggers. What I am still missing there is device trackers, what values do they have? And interestingly my Xiaomi switch says for trigger.platform ‘mqtt’ and my Xiaomi motion sensor says ‘device’. But both use mqtt…
EDIT 2: Thank you, now with your help I use the correct trigger value, and now my original and your code seems to work! Thank you