iOS Notifications with Home Assistant and Node-Red

*The article below contains affiliate links. If you purchase an item after clicking on that link, I will receive a commission. Thank you!

Having an automated smart home is practical and fun. One way to add to the practicality is to be able to receive push notifications to your phone when certain automations run in your house. We will go over the basic setup of how simple push notifications work with Node-Red and Home Assistant.

Prerequisites

In order to receive push notifications, you need to have the iOS app installed on your device. Without this step being completed, the call service to receive the notifications will not be available in Node-Red. Also worth noting is that you will need to have notifications turned on for the iOS device you are pushing to. Without notifications turned on, the flow will work, but nothing will happen on the device.

You will also need to have everything set up that you would like to receive a notification for. If you want a notification when your lights turn off, you will need to have the lights and everything set up. A smart light switch like this one work very well with Home Assistant.

Nodes Used

  • Inject Node
  • Debug Node
  • Call Service Node

Getting Started

You will want to open up Node-Red and have an empty space in your flow ready to go.
As always, I like to start with an inject node and a debug node so that we will be able to test and debug the flow.

Inject and Debug Nodes ready to get started


The next node you will use is the Call Service node. This node allows you to call any service available in the Home Assistant system. The red triangle above the call service node is there as a warning that the node has not been setup yet. Which makes sense since we just added it to the flow.

Call service node needing to be setup

Double-click on the Call Service node to get into the options screen.

Blank options for the Call Service node

Name: This is where we will name the node. Naming keeps the flow easy to read.
Server: This is where you select the server to run from. It would be rare to change this.
Domain: Select the domain for the type of service. Notifications use the “notify” domain.
Service: This is the service you want to call from that domain. With iOS notifications, each iOS device in your system will have it’s own service. Make sure you select the correct device or you will be sending notifications to the wrong place.
Area: This field will go away once you select the domain and service for the notifications.
Device: This field will go away once you select the domain and service for the notifications.
Entity: This field will go away once you select the domain and service for the notifications.
Data: This is where we build the notification. The data field follows a very specific design so it makes sense to copy and paste it once you get it working the first time. There are two options in the grey dropdown to the left of the input field. There is the “expression” and then there is “json.” The iOS notification service works with json, so select that dropdown and then press the ellipses to open up the editor.

Data Field

We will be working with JSON so if you know how to write JSON, this will be very straightforward. For a quick tutorial that in no way gets even close to knowing everything, JSON works by sending pairs of information. These attribute-value pairs are what you need to write in your Data field. The two main pairs that you want are the “message” and “title” pairs. You will need to open and close with curly brackets and use a comma between pairs. Below is the code I use for a simple test notification to my phone.

{
    "message": "Message",
    "title": "Test"
}

Once you have this written in the Data field, you can select “Done” and then wire the call service node between the inject node and the debug node. Hit “Deploy” in the top-right corner of Node-Red and then give the server a minute to reload all of the nodes.
Pressing the grey box next to the inject node will start the flow and you should receive your test notification to your iOS device.

The flow when it is done
Success! Notification sent to iOS device

That is all you need to set up the notifications to your iOS device. You can add this to any flow to receive notifications. As an example, below is a flow that I have for notifying me that my lights have turned off when everybody leaves the home.

Flow to send notification when lights are turned off

You may notice a node called “Sean Notify On” right before the call service node at the end. This is a step that I have added so that I can turn notifications on or off. It uses a “helper” toggle that I can turn on or off from my dashboard. There are different notifications based on level of importance so that I can turn off only certain notifications and leave other more important ones on. That’s a post for another day.

Leave a Reply

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