Node-red-contrib-home-assistant-websocket

@Kermit would it make sense to have something like dev-state node, sometimes testing flows i need values of sensor to move around before waiting for a change, so i usually have to go to the ha panel, find the entity_id and set the state to see how it goes

Looks like there is something similar but not maintained any more under new auth methods

In your Turn on TV call-service node change the Output Location to None or some other property if you want to use the output later in the flow. This will stop the first call-service node from overwriting the second one.

I have notes written up for a “dev-state” node but haven’t fleshed it out. Can’t decided whether to keep it simple, i.e. just a URL and JSON string or make a full UI for all the missing URLs that the current nodes don’t touch for the HTTP and websocket API.

Currently, you could just use an HTTP request node to do this now. This is untested but should be pretty close.

[{"id":"4c695472.482f5c","type":"inject","z":"ffbd7f06.4a014","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":176,"y":528,"wires":[["b73c1dc7.e523c"]]},{"id":"91351050.598ea","type":"http request","z":"ffbd7f06.4a014","name":"","method":"POST","ret":"txt","url":"http://localhost:8123/api/states/<entity_id>","tls":"","x":454,"y":528,"wires":[["47b04928.5a7998"]]},{"id":"b73c1dc7.e523c","type":"function","z":"ffbd7f06.4a014","name":"","func":"const LongLivedAccessToken = \"jalfjalsfaslfjlsafj\";\nmsg.headers = {\"Authorization\": `Bearer ${LongLivedAccessToken}`};\nmsg.payload = {\n    \"state\": \"custom_state\",\n    \"attributes\": {\n        \"attr1\":\"value1\",\n        \"attr2\":\"value2\"\n    }\n};\nreturn msg;","outputs":1,"noerr":0,"x":306,"y":528,"wires":[["91351050.598ea"]]},{"id":"47b04928.5a7998","type":"debug","z":"ffbd7f06.4a014","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":614,"y":528,"wires":[]}]

Perfetc, thx, it works. But still I thinik that if I put something in node editbox, these info have to subscribe any incoming payload.

Yes I though about just wrapping it in a http subflow for general use.

Thanks

EDIT: Nevermind - I restarted the node-red container and autocomplete is working now. Thank you for the awesome WS implementation!

I’m on v0.7.0 and autocomplete isn’t working. Everything in the automations shows connected and the automations themselves work.
I have an https server, a legacy API key, and the cert doesn’t match the internal IP address I’m using for node-red, so I also have the “ignore invalid certs” box checked.

Any thoughts?

Quick question, does node-red need to be running on the same machine that it running HA, or can I use Node-Red on another machine on the same network to Access HA when using this node?

it can be on a different machine. The URL that HA runs on needs to be accessible from whatever machine you’re running node-red from.

I have my NR running on a rPi3, and my HA running on an old netbook-style laptop (barely more powerful than the pi). I had everything running on the pi, but it was getting sluggish, and I was concerned about the HA read/write cycles on the SD card. The netbook is still a bit sluggish, so ultimately I’d like to move everything to a more powerful server once I find some extra coin.

I’m running Node-Red on a dedicated RPi and experience much better responses

Hi kermit, I “push” for this thing, 'cause otherwise in most chase you have to check current state before use wait until node…

This feature is pushed to Github but currently don’t plan on pushing out a new version for a bit.

@Kermit Just upgraded my RPi to v0.7.1 and the sever is not connecting.

v0.7.0 was.

ScreenShot_20190213100107
Any help please.

What do the logs show at startup?

  • Node Red Version?
  • Is Node Red running in Docker? [e.g. yes/no/hassio]

Hi Kermit

Node-RED version: v0.19.5
and yes its in a docker.

Welcome to Node-RED

13 Feb 21:03:03 - [info] Node-RED version: v0.19.5

13 Feb 21:03:03 - [info] Node.js version: v8.1.3

13 Feb 21:03:03 - [info] Linux 4.14.79-v7+ arm LE

13 Feb 21:03:04 - [info] Loading palette nodes

13 Feb 21:03:09 - [info] Dashboard version 2.13.2 started at /ui

13 Feb 21:03:10 - [warn] ------------------------------------------------------

13 Feb 21:03:10 - [warn] [node-red-contrib-home-assistant-websocket/server] Error: Cannot find module ‘home-assistant-js-websocket’

13 Feb 21:03:10 - [warn] ------------------------------------------------------

13 Feb 21:03:10 - [info] Settings file : /data/settings.js

13 Feb 21:03:10 - [info] Context store : ‘default’ [module=memory]

13 Feb 21:03:10 - [info] User directory : /data

13 Feb 21:03:10 - [warn] Projects disabled : editorTheme.projects.enabled=false

13 Feb 21:03:10 - [info] Flows file : /data/flows.json

13 Feb 21:03:10 - [info] Server now running at http://127.0.0.1:1880/

13 Feb 21:03:10 - [warn]

13 Feb 21:03:10 - [error] [server-state-changed:197d0a6b.5cb5a6] TypeError: Cannot read property ‘addListener’ of undefined

at ServerStateChangedNode.addEventClientListener (/data/node_modules/node-red-contrib-home-assistant-websocket/lib/events-node.js:40:26)


at ServerStateChangedNode.EventsNode (/data/node_modules/node-red-contrib-home-assistant-websocket/lib/events-node.js:18:14)

at ServerStateChangedNode (/data/node_modules/node-red-contrib-home-assistant-websocket/nodes/events-state-changed/events-state-changed.js:29:13)

at createNode (/usr/src/node-red/node_modules/node-red/red/runtime/nodes/flows/Flow.js:305:18)

at Flow.start (/usr/src/node-red/node_modules/node-red/red/runtime/nodes/flows/Flow.js:89:35)

at start (/usr/src/node-red/node_modules/node-red/red/runtime/nodes/flows/index.js:328:29)

at tryCatchReject (/usr/src/node-red/node_modules/when/lib/makePromise.js:845:30)

at runContinuation1 (/usr/src/node-red/node_modules/when/lib/makePromise.js:804:4)

at Fulfilled.when (/usr/src/node-red/node_modules/when/lib/makePromise.js:592:4)

at Pending.run (/usr/src/node-red/node_modules/when/lib/makePromise.js:483:13)

forgive me if this has already been asked, but…

does the HA palette allow for a snapshot of current states? like i wanna feed it a list of entities and get all their current states, save that to a json mqtt, change those entities to whatever, then sometime later, grab it all from mqtt and then restore those entity states.

ie: trigger away event, it captures all the current states, saves them, turns everything off, then when i return, triggers the home event, reads them, restores everything to those saved states.

This really has more to do with your docker install than the module because it’s failing to install home-assistant-js-websocket. I would recommend trying to either login into your docker container and manually installing it or try rebuilding the container.

The get-entities node would allow you to grab all the current states from a list but you would have to do some data manipulation to set them all back to that state after.

I have uninstalled and then rebooted node red and then reinstalled it and its all working again

Thanks @Kermit

Thank you, after sorting out my access token it works well, thanks very much for this package. :slight_smile: