I watched a YouTube video that is a couple of years old, about a Lovelace design. I learned a few tips that I will use to clean up my Lovelace pages, but he used the ~ symbol in a way I’ve never seen before.
In a card, he defines room:
- entity: climate.bedroom
attribute: temperature
name: Set
action:
service: script.temperature_toggle
room: bedroom
Since it’s a script and can pass variables to it, the other person probably had can automation that called the script and they passed the variable ‘room’ to it so they can use the same script for different rooms.
It’s not used a lot but I do use it in some of my config at times. Not necessarily for entity names but also other stuff as well.
You’re probably correct since the video was about having buttons on the home page that link to various room pages. So, if I understand correctly, room is defined in the card as room: bedroom, and in the script ~room expands to “bedroom”?
It’s useful wherever you use Jinja templates and you need to connect two or more strings together, especially when those strings are being stored inside variables. That includes scripts, template sensors, automations, and dashboard cards like Markdown or Mushroom.