When coding in Notepad++ both data_template and entity_id are gray, where I think they should not be. Or I’m I wrong about this?
When I remove the “>” the colors off the text is correct but I get errors the following error:
ERROR (MainThread) [homeassistant.bootstrap] Error loading /config/configuration.yaml: while scanning for the next token found character ‘%’ that cannot start any token
As you can see I’m not to familiar with templates. Is my code correct or what should be changed?
Did you ever figure this out? I read in one thread that people have not been able to get data_template to work inside service_template. All the working examples I’ve seen posted are just a simple service call with an entity_id, so perhaps this isn’t supported. But curious as to whether you made any progress after this post.
Yes I did get it working! Don’t know anymore what the fix was. Also do not use the code anymore because Snips (program that sends the intents) was way to slow for me. So I cannot show it…
But it certainly is possible to use both service template and data template
When i Added the if else logic as seen above i keep getting a configuration error.
Invalid config for [automation]: expected a dictionary for dictionary value @ data['action'][0]['data_template']. Got None. (See /config/configuration.yaml, line 48). Please check the docs at https://home-assistant.io/components/automation/
However if i were to remove the if else and only apply either the
I’m having the same problem. Meaning:
Firstly: I’m using service_template to select serviceA or serviceB
Secondly: As service A has different set of arguments than serviceB, I’m using data_template do select appropriate argument sets.
Thank you for a swift reply.
I was afraid that my solution wouldn’t work.
About your approach: I haven’t tested it yet, but I have some doubts about arguments’ names. Shouldn’t they be named the same in both of the scripts? Otherwise how would HA know how to pair values with arguments?