Node Red Experiences

Thanks, this was the solution :slight_smile:
Sometimes its so easy

I am currently thinking of realizing my heat-automation and turn off heating if there is an open window via node-red, are there any examples you might share? Thanks in advance!

Hi.

See this example. It checks if heaters are on if window opens. Then switch’s on a binary switch and switch off heater. When window closes checks the binary switch and if on then switches on the heater.

The origin of window opening closing is through deconz but you can do it with an event node the same.

Hope it helps.

Sergi

[{"id":"4a674376.8a859c","type":"tab","label":"Finestres","disabled":false,"info":""},{"id":"9240cca9.ba311","type":"websocket in","z":"4a674376.8a859c","name":"deCONZ","server":"78b22e98.639","client":"","x":100,"y":480,"wires":[["b488ce81.18e5d8"]]},{"id":"b488ce81.18e5d8","type":"json","z":"4a674376.8a859c","name":"","property":"payload","action":"","pretty":false,"x":267.5,"y":488,"wires":[["47494934.054e38"]]},{"id":"47494934.054e38","type":"switch","z":"4a674376.8a859c","name":"Sensor?","property":"payload.id","propertyType":"msg","rules":[{"t":"eq","v":"32","vt":"str"},{"t":"eq","v":"30","vt":"str"},{"t":"eq","v":"34","vt":"str"},{"t":"eq","v":"25","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":407.5,"y":488,"wires":[["5e662efc.2fba8"],["d7b87155.766268"],["2cefef91.0de648"],["186260b7.f72e6f"]]},{"id":"5e662efc.2fba8","type":"switch","z":"4a674376.8a859c","name":"Open/Close","property":"payload.state.open","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":676.5,"y":172,"wires":[["46dc942c.4db174"],["c3a56977.1754a"]]},{"id":"d7b87155.766268","type":"switch","z":"4a674376.8a859c","name":"Open/Close","property":"payload.state.open","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":661,"y":372,"wires":[["8906b345.5d7978"],["77f49d80.da598c"]]},{"id":"2cefef91.0de648","type":"switch","z":"4a674376.8a859c","name":"Open/Close","property":"payload.state.open","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":651,"y":590,"wires":[["29c80284.d9041e"],["b4b2fabe.cc91f8"]]},{"id":"46dc942c.4db174","type":"api-current-state","z":"4a674376.8a859c","name":"clim des on?","server":"870a94be.a26df8","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"climate.despatx","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":850.5,"y":122,"wires":[["718121b6.a12368","3f65502e.3b8e38"],[]]},{"id":"718121b6.a12368","type":"api-call-service","z":"4a674376.8a859c","name":"Apaga Cal Despatx","server":"870a94be.a26df8","service_domain":"climate","service":"set_operation_mode","data":"{\"entity_id\":\"climate.despatx\",\"operation_mode\":\"off\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1044.5,"y":87,"wires":[[]]},{"id":"3f65502e.3b8e38","type":"api-call-service","z":"4a674376.8a859c","name":"Activa control Desp","server":"870a94be.a26df8","service_domain":"input_boolean","service":"turn_on","data":"{\"entity_id\":\"input_boolean.escriptori\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1043.5,"y":135,"wires":[[]]},{"id":"c3a56977.1754a","type":"api-current-state","z":"4a674376.8a859c","name":"cont des on?","server":"870a94be.a26df8","version":"1","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"input_boolean.escriptori","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":849,"y":216,"wires":[["56dd297.7eb3b58","507018b2.c932f8"],[]]},{"id":"507018b2.c932f8","type":"api-call-service","z":"4a674376.8a859c","name":"Apaga control Desp","server":"870a94be.a26df8","service_domain":"input_boolean","service":"turn_off","data":"{\"entity_id\":\"input_boolean.escriptori\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1050,"y":227,"wires":[[]]},{"id":"56dd297.7eb3b58","type":"api-call-service","z":"4a674376.8a859c","name":"Encen Cal Despatx","server":"870a94be.a26df8","service_domain":"climate","service":"set_operation_mode","data":"{\"entity_id\":\"climate.despatx\",\"operation_mode\":\"heat\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1045,"y":186,"wires":[[]]},{"id":"8906b345.5d7978","type":"api-current-state","z":"4a674376.8a859c","name":"clim men on?","server":"870a94be.a26df8","version":"1","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"climate.menjador_out","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":850,"y":317,"wires":[["4bd37bc6.68b57c","b02db752.38fa28","e4890723.e02f68"],[]]},{"id":"4bd37bc6.68b57c","type":"api-call-service","z":"4a674376.8a859c","name":"Apaga Cal Menout","server":"870a94be.a26df8","service_domain":"climate","service":"set_operation_mode","data":"{\"entity_id\":\"climate.menjador_out\",\"operation_mode\":\"off\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1046,"y":276,"wires":[[]]},{"id":"e4890723.e02f68","type":"api-call-service","z":"4a674376.8a859c","name":"Activa control Menj","server":"870a94be.a26df8","service_domain":"input_boolean","service":"turn_on","data":"{\"entity_id\":\"input_boolean.menjador\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1046,"y":355,"wires":[[]]},{"id":"77f49d80.da598c","type":"api-current-state","z":"4a674376.8a859c","name":"cont men on?","server":"870a94be.a26df8","version":"1","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"input_boolean.menjador","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":845.5,"y":428,"wires":[["1f0e9a74.4c1cf6","81b38ac3.e393d8","a389ba55.9496e"],[]]},{"id":"a389ba55.9496e","type":"api-call-service","z":"4a674376.8a859c","name":"Apaga control Menj","server":"870a94be.a26df8","service_domain":"input_boolean","service":"turn_off","data":"{\"entity_id\":\"input_boolean.menjador\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1045.5,"y":474,"wires":[[]]},{"id":"b02db752.38fa28","type":"api-call-service","z":"4a674376.8a859c","name":"Apaga Cal Menout","server":"870a94be.a26df8","service_domain":"climate","service":"set_operation_mode","data":"{\"entity_id\":\"climate.menjador_in\",\"operation_mode\":\"off\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1046,"y":316,"wires":[[]]},{"id":"1f0e9a74.4c1cf6","type":"api-call-service","z":"4a674376.8a859c","name":"Encen Cal Menout","server":"870a94be.a26df8","service_domain":"climate","service":"set_operation_mode","data":"{\"entity_id\":\"climate.menjador_out\",\"operation_mode\":\"heat\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1045,"y":393,"wires":[[]]},{"id":"81b38ac3.e393d8","type":"api-call-service","z":"4a674376.8a859c","name":"Encen Cal Menout","server":"870a94be.a26df8","service_domain":"climate","service":"set_operation_mode","data":"{\"entity_id\":\"climate.menjador_in\",\"operation_mode\":\"heat\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1045,"y":433,"wires":[[]]},{"id":"29c80284.d9041e","type":"api-current-state","z":"4a674376.8a859c","name":"clim dorm on?","server":"870a94be.a26df8","version":"1","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"climate.dormitori","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":833,"y":552,"wires":[["71703c2c.708954","aaec671.a316418"],[]]},{"id":"71703c2c.708954","type":"api-call-service","z":"4a674376.8a859c","name":"Apaga Cal Dorm","server":"870a94be.a26df8","service_domain":"climate","service":"set_operation_mode","data":"{\"entity_id\":\"climate.dormitori\",\"operation_mode\":\"off\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1031,"y":517,"wires":[[]]},{"id":"aaec671.a316418","type":"api-call-service","z":"4a674376.8a859c","name":"Activa control Dorm","server":"870a94be.a26df8","service_domain":"input_boolean","service":"turn_on","data":"{\"entity_id\":\"input_boolean.dormitori\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1050,"y":565,"wires":[[]]},{"id":"b4b2fabe.cc91f8","type":"api-current-state","z":"4a674376.8a859c","name":"cont dorm on?","server":"870a94be.a26df8","version":"1","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"input_boolean.dormitori","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":831.5,"y":640,"wires":[["80d7d8c7.1730e","d475c562.ffb428"],[]]},{"id":"d475c562.ffb428","type":"api-call-service","z":"4a674376.8a859c","name":"Apaga control Dorm","server":"870a94be.a26df8","service_domain":"input_boolean","service":"turn_off","data":"{\"entity_id\":\"input_boolean.dormitori\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1046.5,"y":657,"wires":[[]]},{"id":"80d7d8c7.1730e","type":"api-call-service","z":"4a674376.8a859c","name":"Encen Cal Dorm","server":"870a94be.a26df8","service_domain":"climate","service":"set_operation_mode","data":"{\"entity_id\":\"climate.dormitori\",\"operation_mode\":\"heat\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1031.5,"y":616,"wires":[[]]},{"id":"186260b7.f72e6f","type":"switch","z":"4a674376.8a859c","name":"Open/Close","property":"payload.state.open","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":660,"y":768,"wires":[["e4a4b0ae.c8dc8"],["6b609c26.442ed4"]]},{"id":"e4a4b0ae.c8dc8","type":"api-current-state","z":"4a674376.8a859c","name":"clim Magat on?","server":"870a94be.a26df8","version":"1","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"climate.magatzem","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":842,"y":730,"wires":[["d7586057.6643c","aeef073a.78ad08"],[]]},{"id":"d7586057.6643c","type":"api-call-service","z":"4a674376.8a859c","name":"Apaga Magat Dorm","server":"870a94be.a26df8","service_domain":"climate","service":"set_operation_mode","data":"{\"entity_id\":\"climate.magatzem\",\"operation_mode\":\"off\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1050,"y":695,"wires":[[]]},{"id":"aeef073a.78ad08","type":"api-call-service","z":"4a674376.8a859c","name":"Activa control Magat","server":"870a94be.a26df8","service_domain":"input_boolean","service":"turn_on","data":"{\"entity_id\":\"input_boolean.magatzem\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1059,"y":743,"wires":[[]]},{"id":"6b609c26.442ed4","type":"api-current-state","z":"4a674376.8a859c","name":"cont Magat on?","server":"870a94be.a26df8","version":"1","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"input_boolean.magatzem","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":840.5,"y":818,"wires":[["e3c0edc7.f2047","6b4a935e.1f8a9c"],[]]},{"id":"6b4a935e.1f8a9c","type":"api-call-service","z":"4a674376.8a859c","name":"Apaga control Magat","server":"870a94be.a26df8","service_domain":"input_boolean","service":"turn_off","data":"{\"entity_id\":\"input_boolean.magatzem\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1055.5,"y":835,"wires":[[]]},{"id":"e3c0edc7.f2047","type":"api-call-service","z":"4a674376.8a859c","name":"Encen Cal Magat","server":"870a94be.a26df8","service_domain":"climate","service":"set_operation_mode","data":"{\"entity_id\":\"climate.magatzem\",\"operation_mode\":\"heat\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1050.5,"y":794,"wires":[[]]},{"id":"8967c1bd.889d2","type":"debug","z":"4a674376.8a859c","name":"0","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":300,"y":360,"wires":[]},{"id":"793ed0bd.b39b8","type":"debug","z":"4a674376.8a859c","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":360,"y":620,"wires":[]},{"id":"78b22e98.639","type":"websocket-listener","z":"","path":"ws://192.168.0.12:40860","wholemsg":"false"},{"id":"870a94be.a26df8","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]

thanks for sharing!

Hi,
I’m trying to use this but I have no idea how to get the state of my aqara switches connected by deconz. I only ever used events, which you explain in the flow are unsuitable. Can you give me any hint here?

since yesterday, the current node does not give numerical values.
if I pass a value from a sensor it gives Nan output. can it be solved in some way?
I believe i’ve update some palette in Node Red

There is a bug with the 0.22.0 version of the Home Assistant websocket node. The author put out a patch yesterday afternoon (0.22.1) that should fix this, but I have not tested it yet. You should be able to update this in the pallete manager.

I had this problem - I run my own node-red in docker not under the control of HA.

The upgrade did not fix this for me. I have implemented a “fix”, which works for me, which is to create a new HA server with the same Base URL and Access Token (effectively an identical version of the not-working one) and go through my HA nodes in node-red (a real PITA!!!) and switch them to use the “new” Ha server node!

So far, so good.

Sorry. Forget that. Too hasty in posting. After a short time, the same nodes that had the problem revert from (for example) state “heat” or state “home” to “NaN” again.

So this was NOT a fix after all.

bikefright

I reverted to version 0.20.2 of the HA websocket module via the CLI in my docker container as follows:

docker container exec -u 0 -it nodered bash
cd /data
npm install [email protected]

I then restarted my node-red container via portainer and all is good in the world again…and has been for over an hour :slight_smile:

bikefright.

Just got to say Node Red has been a revolution to me. As I tried to make more complex automations with multiple conditions I found YAML and the automation config extremely confusing. I have no idea where the contributors are going with the config GUI but I think the current direction is wrong. It needs to be more visual, which Node Red is.

You can do this without even going into the Docker container. For me, I map everything to /srv/docker. So Node Red is in /srv/docker/nodered. Then I do exactly what you stated above

cd /srv/docker/nodered
npm install node-red-contrib-home-assistant-websocket@<version>

same problem. also there is the issue

are you in hassio?

@matteos1 No.

I run my own node-red docker container, not the hassio add-on. I think that is what you are asking.

bikefright.

yes i installed hassio i’like to repair my insallation of current state returning on previous version but I don’t know how…

I’m not 100% sure how to do this.

I would reach out to frenck again via the github issue (I see you already raised an issue there) and reference the open issue on the node-red-contrib-home-assistant-websocket github node-red-contrib-home-assistant-websocket

Ask the specific question: “Is it possible to downgrade the HA websocket module within my node-red container installed from the add-on store? If so, how?”

bikefright.

1 Like

Sorry Matteo, I meant for you to either reopen your closed issue on github here: hassio node-red addon where frenck had already responded to you, or better still, raise a new issue but be specific about the need to downgrade.

I know you can specify modules to install within the hassio plugin on it’s addon configuration page, under the “npm-packages:” section, but what I don’t know is if you can specify a specific version of a module (like you can when using the CLI with an “npm install x@y” command).

I’ve just seen Jason respond that he believes the node-red modules are built in on the fly whenever you start/restart the hassio addon, so perhaps you could try specifying a version of the module in the addon config?

Look for the “npm_packages:” section of the addon config and add the following line so it looks like this:


npm_packages:
  - node-red-admin
  - [email protected]
  - any other packages already in the list

Restart the addon and check the node red palette to see if a) node-red starts? b) if it does, did it observe the specified version?

I strongly suspect however that the HA websocket module is installed under the covers and don’t know how the above config would compete/interact with a list of user specified modules to include upon restart - which will win? System or user? I don’t know!

Worst case you: stop the addon, remove the line from the addon config and restart the addon. You should be no worse off than you are now.

bikefright

I found that by updating from the manage palette to the latest version of node-red-contrib-home-assistant-websocket, the current state node does not give exact values. I was wondering if there was a way for a way to downgrade the node-red-contrib-home-assistant-websocket dLL version 0.22.1 to version 0.21.5, which is the latest working version.
Of course, node red is a hassio add-on

Many thanks to this code. Very helpful for something that I could not do by myself. It works nicely alone, but when I integrate it to my other nodes (single touch, double touch), it interfers.
I believe that this happens because your code reacts to a single touch and it is over my knowledge correct this behavior (I tryed many things). Can you give some direction in order to the code react only for long pressing?
Only using your code, a single and fast press is enough for turning the light on, when it should react only when long pressing.
Thanks!

Glad you’re finding it helpful :slight_smile: Sorry for the delay in answering.

Here is an updated export: https://hastebin.com/awojujayiv.json

The input to Format Msg should be the long press hold and long press release events:

You can see in the image above that I’m listening to deconz_event, then filtering on msg.payload.event.id = bathroom_switch (in this case) then sending that to a switch node containing the switch values:

The reason that it’s is important to send both the long hold/release values to the format msg and dimming subflows is because they are transformed into on/off values that control the gate that starts/stops the dimming.