I have a template working in the developer tools and we get info out but after adding it to config file I get an error no idea what’s wrong please help
Code: sensor: - platform: template sensors: washing_time_finished - Pastebin.com
I have a template working in the developer tools and we get info out but after adding it to config file I get an error no idea what’s wrong please help
Code: sensor: - platform: template sensors: washing_time_finished - Pastebin.com
please don’t post camera pictures because they are too hard to read (unless they are really clear - these aren’t)
And when posting code don’t use screenshots at all. Post properly formatted actual text.
That said post the code for your whatever-it-is-you-are-doing here so we can see the actual code and any syntax errors.
What finity said; in the future, please follow the guidelines in the forum’s FAQ.
The problem is due to the fact the template lacks outer quotes.
sensor:
- platform: template
sensors:
washing_time_finished:
friendly_name: 'Washing Time Finished'
value_template: "{{ as_timestamp(strptime(states('sensor.washer_washer_completion_time'), '%d %m %Y %H:%M:%S')) | timestamp_custom('%d %b ~ %I:%M', false) }}"
Alternately, you can use the line-continuation character and move the template to a separate line. Then it doesn’t need outer quotes.
sensor:
- platform: template
sensors:
washing_time_finished:
friendly_name: 'Washing Time Finished'
value_template: >
{{ as_timestamp(strptime(states('sensor.washer_washer_completion_time'), '%d %m %Y %H:%M:%S')) | timestamp_custom('%d %b ~ %I:%M', false) }}
Please note that the corrected examples I posted use single-quotes within the template and double-quotes outside the template. You can also do the opposite (double inside, single outside); whatever you use outside, don’t use it inside. Your original example used both single and double-quotes within the template.
The code is in the paste bin
The pictures are only to show it works in dev tools and not in config.
The yaml is in the link in the post.
If you can post it there then you can post it here too. It saves me a click or two to help you.
Whatever you post externally might eventually disappear and that deprives users, who read this thread at a later date, from seeing the original material.