Sending text messages from Home Assistant can be handy as it allows you to send notifications to people who don’t have the companion app installed. In this guide, I will go through the various methods and show you exactly how to set up text message notifications.
Table of Contents
Home Assistant can send text messages to cell phones using one of two methods. One method is to set up the Twilio SMS integration and the second method is to configure the Home Assistant SMTP integration to use your carrier’s email-to-text service.
Having the ability to send text messages via Home Assistant is helpful for family and friends who don’t want to use a third-party push service such as Pushbullet or you may want to just send messages to people without giving them access to your Home Assistant instance.
Why Send SMS with Home Assistant?
Using Home Assistant to send text messages can be a great method of distributing notifications to your Home Assistant users that do not have the Home Assistant companion app installed on their phones.
You may have family members such as children who you do not want to give access to Home Assistant, or their phone may not be compatible with the app, but you may want them to receive some notifications automatically.
An example of this would be sending an SMS notification letting them know they have been playing on the Xbox too long or sending reminders of chores that need completing.
Method 1 – Twilio SMS Integration for Home Assistant
Twilio is an internet service that you can signup with and then use to send SMS messages to any cell phone via the internet. Twilio have a public API that integrates directly with Home Assistant using their official integration via the add-on store.
Twilio offers new users a free trial and then charges as low as $0.0075 per message sent and you can even request your own personal number for as little as $1 per month. Full details of their pricing structure can be found here: https://www.twilio.com/sms/pricing/us
Use Twilio in Home Assistant to send SMS
To set up the Twilio integration in Home Assistant follow the steps below and you could be sending messages within minutes.
- Sign in or register a new account with Twilio over at https://www.twilio.com/try-twilio
- If you have just signup up for the first time you will need to verify your phone number to start your free trial. Simply enter your phone number in the box and click submit. Twilio will then send you a message via text and you then need to enter that number in the verification box to continue.
- Once logged in and verified you should be taken to the dashboard where you will see your account information. Copy down the values from the Account SID and Auth Token boxes.
- Now you will need to open your Home Assistant configuration.yaml file in a text editor and add the following code. Replace ACCOUNT_SID_FROM_TWILIO with your actual SID and do the same for the Auth Token.
twilio: account_sid: ACCOUNT_SID_FROM_TWILIO auth_token: AUTH_TOKEN_FROM_TWILIO
- Now that you have set up the Twilio account details within your configuration file the next step is to add the following code to set up a new notification channel. Add this code to the same file.
notify: - name: NOTIFIER_NAME platform: twilio_sms from_number: +14151234567
- Replace NOTIFIER_NAME with your name or anything else to uniquely identify your notification channel and then replace the sample phone number with your own. When text messages are sent via this notification channel they will appear from that phone number as long as it has been verified by Twilio.
- Your notification channel is now completely configured and you can begin to use it in any automation you wish. For full usage instructions and further options available head over to https://www.home-assistant.io/integrations/twilio_sms/ to see a complete example.
Method 2 – Use an Email to SMS service for Home Assistant
Method two requires the use of the SMTP integration to send emails from your email address to a cell phone carrier’s Email SMS service.
Many cell phone networks provide their customers with the ability to send TEXT messages to phone numbers via a specific email address. For example, if your network is Virgin Mobile and your phone number is (555) 555-1234 then you can send an email to [email protected]
All network providers that have this functionality utilize a specific SMS gateway domain, the table below lists some of the biggest networks. If your network is not listed below then you may need to contact them to find out what it is or take a look at https://email2sms.info/ for a more complete list.
Use Email to SMS in Home Assistant
The following steps for this method will assume that Gmail is your email provider and T-Mobile is your cellular network.
- Open up your Home Assistant configuration.yaml file and add the following code.
notify: - name: "NOTIFIER_NAME" platform: smtp server: "smtp.gmail.com" port: 587 timeout: 15 sender: "[email protected]" encryption: starttls username: "[email protected]" password: "YOUR_PASSWORD" recipient: - "[email protected]" sender_name: "SENDER_NAME"
- Change NOTIFIER_NAME to something unique such as “Bob’s Phone”.
- Replace [email protected] with your own email address.
- If you are not using Gmail then replace smtp.gmail.com and the port with your email provider’s own SMTP details.
- Replace YOUR_PASSWORD with your email password. Use the secrets file to store this. If you have two-factor authentication enabled on your email account then you will need to use an app password. To create a Gmail app password to use in Home Assistant go to this page and follow the steps.
- Replace [email protected] with a recipient SMS email gateway address to the phone number you need to use. You can add multiple recipients by adding new addresses on each line.
- Once your configuration is complete you will then just need to validate and restart Home Assistant to enable the notification. Do this by opening Home Assistant then going to Configuration → Settings → Server Controls → Restart Home Assistant.
How to receive SMS in Home Assistant
Home Assistant can receive text messages if you implement the SMS integration and connect a GSM USB device to your Home Assistant server.
Summary
I have outlined two methods for enabling text message notifications with Home Assistant, both are easy to set up and are great alternatives to using push notifications or native notifications within the Home Assistant companion app.
If you would like to learn how to send email notifications from Home Assistant take a look at this guide or check out this article if you would like to send messages with Telegram.
If I required SMS notifications the method I would choose is using an email-to-SMS service because it would give me the flexibility of changing the SMS notification to an email notification by only having to replace the recipient’s email address.