Using emoji in Home Assistant

Breaking change in Home Assistant 2022.7

This code will no longer work in the latest Home Assistant version. Instead of using the surrogate pair code as described below, you can paste the emoji symbol directly into your text / code (e.g., 👉)

If you are in the camp of people who need to include emoji in every single sentence, you probably wondered how to make it happen in your Home Assistant automation. It is not the most straightforward process, but possible with the right expressions.

I wanted to display standard emoji in markdown cards as well as iOS notifications to make them visually more interesting. The trick to do that is to express the emoji as a surrogate pair.

Surrogate Pair

A surrogate pair is defined by the Unicode Standard as “a representation for a single abstract character that consists of a sequence of two 16-bit code units, where the first value of the pair is a high-surrogate code unit and the second value is a low-surrogate code unit.”  Since Unicode is a 21-bit standard, surrogate pairs are needed by applications that use UTF-16, such as JavaScript, to display characters whose code points are greater than 16-bit.  (UTF-8, the most popular HTML encoding, uses a more flexible method of representing high-bit characters and does not use surrogate pairs.) Source:

In practice, that means a notification message with the following code is displayed on your iOS device or in Home Assistant front end as  🚨 WATER LEAK detected under the washer

message: '{{ "\uD83D\uDEA8" }} WATER LEAK detected under the washer'

Finding these surrogate pairs was the hardest part until I discovered this calculator:

Simply paste the emoji in the first field, hit calculate and note down the values in the last two fields. Make sure you properly format the code with \u before each set of 4 characters and your emojis should show up.

  1. no need to calculate anything
    just go to this site, find emoji you like click on it and you will get your code with \u

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Article

Send Synology Notifications to Slack

Next Article

Automate what happens when you start your car

We use cookies to improve your experience on our site and to show you relevant advertising. To find out more, please refer to our privacy policy.