Node-red-contrib-home-assistant-websocket

uncheck if you want to allow overrides

npm didn’t install the @hapi/joi package when it installed the rest of the dependencies. You can uninstall it and try and reinstall it and watch the build log to see why it failed or manly log into to docker container and in the node-red folder use npm install @hapi/joi.

Thanks, that was simple. I never thought twice to think what that checkbox does. Given that, it might be a bit confusing that the current_state and wait_until behave a bit differently. The wait_until defaults with the ‘Block Input Override’ enabled and the current_state is default to disabled. Also, the input parameters for entityId are different between the two. wait_until uses ‘payload.entityId’ and current_state uses ‘payload.entity_id’

Thanks for the advice @Kermit! However, I’m still having some issues. It’s probably something I did. any good ideas?

image

I have also tried removing node-red-contrib-home-assistant-websocket and reinstalling it.

Thanks again!

What are you running docker on? What do the npm logs say when installing it via the palette? There should be a view install log button next to the right side when installing it.

New Release v0.14.0

Features

  • JSONata everywhere (6424235)
  • api: Add option for data field to be a JSONata Expr (37b54ce)
  • call-service: Add JSONata option to data field (8e91f42)
  • fire-event: Add option for data field to be a JSONata Expr (526d083)
  • get-entities: Allow overriding of config values from payload (a0fdb96), closes #133

JSONata

  • There are three functions added for JSONata expressions within the Home Assistant nodes
    • $entity() returns the entity that triggered the node
    • $prevEntity() returns the previous state entity if the node is an event node
    • $entities() returns all entities in the cache
    • $entities(entity_id) returns a single entity from cache matching passed in entity_id

When JSONata appears in the conditional dropdown it expects the expression to return a boolean, true or false.

image

When it is chosen with a conditional, not JSONata it will return a value of the evaluated expression that will be checked against the conditional chosen.

image

Call-Service Node Changes

  • Entity ids are no longer merged with the data property on the front end
  • The data field does not have to be valid JSON until after templates are rendered. This change will allow you to assign numbers to properties as an actual number and not a string using templates.
  • entity_id in the data property will supersede the entity id field
  • Flows exported from version 0.14.0 will lose the entity id when imported into a previous version

Notice: Just because the text is yellow on a node doesn’t mean you need to go update it. It will continue to function just as it is and the next time you modify the node it will be upgraded then.

Full Changelog


Buy me a coffee For those that enjoy my work.

5 Likes

Thanks for the update, I’ve just updates, redeployed nodes, etc. and all working great so far. :slight_smile:

Hello @Kermit,

I’m running docker on a raspberry pi.

Here is my log:

Thanks again for your help on this. I really appreciate it!

I know it runs right out of the box on rpi using docker. Maybe try rebuilding the container also not sure if you’re already using it or not but I recommend using the raymondmm/node-red image.

Hello again Kermit and thanks

I have rebuilt the container a few times using the image you have prescribed in other posts and above. Here is the log:

