Node-RED google home integration

Just sharing.

For anyone who is using lights that use 0,255,brightness as the inputs/outputs and want to use "Send/receive complete state" set to on, here are subflows I put together to convert between a complete state object and a 0,255,brightness level depending on if Off/On/Change in Brightness is received from NORA (or vice versa on the input).

Here is a post-NORA node (Note: my interface to HomeSeer requires strings so if you need numbers you might need to make a change to the change nodes to use numbers and not strings) :

[{"id":"d6132d2d.a892c","type":"subflow","name":"NORA - Post","info":"","category":"","in":[{"x":80,"y":180,"wires":[{"id":"116868a0.ec08b7"}]}],"out":[{"x":780,"y":180,"wires":[{"id":"19aaafe8.1c9cc","port":0},{"id":"2af74ff0.26cc9","port":0},{"id":"4f2a09b0.731858","port":0}]}]},{"id":"116868a0.ec08b7","type":"switch","z":"d6132d2d.a892c","name":"On/Off","property":"payload.on","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":210,"y":180,"wires":[["faafcfc6.f2528"],["4f2a09b0.731858"]]},{"id":"4f2a09b0.731858","type":"change","z":"d6132d2d.a892c","name":"Off","rules":[{"t":"set","p":"onPrevious","pt":"flow","to":"payload.on","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":220,"wires":[[]]},{"id":"faafcfc6.f2528","type":"switch","z":"d6132d2d.a892c","name":"onPrevious","property":"onPrevious","propertyType":"flow","rules":[{"t":"true"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":390,"y":160,"wires":[["19aaafe8.1c9cc"],["2af74ff0.26cc9"]]},{"id":"2af74ff0.26cc9","type":"change","z":"d6132d2d.a892c","name":"Last","rules":[{"t":"set","p":"onPrevious","pt":"flow","to":"payload.on","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"255","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":180,"wires":[[]]},{"id":"19aaafe8.1c9cc","type":"change","z":"d6132d2d.a892c","name":"Brightness","rules":[{"t":"set","p":"onPrevious","pt":"flow","to":"payload.on","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"payload.brightness","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":140,"wires":[[]]}]

Here is a pre-NORA node (Note: The function is in there to convert the string I get to a number for NORA):

image

[{"id":"6ee85fdd.12c49","type":"subflow","name":"NORA - Pre","info":"","category":"","in":[{"x":80,"y":100,"wires":[{"id":"23f7c1.3972f84"}]}],"out":[{"x":700,"y":100,"wires":[{"id":"43c4e555.32564c","port":0},{"id":"3a7f55a3.65e3da","port":0},{"id":"cc707d6c.fbe7e","port":0}]}]},{"id":"385c570d.c4a378","type":"switch","z":"6ee85fdd.12c49","name":"Status","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"255","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":370,"y":100,"wires":[["43c4e555.32564c"],["3a7f55a3.65e3da"],["cc707d6c.fbe7e"]]},{"id":"43c4e555.32564c","type":"change","z":"6ee85fdd.12c49","name":"Off","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload.on","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":60,"wires":[[]]},{"id":"3a7f55a3.65e3da","type":"change","z":"6ee85fdd.12c49","name":"On","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload.on","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":100,"wires":[[]]},{"id":"cc707d6c.fbe7e","type":"change","z":"6ee85fdd.12c49","name":"Brightness","rules":[{"t":"set","p":"brightnessPrevious","pt":"flow","to":"payload","tot":"msg"},{"t":"move","p":"payload","pt":"msg","to":"payload.brightness","tot":"msg"},{"t":"set","p":"payload.on","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":140,"wires":[[]]},{"id":"23f7c1.3972f84","type":"function","z":"6ee85fdd.12c49","name":"toNumber","func":"msg.payload = parseInt(msg.payload,10);\nreturn msg;","outputs":1,"noerr":0,"x":200,"y":100,"wires":[["385c570d.c4a378"]]}]

Edit: Note that you might need to set an initial brightness from your device for the input flow to work correctly.

Edit: Updated the Pre-subnode to remove the Brightness setting for on/off status..