Home Assistant connection configuration
Label for this configuration, see details below for implications
Using the Home Assistant Add-on
If you're running Node-RED as a Hass.io Add-on check this. No other information is needed.
The base URL and port of the Home Assistant instance can be reached at, for example:
Long-lived Access Token used to contact the API
Unauthorized SSL Certificates
This will allow you to use self-signed certificates. Only use this if you know what you're doing.
string | delimited
A list of strings, not case sensitive, delimited by vertical pipe, |, that will return true for State Type Boolean.
Heartbeat will send a ping message using the websocket connection to Home Assistant every X seconds. If a pong response is not received within 5 seconds Node-RED will attempt to reconnect to Home Assistant.
The interval at which the ping message is sent to Home Assistant. The minimum value is 10 seconds.
Enable Global Context Store
If enabled, the global context store will be used to store the Home Assistant connection, state, and service information. This allows you to use the information in other nodes using context functions.
Cache Autocomplete Results
Enables the caching of the JSON autocomplete requests. Enabling or disabling this may require a restart of Node-RED for it to take effect.
ID Selector Display
Which text to show in the selector after the id has been chosen.
Status Date Format
A string that will appear in the status of an event node between the state and date string.
The other options are directly from DateTimeFormat Options.
Every node requires a configuration attached to define how to contact Home Assistant, which is this config node's main purpose.
Each config node will also make some data available in the global context, the
Name value in this node is used as, camelcase, and the namespace for those values
events is made available in the global context.
states is always set to all available states at startup and updated whenever state changes occur so it should be always up to date.
events is only updated on initial deploy.
Say we have a config node with the name
Home Assistant, with an entity set up in Home Assistant as
switch.my_switch. This state would be available within function nodes and you could fetch using something like the below code
const haCtx = global.get("homeassistant"); const configCtx = haCtx.homeAssistant; const entityState = configCtx.states["switch.my_switch"]; return entityState.state === "on" ? true : false;
Communication with Home Assistant is accomplished via a combination of WebSocket and the REST API if you are having trouble communicating with home assistant make sure you can access the API outside of node-red, but from the same server node-red is running on, using a REST client, curl, or any number of other methods to validate the connection