#Keep UI from reformatting template text

1 messages · Page 1 of 1 (latest)

lament citrus
#

Is there any way to stop the UI from reformatting the value_template text?

#

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

hearty horizon
#

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,

lament citrus
#

yea

#

alright

#

was hoping there was some secret ninja method to do it

summer arrow
#

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 %}
hearty horizon
#

Are you up for using Code Server or something else to edit some of them?

summer arrow
#

> tells YAML that it can replace newlines with spaces

#

and so when it is serialized all the newlines are lost

hearty horizon
#

That's ninja...

lament citrus
#

😮

#

that worked

#

amazing

hearty horizon
#

But the next time you edit or save it, that gone probably.

lament citrus
#

it kept it

summer arrow
#

no it should stay

lament citrus
#

little extra new line between stuff is much better than it all being mushed together, thank you, love the secret ninja methods

hearty horizon
#

TBH that's almost as bad as the UI jubmle for me, though...

lament citrus
#

i'd definitely prefer it all together but hey

#

it's better than storing an automation or value outside the ui editor for me

hearty horizon
#

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.

lament citrus
#

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

hearty horizon
#

Once you wrap your head around it, you never go back...

lament citrus
#

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

hearty horizon
#

👯

oak cipher
#

is there a reason you're including the quotes in your values?

lament citrus
#

i assumed it needed them to know it was a string but maybe it doesnt

oak cipher
#

it doesn't need them

#

and it's just going to cause you problems long term