Home Assistant has a nice iOS integration with the Home Assistant for iOS app. In this post I will describe how I have used the notify platform in Home Assistant to get notifications on my iOS devices when the front door of our house is opened.
Home Assistant
I have been using Home Assistant for about 10 months now and my initial steps with HA are described in these posts:
Home Assistant – getting started and using MQTT sensors
Home Assistant – integrating RESTful switches
Owntracks, Mosquitto and Home Assistant
The HA community does a great job and I try to stay updated with the new releases of Home Assistant. I’m currently on version 0.57.2 and I am hosting my Home Assistant on a Raspberry Pi 2.
The ios component
If you configure Home Assistant to use the ios component, the companion iOS app will have additional functionality for device tracking and notifications. To load the ios component, you simply add one row to your configuration.yaml file on your Home Assistant server:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ios: |
This will also load the notify-, device_tracker and zero_conf platforms.
Basic notifications
With the ios component active in Home Assistant, you can use the States developer tool in HA to check that your device has been tracked via the iOS app:
With the device name found by Home Assistant, you can test to send a notification to the device with the Service developer tool. Use “ios_” + the device name for the service:
If everything was setup correctly, a notification should appear on your iOS device after pressing the Call Service button:
Automation rules for notifications
I have a home-made open door detector for our front door. It is described in this post:
A low energy open door detector with radio signals and MQTT
Every time the door is opened, it broadcasts a new sequential value via 433MHz and an ESP8266 board detects this and transforms the value to an MQTT message on the local LAN. My Home Assistant instance subscribes to these MQTT messages and it is recorded as a state change within Home Assistant.
I want to have notifications on my iPhone when the door is opened. This can be achieved with an automation rule. It will be triggered when the state of the door sensor is changed. The action that should be executed is sending a notification to my iPhone with the notify platform:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
automation: | |
alias: Notify Lars when door is opened | |
trigger: | |
platform: state | |
entity_id: sensor.front_door_opened | |
action: | |
service: notify.ios_larsiphone | |
data: | |
message: The front door has been opened! |
Now, when I open my front door, voilà, I get a notification on my phone:
As getting lots of these notifications while at home can be annoying, the automation rule can be modified with a condition so that the action is only executed when I’m not at home (or actually when my iPhone is not at home):
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
automation: | |
alias: Notify Lars when door is opened | |
trigger: | |
platform: state | |
entity_id: sensor.front_door_opened | |
condition: | |
condition: state | |
entity_id: device_tracker.larsiphone | |
state: not_home | |
action: | |
service: notify.ios_larsiphone | |
data: | |
message: The front door has been opened! |
More on notifications
You can send notifications to several devices or a group:
https://home-assistant.io/docs/ecosystem/ios/notifications/basic/
Adding sounds
You can use a built-in or a custom sound for a notification:
https://home-assistant.io/docs/ecosystem/ios/notifications/sounds/
There is a built-in sound that fits my event perfectly. By adding this:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
automation: | |
alias: Notify Lars when door is opened | |
trigger: | |
platform: state | |
entity_id: sensor.front_door_opened | |
action: | |
service: notify.ios_larsiphone | |
data: | |
message: The front door has been opened! | |
data: | |
push: | |
sound: "US-EN-Alexa-Front-Door-Opened.wav" |
I get a notification with a speech recording “The front door has been opened” when the door is opened. Nice!
Actionable notifications
With Actionable notifications, you can make Home Assistant act on feedback from how the user handles the notification on the devices. I have not tested it yet, but it might be useful.
https://home-assistant.io/docs/ecosystem/ios/notifications/actions/
Attachments and dynamic content
With iOS10 you can send notifications with attachments and dynamic content:
https://home-assistant.io/docs/ecosystem/ios/notifications/attachments/
https://home-assistant.io/docs/ecosystem/ios/notifications/content_extensions/
This can be useful for sending a snapshot or a live stream from a security camera when a motion is detected. I have not tried it yet, but it will be an upcoming experiment for my Home Assistant-connected cameras.
Privacy, limits and security
https://home-assistant.io/docs/ecosystem/ios/notifications/privacy_security_rate_limits/
My Home Assistant configuration
My Home Assistant configuration is available on GitHub:
https://github.com/LarsBergqvist/Home-Assistant_configuration
Hi Lars, thanks for the great article!
Have you played with textInput?
Maybe you can help with that https://community.home-assistant.io/t/31116
LikeLike
Thanks for your kind comment. I have not yet experimented with actionable notifications. I might try it in the future though.
LikeLike