Escaping color character in template when calling a notify service

How do I escape the colon character in Warning: below?

In the meantime, I’ve replaced the Warning: with Warning! in order for the YAML editor to treat it as a literal string of characters:

Normally, I do trial and error in the template editor until I get it right. However, in this case, the template editor doesn’t mind if I have a colon there or not:

Use quotes.

Thanks, but where? Do I put quotes around the colon character? Single quotes, double quotes?

Sorry:


service: notify.sms_family
data:
  message: "Warning: Litter-Robot waste drawer is {{ states('sensor.litter_robot_waste_drawer') }}% full. Please replace bag!"

P.S.: Use the tab „services“ in dev tools when you want to test notifications .

1 Like

Thank you so much. Sorry to keep bugging you… I just want to make sure I did this right. This is what it looks like in the YAML editor:
Screenshot 05-11-2021 at 06.56.01 PM

However, the actual script in automations.yaml has two single quotes surrounding the sensor name. Ive never seen a template with 2 single quotes like that… Also, I noticed that the double-quotes was changed to single quotes in the automations.yaml. Maybe this is normal?

  - service: notify.sms_family
    data:
      message: 'Warning: Litter-Robot waste drawer is {{ states(''sensor.litter_robot_waste_drawer'')
        }}% full. Please replace bag!'
  mode: single

No problem.
To be honest: I never cared. What I know is that special characters and magic YAML variables need quotation to be interpreted properly. Think, I‘m not the right person figuring out that :upside_down_face:

Yes it is. It’s just the way the UI editor parses yaml to store it as json (and vice-versa).

1 Like