Wanted to share a small script to email a foreign language text (in my case Japanese) that can only be encoded in unicode.
Precondition: need to have an SMTP notification set up as described here:
Mine is called notify.SMStoAll - I am using a gmail email account to mobile carrier configuration:
- name: SMStoAll
platform: smtp
server: smtp.gmail.com
port: 587
timeout: 15
sender: !secret gmail_username
encryption: starttls
username: !secret gmail_username
password: !secret google_smtp_password
recipient:
- !secret A_sms
- !secret B_sms
- !secret C_sms
sender_name: My Home Assistant
Now comes the tricky part: you can use a regular call to the notifier with regular message body BUT you must force gmail and/or the carrier to interpret the message in rich text / html.
This is easily achieved by adding an empty html body to the message as shown below.
service: notify.SMStoAll
data_template:
title: Home Assistant Message
message: '{{ message_en }} - {{ message_jp }}'
data:
html: ' '
Tada! The message arrived readable in Japanese script