> [email protected] start /usr/src/node-red,
> node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data",
,
25 Jul 03:15:19 - [info] ,
,
Welcome to Node-RED,
===================,
,
25 Jul 03:15:19 - [info] Node-RED version: v0.20.5,
25 Jul 03:15:19 - [info] Node.js  version: v10.15.3,
25 Jul 03:15:19 - [info] Linux 4.19.42-v7+ arm LE,
25 Jul 03:15:20 - [info] Loading palette nodes,
Thu, 25 Jul 2019 03:15:23 GMT node-telegram-bot-api deprecated Automatic enabling of cancellation of promises is deprecated.,
In the future, you will have to enable it yourself.,
See https://github.com/yagop/node-telegram-bot-api/issues/319. at internal/modules/cjs/loader.js:701:30,
25 Jul 03:15:24 - [warn] rpi-gpio : Cannot find Pi RPi.GPIO python library,
25 Jul 03:15:24 - [warn] Missing node modules:,
25 Jul 03:15:24 - [warn]  - node-red-contrib-home-assistant-websocket (0.14.0): server, server-events, server-state-changed, trigger-state, poll-state, api-call-service, ha-fire-event, api-current-state, ha-get-entities, api-get-history, api-render-template, ha-wait-until, ha-api,
25 Jul 03:15:24 - [info] Removing modules from config,
25 Jul 03:15:25 - [info] Settings file  : /data/settings.js,
25 Jul 03:15:25 - [info] Context store  : 'default' [module=memory],
25 Jul 03:15:25 - [info] User directory : /data,
25 Jul 03:15:25 - [warn] Projects disabled : editorTheme.projects.enabled=false,
25 Jul 03:15:25 - [info] Flows file     : /data/flows.json,
25 Jul 03:15:25 - [info] Server now running at http://127.0.0.1:1880/,
25 Jul 03:15:25 - [warn] ,
,
---------------------------------------------------------------------,
Your flow credentials file is encrypted using a system-generated key.,
,
If the system-generated key is lost for any reason, your credentials,
file will not be recoverable, you will have to delete it and re-enter,
your credentials.,
,
You should set your own key using the 'credentialSecret' option in,
your settings file. Node-RED will then re-encrypt your credentials,
file using your chosen key the next time you deploy a change.,
---------------------------------------------------------------------,
,
25 Jul 03:15:25 - [info] Waiting for missing types to be registered:,
25 Jul 03:15:25 - [info]  - server,
25 Jul 03:15:25 - [info]  - trigger-state,
25 Jul 03:15:25 - [info]  - api-current-state,
25 Jul 03:15:25 - [info]  - api-call-service,
25 Jul 03:15:25 - [info]  - server-state-changed,
25 Jul 03:15:25 - [info]  - ha-get-entities,
25 Jul 03:15:25 - [info]  - server-events,
25 Jul 10:53:53 - [info]  Disabled node types:,
25 Jul 10:53:53 - [info]  - twitter-credentials,
25 Jul 10:53:53 - [info]  - twitter in,
25 Jul 10:53:53 - [info]  - twitter out,
25 Jul 11:31:44 - [info] Installing module: node-red-contrib-home-assistant-websocket, version: 0.14.0,
25 Jul 11:32:52 - [info] Installed module: node-red-contrib-home-assistant-websocket,
25 Jul 11:32:53 - [info] Missing type registered: server-events,
25 Jul 11:32:53 - [info] Missing type registered: server-state-changed,
25 Jul 11:32:53 - [info] Missing type registered: api-call-service,
25 Jul 11:32:53 - [info] Missing type registered: api-current-state,
25 Jul 11:32:53 - [info] Missing type registered: ha-get-entities,
25 Jul 11:32:53 - [info] Missing type registered: trigger-state,
25 Jul 11:32:53 - [info] Added node types:,
25 Jul 11:32:53 - [info]  - node-red-contrib-home-assistant-websocket:server : Error: Cannot find module 'debug' (line:6),
25 Jul 11:32:53 - [info]  - node-red-contrib-home-assistant-websocket:server-events,
25 Jul 11:32:53 - [info]  - node-red-contrib-home-assistant-websocket:server-state-changed,
25 Jul 11:32:53 - [info]  - node-red-contrib-home-assistant-websocket:trigger-state,
25 Jul 11:32:53 - [info]  - node-red-contrib-home-assistant-websocket:poll-state,
25 Jul 11:32:53 - [info]  - node-red-contrib-home-assistant-websocket:api-call-service,
25 Jul 11:32:53 - [info]  - node-red-contrib-home-assistant-websocket:ha-fire-event,
25 Jul 11:32:53 - [info]  - node-red-contrib-home-assistant-websocket:api-current-state,
25 Jul 11:32:53 - [info]  - node-red-contrib-home-assistant-websocket:ha-get-entities,
25 Jul 11:32:53 - [info]  - node-red-contrib-home-assistant-websocket:api-get-history,
25 Jul 11:32:53 - [info]  - node-red-contrib-home-assistant-websocket:api-render-template,
25 Jul 11:32:53 - [info]  - node-red-contrib-home-assistant-websocket:ha-wait-until,
25 Jul 11:32:53 - [info]  - node-red-contrib-home-assistant-websocket:ha-api,

I notice the credential error, but from what I have read that that is an independant issue with creating a token and modifying the /opt/node-red/settings.js file.

I greatly appreciate your assistance.

Can the jsonata functions be called from within any nodered jsonata expression? Or only the ha nodes ?

Only in HA nodes

1 Like

Can anyone post an example using jasonata?

To whom it may concern- I was able to fix my issue by stopping the container, exporting all my flows, deleting everything in the data folder, rebuilding the container, then finally importing all of the flows. Thanks again @Kermit for your assistance and development of this awesome addon.

What kind of examples are you looking for?

How about an example of using it to populate the data of a call service node?

What I am asking is a use case example. I am not sure where or when this would be useful.

Have you used jsonata before?
I haven’t used yet the jsonata in ha nodes but I do use them quite a lot in switch and change node.
I have a flow, executes at certain time is for turning the heater in the morning. I need to first check temp, if is under a value but I wanted that temp limit to be adjustable so use an input_number. So it will only pass if temp is below that input number. Now I can do that with jsonata and the included ha function. ATM what I have is a state change node that stores the input number value in context.

@silfa718 @MizterB I broke it out into a seperate post.

@Kermit I was wondering if you had any examples of the API node? I’m trying to query /zha/devices via websockets as in the below lovelace card but I’m not having any success so far.