I am creating a script that I can use repeatedly for calls made by automations for various lights which are triggered by button pushes, but I am running up against the issue if understanding and using a variable in the data_template.
I have automations that call the script with a light:
on the script I am then using that given light to check the brightness, but getting an error in the logs no matter which way I attempt to use the variable within the brightness check.
I’ve looked through the forum but can’t find an answer (likely phrasing my query wrong), but hoping someone can point me in the right direction of how to do this.
Really don’t want to make 30+ versions of the same script to do this.
Invalid config for [script]: invalid template (TemplateSyntaxError: expected name or number) for dictionary value @ data['script']['lightincrease']['sequence'][0]['data_template']. Got None. (See /config/configuration.yaml, line 208).
Good point. Speaking of data_template, check out this unforseen side-effect of making data the equivalent of data_template.
The goal is to publish a payload containing a template, but you don’t want the template to be evaluated simply published literally. It becomes a bit more complicated now that data works like data_template.
Sorry for hijacking the thread! (See you in the other thread if you want to continue the conversation)
Looks to be a step in the right direction, but get the following:
Invalid config for [script]: Entity ID {{ person }} is an invalid entity id for dictionary value @ data['script']['notification']['sequence'][0]['entity_id']. Got '{{ person }}'. (See /config/configuration.yaml, line 208).
Invalid config for [automation]: string value is None for dictionary value @ data['action'][0]['service']. Got None. (See /config/configuration.yaml, line 207).
Sorry, I didn’t proofread the script. It’s probably flagging it as invalid because you can’t template the entity_id option within the condition. For example if you replace it with person.whatever it passes config check.
All good, you are helping me. I should have checked that myself, I thought that was what it was saying but didnt want to believe it.
That is a bummer though, hopefully I can perhaps move the condition back to the action phase of my automation and just use this as a general sending notifications script.
I did manage to move the condition back to the action phase of the automation, and just used the script as a notification script rather than needing to repeat that piece of code if different areas.