Extending Home Assistant by Node-RED flows.
- Triggers that are supported:
- Zone presence (e.g. person is at home).
- Alarm time from phone (requires phone app).
- State changes (e.g. pause music when the phone is ringing).
- Schedule (e.g. specific time at day, or sunrise/sunset).
- Custom triggers from HA scripts (e.g. to connect a script to Google Assistant and run its actions by Node-RED).
- Actions that could be run:
- Save currrent state or restore it (e.g. when leaving/comming back home).
- Turning devices off, by entire domains or entities filtering.
- Media player pausing and resuming.
- Climate setting to specific temperature, turning on/off, and cycling on-off for defined times.
- Cover opening, closing, setting to specific position, or changing position by steps (e.g. slow opening at morning).
- Spotify playback for playlists, and to any device (supports Sonos devices).
- Appling scenes.
- Running any other HA service.
- Ability to use HA UI to change the configuration (e.g. enable/disable scenarios).
- Allowing usage of targeted actions multiple times.
First, validate that all the dependencies are met, then continue to the Install or update section.
- You must have Home Assistant installed.
- You should have Home Assistant Node-RED addon installed. If it doesn't, you need to set the HA server node manually to connect to your HA instance.
- You must have Node-RED installed.
- Within Node-RED, make sure the following modules are installed (though the top-right menu > Manage palette):
- node-red-contrib-home-assistant-websocket
- node-red-contrib-calendar-trigger
- node-red-contrib-schedex
Notice: when updating, save the current latitude & longitude of the Schedex node before you import the updated flows.
-
Download this repository as a zip and un-zip it.
-
Import the flows
.json
files from flows folder into Node-RED (through the top-right menue > Import). -
If you're not using the Home Assistant Node-RED addon, set the Home Assistant server node manually (through the top-right menue > Configuration nodes > Home Assistant).
-
Set the latitude & longitude of the Schedex node. You can find them by clicking on a spot on a map inside Google Maps.
-
Copy the the
nodered-configuration.json
file from config folder, into your/config
folder of Home Assistant (you can upload the file via HA File editor addon).If you're running Node-RED outside of HA, create a
/config
folder under the root folder where Node-RED is running, and place the file there. -
Deploy the flows to Node-RED.
All the configuration is done on the nodered-configuration.json
file.
You can find a complete example for the configuration file here.
The nodered-configuration.json
file contains the following main sections:
- events - this is the triggers section.
- actions - here you can define actions that you want to reffer to from multiple triggers, if needed.
- spotify - contains the configuration and authorization for Spotify playback.
- input_entities_to_config_map - configuration for input entities that can control the Node-RED configuration file.
The events
property in the nodered-configuration.json
file allows you to configure the following triggers:
- Presence - triggered when a persone detected at a zone.
- Alarm - triggered when the phone alarm goes off.
- States - triggered when an entity state is changed, to a specific value(s).
- Schedule - triggered at a specific schedule (e.g. time of day).
- Custom events - triggered manually (e.g. by HA script).
The actions
property in the nodered-configuration.json
file allows you to configure actions that you use multiple times.
The actions types that you can define:
- State preservation - saving or restoring state of devices, filtering by domains and/or entities.
- Turn off - turn off any device which supports it, filtering by domains and/or entities.
- Media - control
media_player
entities (play/resume, pause). - Climate - control
climate
entities (turn on/off, set temperature). - Cover - control
cover
entities (open, close, set position). - Spotify - Spotify playlists playback, to any Spotify device/speaker.
- Scene - apply scenes.
- Service - running any HA service.
The spotify
property in the nodered-configuration.json
file holds the Soptify configuration.
Reffer to Spotify configuration documanation for more info.
The input_entities_to_config_map
property in the nodered-configuration.json
file allows to configure input entities that can control the Node-RED configuration file. This is helpful when you want to be able to change certain configuraitons from the UI on the fly instead of opening the configuration file to change them.
Reffer to Input entities control documanation for more info.