HS-WD200+ Scene Automation using NodeRED

I’m currently switching from OpenHAB to Home Assistant. In both systems I’m using NodeRED for as much of the logic processing as I can. OpenHAB has items that are the equivalent of entities in Hass. OpenHAB creates an item for each device called “scene number”. When a scene is chosen (double tap HS-WD200+) that scene code is populated in the item/entity. It can then be used like any other item/entity as part of the device. For automation of scenes, I’m currently pulling from the event bus.

Question: Is this an efficient and recommended practice? Will I have performance issues and is there a better way to do this in HAss?

[{"id":"f81d9522b7c69c70","type":"tab","label":"Scenes","disabled":false,"info":"","env":[]},{"id":"56f2b223fa91818a","type":"server-events","z":"f81d9522b7c69c70","name":"","server":"4bfe0967.742368","version":1,"event_type":"zwave_js_value_notification","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"$outputData(\"eventData\").event_type","valueType":"jsonata"}],"x":180,"y":80,"wires":[["e002696701270e8b"]]},{"id":"2053040cfaddb1f4","type":"switch","z":"f81d9522b7c69c70","name":"Office Dimmer Scene","property":"node_id","propertyType":"msg","rules":[{"t":"eq","v":"26","vt":"str"},{"t":"eq","v":"24","vt":"str"},{"t":"eq","v":"45","vt":"str"},{"t":"eq","v":"19","vt":"str"},{"t":"eq","v":"49","vt":"str"},{"t":"eq","v":"60","vt":"str"}],"checkall":"true","repair":false,"outputs":6,"x":160,"y":240,"wires":[["d584f9eac3eea739"],["11ea54aa9307223a"],["11ea54aa9307223a"],["eaa4514a8c5ea69d"],["78fc3cc239d28a4c"],["78fc3cc239d28a4c"]]},{"id":"e002696701270e8b","type":"function","z":"f81d9522b7c69c70","name":"Convert msg.payload","func":"var service = msg.payload.event.property_key.substr(2,1)\n\nmsg.node_id = msg.payload.event.node_id;\nmsg.scence = msg.payload.event.value_raw;\n\ndelete msg.payload;\ndelete msg.topic;\n\nif (service == 1) {\n    msg.payload= { \"service\": \"turn_\" + \"on\" };\n} else {\n    msg.payload= { \"service\": \"turn_\" + \"off\" };\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":160,"y":140,"wires":[["2053040cfaddb1f4","4be589d640e65b9b"]]},{"id":"11ea54aa9307223a","type":"switch","z":"f81d9522b7c69c70","name":"Node 27 & 45","property":"scence","propertyType":"msg","rules":[{"t":"eq","v":"3","vt":"str"},{"t":"eq","v":"4","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":460,"y":200,"wires":[["637a2e5639827b73"],["a1a8966e3c4feb66"]]},{"id":"d584f9eac3eea739","type":"api-call-service","z":"f81d9522b7c69c70","name":"Hallway Light","server":"4bfe0967.742368","version":3,"debugenabled":false,"service_domain":"light","service":"","entityId":"light.dimmer_hallway_d","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":450,"y":140,"wires":[[]]},{"id":"637a2e5639827b73","type":"api-call-service","z":"f81d9522b7c69c70","name":"Livingroom Switchs","server":"4bfe0967.742368","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.outlet_livingroom_u_couch, switch.outlet_livingroom_u_tv","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":670,"y":180,"wires":[[]]},{"id":"09a138bc3671313e","type":"comment","z":"f81d9522b7c69c70","name":"HS-WD200+ Scene Codes","info":"up \t= 1.0\t    | down     \t\t= 2.0\n\nup up_hold  = 1.1   | down down_hold    = 2.1\nup_hold     = 1.2\t| down_hold    \t    = 2.2\nup_2x \t    = 1.3\t| down_2x       \t= 2.3\nup_3x \t    = 1.4\t| down_3x    \t    = 2.4\nup_4x \t    = 1.5\t| down_4x    \t    = 2.5\nup_5x \t    = 1.6\t| down_5x    \t    = 2.6","x":150,"y":40,"wires":[]},{"id":"eaa4514a8c5ea69d","type":"api-call-service","z":"f81d9522b7c69c70","name":"MBR Nightstand Lights","server":"4bfe0967.742368","version":3,"debugenabled":false,"service_domain":"Switch","service":"","entityId":"switch.outlet_mbed_jeff, switch.outlet_mbed_lili","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":480,"y":260,"wires":[[]]},{"id":"78fc3cc239d28a4c","type":"api-call-service","z":"f81d9522b7c69c70","d":true,"name":"Attic Light","server":"4bfe0967.742368","version":3,"debugenabled":false,"service_domain":"switch","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":440,"y":300,"wires":[[]]},{"id":"4be589d640e65b9b","type":"debug","z":"f81d9522b7c69c70","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":430,"y":80,"wires":[]},{"id":"a1a8966e3c4feb66","type":"api-call-service","z":"f81d9522b7c69c70","name":"Mirror","server":"4bfe0967.742368","version":3,"debugenabled":false,"service_domain":"switch","service":"","entityId":"switch.outlet_livingroom_u_mirror","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":630,"y":220,"wires":[[]]},{"id":"4bfe0967.742368","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":true,"heartbeatInterval":"30"}]

Event all nodes can use a lot of resources so it’s best to use them only when needed. Typically you would use a switch right after with the specific message path you’re listening for. The function node does the same but I believe using a function as a filter uses more resources that a switch.

I don’t use zwave but I do think that you need an event all for that. However if this is a entity and the change occurs in an attribute and not the state. You can set an event state to catch an attribute change by unchecking Current state equals previous state

So if I understand you; you are an advocate of the approach but you think there could be some potential efficiencies I should be considered. Thank you…

1 Like