Hi all, I’ve got a problem. I have a switch that emits a code value when pressed, let’s say “a”; I want to use it to turn a light on and off, let’s say the on command is “b” and the off command is “c”. I have no problem controlling the on/off light separately in HA and in Node-RED, now it’s the status feedback that’s hitting a problem. I switch the light on and off in Node-RED and it’s status is feedback to HA; when I switch the light off in HA, I reset the counter in Node-RED and it works fine. Now the problem is that when I turn on the light in HA, its state is not feedback to Node-RED, how can I set it so that its state is feedback to Node-RED properly? The code is below:
[{"id":"291a50771bcce177","type":"server-state-changed","z":"9181291559b8dc27","name":"light3","server":"f7c43d95.90a6d","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.light3","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":130,"y":300,"wires":[["b9c77c67bf505473"]]},{"id":"b9c77c67bf505473","type":"switch","z":"9181291559b8dc27","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":300,"wires":[["d59c6de9c4db92c5"],["3d3f65202e0733f6","c63f0340.f2ce7"]]},{"id":"d59c6de9c4db92c5","type":"function","z":"9181291559b8dc27","name":"light3_on","func":"msg.payload = \"b\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":280,"wires":[[]]},{"id":"3d3f65202e0733f6","type":"function","z":"9181291559b8dc27","name":"light3_off","func":"msg.payload = \"c\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":340,"wires":[[]]},{"id":"58d816b8.3f26f8","type":"counter","z":"9181291559b8dc27","name":"","init":"0","step":"1","lower":null,"upper":null,"mode":"increment","outputs":1,"x":300,"y":420,"wires":[["eb3583b1.0a3a8"]]},{"id":"eb3583b1.0a3a8","type":"switch","z":"9181291559b8dc27","name":"iteration","property":"count","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":460,"y":420,"wires":[["6f7bb0bb2a05c848"],["c63f0340.f2ce7","f9dbeac1fbf14e4c"]]},{"id":"c63f0340.f2ce7","type":"change","z":"9181291559b8dc27","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":500,"wires":[["58d816b8.3f26f8"]]},{"id":"6f7bb0bb2a05c848","type":"function","z":"9181291559b8dc27","name":"light3_on","func":"msg.payload = \"b\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":400,"wires":[["758ac0bffd9b0d6d"]]},{"id":"f9dbeac1fbf14e4c","type":"function","z":"9181291559b8dc27","name":"light3_off","func":"msg.payload = \"c\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":440,"wires":[["4f6d870978954736"]]},{"id":"758ac0bffd9b0d6d","type":"api-call-service","z":"9181291559b8dc27","name":"light3_on","server":"f7c43d95.90a6d","version":3,"debugenabled":false,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.light3","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":780,"y":380,"wires":[[]]},{"id":"4f6d870978954736","type":"api-call-service","z":"9181291559b8dc27","name":"light3_off","server":"f7c43d95.90a6d","version":3,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.light3","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":780,"y":460,"wires":[[]]},{"id":"e2846b141a76e5a6","type":"switch","z":"9181291559b8dc27","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"a","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":130,"y":420,"wires":[["58d816b8.3f26f8"]]},{"id":"a40ee56016247a3f","type":"inject","z":"9181291559b8dc27","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":360,"wires":[["e2846b141a76e5a6"]]},{"id":"f7c43d95.90a6d","type":"server","name":"Home Assistant","version":1,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
Any help would be greatly appreciated!