💁🏼‍♀️ Using emoji in Home Assistant

Filed under:

I've found that using emoji in Home Assistant isn't as straight forward as just typing it into your YAML configuration files.

Doing that might result in a broken configuration or if using Lovelace, it not loading. Personally, I think this really sucks, since I use emoji for everything. They are still meant to be symbols which make visual diffing or identification a lot easier. The two notifications in the screenshot below mean a totally different thing but when you're getting a lot of notifications each day, they could easily be read the same because of their text markup & format:

IMG 62D65FAA0D95-1

Both of course since emoji are just a composition of UTF codes using them should be possible in some way. Lets take 💁🏼‍♀️ which is easily one of my favorites. I would have thought that using its hex code point (U+1F481) would have worked but it didn't. UTF8? Nope. UTF16 (something I have never used before) proved to be the answer.

To get emoji working in Home Assistant you need to use the encoding called hex UTF-16 surrogates

For our sassy woman emoji this would be D83D DC81. To use them in Home Assistant they need to be formatted as follows: \ud83d\udc81. Note that using this in notifications, platforms and components should work but I didn't manage to get it running in Lovelace UI, even when correctly formatted like this. Now you tell me this doesn't look pretty and easy:

HA notifications with emoji

Of course with my limited knowledge of the unicode & UTF spec I didn't find those hex codes myself. I tried dabbling around with something in the shellm you can use it to get the hex representation of your emoji:

$ printf "🔋" | xxd
00000000: f09f 948b

$ printf "🔋" | hexdump
0000000 f0 9f 94 8b
0000004

Ok, so this works but I've found scripting it to make a bash function out of it was hard and not worth the effort. Instead you can use this excellent UTF-8 tool website to get every single encoding for your emoji.

Keep ramming emoji in everywhere!