#Keep UI from reformatting template text
1 messages · Page 1 of 1 (latest)
Keeping it like this instead action: input_text.set_value metadata: {} data: value_template: > {% if now().month == 2 and now().day == 15 %} "valentine" {% elif now().month == 7 and now().day == 4 %} "independence" {% elif now().month == 10 and now().day == 31 %} "halloween" {% elif now().month == 11 and now().day == 27 %} "birthday" {% elif now().month == 11 %} "fall" {% elif now().month == 12 and (now().day == 24 or now().day == 25) %} "christmas" {% else %} "night light" {% endif %} target: entity_id: input_text.light_pattern_preset alias: Set the light preset based on date
Hi @lament citrus,
Not if you are storing it in the automations.yaml file that the UI editor uses...
If you split the configuration and don't use the UI editor for those, then yes,
maybe like this:
data:
value_template: >
{% if now().month == 2 and now().day == 15 %} "valentine"
{% elif now().month == 7 and now().day == 4 %} "independence"
{% elif now().month == 10 and now().day == 31 %} "halloween"
{% elif now().month == 11 and now().day == 27 %} "birthday"
{% elif now().month == 11 %} "fall"
{% elif now().month == 12 and (now().day == 24 or now().day == 25) %}
"christmas"
{% else %} "night light"
{% endif %}
Are you up for using Code Server or something else to edit some of them?
> tells YAML that it can replace newlines with spaces
and so when it is serialized all the newlines are lost
That's ninja...
But the next time you edit or save it, that gone probably.
it kept it
no it should stay
little extra new line between stuff is much better than it all being mushed together, thank you, love the secret ninja methods
TBH that's almost as bad as the UI jubmle for me, though...
i'd definitely prefer it all together but hey
it's better than storing an automation or value outside the ui editor for me
Just use a real editor. Once the thing is built, most of the tweaks for cool stuff the UI can't do anyway. Build the base in the UI, and move the YAML to a split file is what I do a lot of times.
yea, i may move this to trigger off a calendar instead then the automation wont change at all and it's just managing calendar events
but for now, appreciate it @summer arrow
ya I already have a ton split out for things that never change but this one in particular is one of those that would
hence probably moving to the calendar method
👯
is there a reason you're including the quotes in your values?
i assumed it needed them to know it was a string but maybe it doesnt