Hi, I need your support… I’m struggling with the migration from legacy format to the new format.
I need advice, how to switch these two sensors in the new format:
Another question, just for my understanding, regarding the state:
Sometimes there’s just a 'and sometimes " in one line, after state - is this the same, or do I have to pay attention to it?
And furthermore there’s state: > or state: >- but the {{...}} in another intended line.
You can use either double or single quotes outside your single line template, it does not matter - as long as whatever you use inside is the opposite type. e.g. both of these are valid:
state: "{{ state_attr('sensor.foo','bar') }}"
state: '{{ state_attr("sensor.foo","bar") }}'
Convention is to use double quotes outside and single quotes inside. However json data requires double quotes around keys so sometimes this is not possible.
Multi-line templates, indicated with >, or | should not have quotes outside the template:
state: >
{{ state_attr('sensor.foo','bar') }}
The use of a dash after the multi-line character strips the last new line character from the data. It is rarely required as home assistant ignores it anyway. You can learn more about this by experimenting with the interactive demo here (scroll down to watch the light grey text at the end of the RESULT text as you play with the controls):