Node Red Contrib Home Assistant
Project is going through active development and as such will probably have a few 'growing pain' bugs as well as node type, input, output and functionality changes. At this stage backwards compatibility between versions is not a main concern and a new version may mean you'll have to recreate certain nodes.
NOTE: node-red-contrib-home-assistant requires node.JS > 8.0 If you're running Node-Red in Docker you'll need to pull the -v8 image for this to work.
$ cd cd ~/.node-red $ npm install node-red-contrib-home-assistant # then restart node-red
If you are running Node Red inside Hass.io addon/container you can use Hass.io API Proxy address
http://hassio/homeassistant as Home Assistant server address (server node Base URL). This way you don't need any real network address.
======= For flow examples checkout the flows here
The installed nodes have more detailed information in the node-red info pane shown when the node is selected. Below is a quick summary
Listens for all types of events from home assistant
State Changed Event
Listens for only
state_changed events from home assistant
Much like the
State Changed Ndoe however provides some advanced functionality around common automation use cases.
Outputs the state of an entity at regular intervals, optionally also at startup and every time the entity changes if desired
Sends a request to home assistant for any domain and service available (
Get Current State
Fetches the last known state for any entity on input
Fetches HomeAssistant history on input
Allows rendering of templates on input
An environment with Home Assistant/Node Red can be easily spun up using docker and docker-compose along with built in VSCode debug enabled.
- Clone this repository:
git clone https://github.com/AYapejian/node-red-contrib-home-assistant.git
- Install node dependencies as usual:
cd node-red-contrib-home-assistant && yarn
- Start the docker dev environment:
yarn run deva. Note: First run will take a bit to download the images ( home-assistants image is over 1gb (yikes!) after that launch is much quicker) b. Note: Also first run load of HomeAssistant web interface seems very slow, but after first time it's also much faster
yarn run devcommand will leave you with a terminal spitting out logs,
ctrl+cout of this and it kills all the servers by design, just run
yarn run devagain to pick back up. The following services and ports are launched in the
||exposed for local access via browser|
||exposed for local access via browser,
- If you run into environment issues running
yarn run dev:cleanshould remove all docker data and get you back to a clean state
- All data will be discarded when the docker container is removed. You can map volumes locally to persist data. Create and copy as directed below then modify
docker-compose.yamlto map the container directories to the created host dirs below. See:
./_docker/docker-compose.mapped.yamlfor an example or just use that file to launch manually
mkdir -p _docker-volumes/home-assistant/config mkdir -p _docker-volumes/node-red/data cp _docker/home-assistant/root-fs/config/* _docker-volumes/home-assistant/config/ cp _docker/node-red/root-fs/data/* _docker-volumes/node-red/data
Node Debugger via VSCode
Optional but it's pretty nice if you have VSCode installed.
- Open the project directory in VSCode
- Go to the debug tab ( or
- In the debug tab you should see an target for "Attach: Docker", run that guy and you can place debug breakpoints and changes will be reloaded within docker automatically
- Open http://localhost:8123 for HomeAssistant (password is
- For node-red either open up via the HomeAssistant web link or left hand menu or just open a browser tab to http://localhost:1880
Other Dev Tips
- If you're using VSCode and annoyed that node-red html (
type="x-red") isn't syntax highlighted you can run force it by adding support. Below is for Mac, can do the same manually on any platform however, note that this is a hack as I couldn't find any other good way to do this.