Node-red. How would you program a bathroom contact light sensor

Well, I use motion sensors that are not Hubitat-compatible. So I cannot recommend them. But there are several zigbee sensors that work well with Hubitat. Like the Iris V2 and V3 sensors, the SmartThings/Aeotec sensors, and the NYCE sensors.

1 Like

How about sonoff https://www.amazon.com/Wireless-Detector-Required-Batteries-Included/dp/B08BFFJ69V/ref=sr_1_3?dchild=1&keywords=Zigbee%2Bmotion%2Bsensor&qid=1622304869&sr=8-3&th=1

@SmartHomePrimer just noted they work well when they are close to Hubitat, but not so well otherwise.

I use 2 Iris V3 motion sensors only because the way my bathroom dimensions cannot be positioned for just one sensor to not false trigger by someone walking by the bathroom door instead of detecting when someone actually walks "into" the bathroom, at the same time the position of the one motion sensor that triggers the entrance to the bathroom can't detect presence while you are in the bathroom so the second sensor is needed. Both humidity reading from these are used to activate the vent fan when the humidity is above 60%. The vent fan shuts off once the door is open AND the humidity is below 60%.

The lights are triggered off when both sensors have been inactive for 15 seconds OR when the contact sensor on the door opens. The contact sensor closed also operates the vent fan.

1 Like

NYCE ceiling motion sensor is great for bathrooms. Very discrete, doesn’t flash when it detects movement (which could freak someone out in a bathroom if they think it’s a camera or something). And it has temp plus humidity sensors too. Well worth the price.

But they’re not easy to find these days.

1 Like

They are only $12 too

2 Likes

Just got 10 more of them yesterday, seller will take $10 each if you buy 10 of them.

1 Like

Is the 2 sensors per room hard? Also do they light up when motion is detected?

I believe the Iris v3 sensors do. The V2 sensors definitely do. Usually possible to place them discretely enough that the risk of a guest accusing you of being a peeping Tom is probably extremely low :scream:. It’s also probably possible to cover or disable the LED that flashes inside the device (if you open it up, I did once with a V2 sensor I used in my bedroom but decided it wasn’t worth the hassle to actually disable the LED).

1 Like

The V2's the whole motion "bulb" as I call it blinks when motion is detected. The V3's have a small little green led that blinks on them.

2 Likes

Ok thx

That’s a fresnel lens, which is what gives the sensor its “field of view.” There’s an LED inside on the pcb that shines through when it flashes.

Do you know the motion timeout on the iris?

V2 20-30 seconds, AFAIK V3 is similar.

Are you sure you always want the light to come on in the bathroom when you enter? If the bathroom has a window (mine has three windows), there is enough light during the daytime that I do not need to turn on the lights. If my wife or I wake up in the middle of the night to go to the bathroom, we do not want the main lights turning on. I have a small nightlight controlled by a light sensor set up to provide enough light to use the toilet in the middle of the night when eyes have grown accustomed to the dark.

Because of these things, I do not have any automations on the main lights.

I do have a motion sensor on the lights in my laundry room so if you enter either from the garage or the house, the lights come on automatically and stay on a preset time. However, that might not work in the bathroom if you take long showers.

Thus, before designing any automation for the bathroom, make sure you list all the possible uses (including timing).

here are a couple examples for you. These are two of my bathrooms. one with two motion sensors, and one with only one. I have contact sensors on the doors also. If the door is open the timeout is very short, if the door is closed, then the fan comes on and the timeout is much longer, in order to account for less movement or visibility (on toilet or shower). If the lights turn out on me, it means I should probably stop reading forum posts and get off the pot!

Flow

‘’’

[{"id":"5b27ad0.730cdd4","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"1e101ad6.d58445","type":"hubitat device","z":"5b27ad0.730cdd4","name":"Motion Sensor - Mud Room Bathroom","server":"319c6842.9a57d8","deviceId":"426","attribute":"motion","sendEvent":true,"x":303,"y":289,"wires":[["22c7000.7b4c08","a9221931.e3bfe","3c7c7417.36990c","fdc49ec6.436ca"]]},{"id":"c9531a35.a85ff8","type":"hubitat device","z":"5b27ad0.730cdd4","name":"Contact Sensor - Mud Room Bathroom Door","server":"319c6842.9a57d8","deviceId":"1462","attribute":"contact","sendEvent":true,"x":323,"y":340,"wires":[["fdc49ec6.436ca","3c7c7417.36990c","a9221931.e3bfe","22c7000.7b4c08"]]},{"id":"57f0a236.b4ec7c","type":"change","z":"5b27ad0.730cdd4","name":"on","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"},{"t":"set","p":"command","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1104,"y":289,"wires":[["b1b1c9d6.708d8","dae6ce96.84bed"]]},{"id":"a538682c.51a9d8","type":"change","z":"5b27ad0.730cdd4","name":"off","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"},{"t":"set","p":"command","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1563,"y":340,"wires":[["dae6ce96.84bed","9f630a75.c7fa5"]]},{"id":"b1b1c9d6.708d8","type":"change","z":"5b27ad0.730cdd4","name":"cancel","rules":[{"t":"delete","p":"payload.value","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1104,"y":374,"wires":[["a566d30a.dcd26","674afebd.0d7fe8"]]},{"id":"22c7000.7b4c08","type":"and-gate","z":"5b27ad0.730cdd4","name":"closed/active","rules":[{"t":"eq","v":"active","vt":"str","propertyType":"msg","property":"payload.value","topic":"Motion Sensor - Mud Room Bathroom"},{"t":"eq","v":"closed","vt":"str","propertyType":"msg","property":"payload.value","topic":"Contact Sensor - Mud Room Bathroom Door"}],"outputTopic":"","gateType":"and","emitOnlyIfTrue":true,"x":665,"y":238,"wires":[["242d7418.94a934","fd7cd315.405368"]]},{"id":"3c7c7417.36990c","type":"and-gate","z":"5b27ad0.730cdd4","name":"closed/inactive","rules":[{"t":"eq","v":"inactive","vt":"str","propertyType":"msg","property":"payload.value","topic":"Motion Sensor - Mud Room Bathroom"},{"t":"eq","v":"closed","vt":"str","propertyType":"msg","property":"payload.value","topic":"Contact Sensor - Mud Room Bathroom Door"}],"outputTopic":"","gateType":"and","emitOnlyIfTrue":true,"x":675,"y":340,"wires":[["674afebd.0d7fe8"]]},{"id":"a9221931.e3bfe","type":"and-gate","z":"5b27ad0.730cdd4","name":"open/active","rules":[{"t":"eq","v":"active","vt":"str","propertyType":"msg","property":"payload.value","topic":"Motion Sensor - Mud Room Bathroom"},{"t":"eq","v":"open","vt":"str","propertyType":"msg","property":"payload.value","topic":"Contact Sensor - Mud Room Bathroom Door"}],"outputTopic":"","gateType":"and","emitOnlyIfTrue":true,"x":665,"y":289,"wires":[["242d7418.94a934"]]},{"id":"fdc49ec6.436ca","type":"and-gate","z":"5b27ad0.730cdd4","name":"open/inactive","rules":[{"t":"eq","v":"inactive","vt":"str","propertyType":"msg","property":"payload.value","topic":"Motion Sensor - Mud Room Bathroom"},{"t":"eq","v":"open","vt":"str","propertyType":"msg","property":"payload.value","topic":"Contact Sensor - Mud Room Bathroom Door"}],"outputTopic":"","gateType":"and","emitOnlyIfTrue":true,"x":675,"y":391,"wires":[["a566d30a.dcd26"]]},{"id":"d8e1f318.1483b","type":"inject","z":"5b27ad0.730cdd4","name":"init","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"10","topic":"","payload":"","payloadType":"date","x":203,"y":204,"wires":[["c9531a35.a85ff8","1e101ad6.d58445"]]},{"id":"7f53ef6e.facb48","type":"change","z":"5b27ad0.730cdd4","name":"on","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"},{"t":"set","p":"command","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1104,"y":238,"wires":[["9f630a75.c7fa5"]]},{"id":"a9444693.527e38","type":"hubitat device","z":"5b27ad0.730cdd4","name":"Motion Sensor - Downstairs Bathroom Corner","server":"cd816c39.6978b","deviceId":"1382","attribute":"motion","sendEvent":true,"x":333,"y":629,"wires":[["a0d98dfa.6e7e5"]]},{"id":"148b10a8.aca03f","type":"hubitat device","z":"5b27ad0.730cdd4","name":"Contact Sensor - Downstairs Bathroom Door","server":"cd816c39.6978b","deviceId":"1383","attribute":"contact","sendEvent":true,"x":323,"y":680,"wires":[["6e4b42f8.a5ae9c","c91bafca.88a358","dd1568e5.c3c798","35709110.9f3a16"]]},{"id":"c9a48b2.66042f8","type":"change","z":"5b27ad0.730cdd4","name":"off","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"},{"t":"set","p":"command","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1563,"y":731,"wires":[["10e9c09c.4ed167","ffaa1af6.f637f8"]]},{"id":"c4b8999b.df5898","type":"change","z":"5b27ad0.730cdd4","name":"cancel","rules":[{"t":"delete","p":"payload.value","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1104,"y":697,"wires":[["77d86b84.e5a25c","a03f77b1.f714c8"]]},{"id":"8c3ac8a.3e399b8","type":"inject","z":"5b27ad0.730cdd4","name":"init","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"10","topic":"","payload":"","payloadType":"date","x":203,"y":510,"wires":[["a9444693.527e38","caecd6bc.93aac8","148b10a8.aca03f"]]},{"id":"90931144.ab51","type":"change","z":"5b27ad0.730cdd4","name":"on","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"},{"t":"set","p":"command","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1563,"y":663,"wires":[["ffaa1af6.f637f8"]]},{"id":"4b036700.e9374","type":"comment","z":"5b27ad0.730cdd4","name":"Downstairs Bathroom","info":"","x":202,"y":459,"wires":[]},{"id":"96bfdbf0.08e5b8","type":"comment","z":"5b27ad0.730cdd4","name":"Mud Room Bathroom","info":"","x":202,"y":136,"wires":[]},{"id":"caecd6bc.93aac8","type":"hubitat device","z":"5b27ad0.730cdd4","name":"Motion Sensor - Downstairs Bathroom Door","server":"cd816c39.6978b","deviceId":"1381","attribute":"motion","sendEvent":true,"x":323,"y":578,"wires":[["a0d98dfa.6e7e5"]]},{"id":"a0d98dfa.6e7e5","type":"or-gate","z":"5b27ad0.730cdd4","name":"Motion Or","rules":[{"t":"eq","v":"active","vt":"str","propertyType":"msg","property":"payload.value","topic":"Motion Sensor - Downstairs Bathroom Door"},{"t":"eq","v":"active","vt":"str","propertyType":"msg","property":"payload.value","topic":"Motion Sensor - Downstairs Bathroom Corner"}],"outputTopic":"motion","gateType":"or","emitOnlyIfTrue":false,"x":655,"y":595,"wires":[["6e4b42f8.a5ae9c","c91bafca.88a358","dd1568e5.c3c798","35709110.9f3a16"]]},{"id":"6e4b42f8.a5ae9c","type":"and-gate","z":"5b27ad0.730cdd4","name":"closed/active","rules":[{"t":"true","propertyType":"msg","property":"bool","topic":"motion"},{"t":"eq","v":"closed","vt":"str","propertyType":"msg","property":"payload.value","topic":"Contact Sensor - Downstairs Bathroom Door"}],"outputTopic":"","gateType":"and","emitOnlyIfTrue":true,"x":886,"y":561,"wires":[["90931144.ab51","c4b8999b.df5898","2fff3924.ed427e"]]},{"id":"c91bafca.88a358","type":"and-gate","z":"5b27ad0.730cdd4","name":"open/active","rules":[{"t":"true","propertyType":"msg","property":"bool","topic":"motion"},{"t":"eq","v":"open","vt":"str","propertyType":"msg","property":"payload.value","topic":"Contact Sensor - Downstairs Bathroom Door"}],"outputTopic":"","gateType":"and","emitOnlyIfTrue":true,"x":886,"y":612,"wires":[["c4b8999b.df5898","2fff3924.ed427e"]]},{"id":"dd1568e5.c3c798","type":"and-gate","z":"5b27ad0.730cdd4","name":"closed/inactive","rules":[{"t":"false","propertyType":"msg","property":"bool","topic":"motion"},{"t":"eq","v":"closed","vt":"str","propertyType":"msg","property":"payload.value","topic":"Contact Sensor - Downstairs Bathroom Door"}],"outputTopic":"","gateType":"and","emitOnlyIfTrue":true,"x":896,"y":663,"wires":[["77d86b84.e5a25c"]]},{"id":"35709110.9f3a16","type":"and-gate","z":"5b27ad0.730cdd4","name":"open/inactive","rules":[{"t":"false","propertyType":"msg","property":"bool","topic":"motion"},{"t":"eq","v":"open","vt":"str","propertyType":"msg","property":"payload.value","topic":"Contact Sensor - Downstairs Bathroom Door"}],"outputTopic":"","gateType":"and","emitOnlyIfTrue":true,"x":896,"y":714,"wires":[["a03f77b1.f714c8"]]},{"id":"ecb1277a.3f6248","type":"change","z":"5b27ad0.730cdd4","name":"10%","rules":[{"t":"set","p":"payload","pt":"msg","to":"10","tot":"num"},{"t":"set","p":"command","pt":"msg","to":"setLevel","tot":"str"},{"t":"set","p":"arguments","pt":"msg","to":"10,0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1563,"y":612,"wires":[["10e9c09c.4ed167"]]},{"id":"efedd172.9ec6d","type":"change","z":"5b27ad0.730cdd4","name":"60%","rules":[{"t":"set","p":"payload","pt":"msg","to":"60","tot":"num"},{"t":"set","p":"command","pt":"msg","to":"setLevel","tot":"str"},{"t":"set","p":"arguments","pt":"msg","to":"60,0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1563,"y":578,"wires":[["10e9c09c.4ed167"]]},{"id":"1a0bbf58.daa851","type":"change","z":"5b27ad0.730cdd4","name":"100%","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"},{"t":"set","p":"command","pt":"msg","to":"setLevel","tot":"str"},{"t":"set","p":"arguments","pt":"msg","to":"100,0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1563,"y":544,"wires":[["10e9c09c.4ed167"]]},{"id":"2fff3924.ed427e","type":"switch","z":"5b27ad0.730cdd4","name":"Mode","property":"mode","propertyType":"global","rules":[{"t":"eq","v":"day","vt":"str"},{"t":"eq","v":"evening","vt":"str"},{"t":"eq","v":"night","vt":"str"},{"t":"eq","v":"sleep","vt":"str"},{"t":"eq","v":"cleaninglady","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":1291,"y":578,"wires":[["1a0bbf58.daa851"],["efedd172.9ec6d"],["ecb1277a.3f6248"],["ecb1277a.3f6248"],["1a0bbf58.daa851"]],"outputLabels":["Day","Evening","Night","Sleep","Cleaning Lady"]},{"id":"242d7418.94a934","type":"switch","z":"5b27ad0.730cdd4","name":"Not Away Restriction","property":"mode","propertyType":"global","rules":[{"t":"neq","v":"away","vt":"str"},{"t":"eq","v":"away","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":899,"y":289,"wires":[["57f0a236.b4ec7c"],[]]},{"id":"fd7cd315.405368","type":"switch","z":"5b27ad0.730cdd4","name":"Not Away Restriction","property":"mode","propertyType":"global","rules":[{"t":"neq","v":"away","vt":"str"},{"t":"eq","v":"away","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":899,"y":238,"wires":[["7f53ef6e.facb48"],[]]},{"id":"674afebd.0d7fe8","type":"stoptimer-varidelay","z":"5b27ad0.730cdd4","duration":"4","durationType":"num","units":"Minute","payloadtype":"num","payloadval":"0","name":"","reporting":"every_second","persist":false,"x":1321,"y":340,"wires":[["a538682c.51a9d8"],[],[]]},{"id":"a566d30a.dcd26","type":"stoptimer-varidelay","z":"5b27ad0.730cdd4","duration":"30","durationType":"num","units":"Second","payloadtype":"num","payloadval":"0","name":"","reporting":"every_second","persist":false,"x":1331,"y":408,"wires":[["a538682c.51a9d8"],[],[]]},{"id":"a03f77b1.f714c8","type":"stoptimer-varidelay","z":"5b27ad0.730cdd4","duration":"30","durationType":"num","units":"Second","payloadtype":"num","payloadval":"0","name":"","reporting":"every_second","persist":false,"x":1331,"y":731,"wires":[["c9a48b2.66042f8"],[],[]]},{"id":"77d86b84.e5a25c","type":"stoptimer-varidelay","z":"5b27ad0.730cdd4","duration":"6","durationType":"num","units":"Minute","payloadtype":"num","payloadval":"0","name":"","reporting":"every_second","persist":false,"x":1321,"y":663,"wires":[["c9a48b2.66042f8"],[],[]]},{"id":"dae6ce96.84bed","type":"hubitat command","z":"5b27ad0.730cdd4","deviceLabel":"Mud Room Bathroom Lights (Lutron N)","name":"","server":"319c6842.9a57d8","deviceId":"1272","command":"","commandArgs":"","x":1952,"y":289,"wires":[[]]},{"id":"9f630a75.c7fa5","type":"hubitat command","z":"5b27ad0.730cdd4","deviceLabel":"Mud Room Bathroom Fan (Lutron N)","name":"","server":"319c6842.9a57d8","deviceId":"1273","command":"","commandArgs":"","x":1952,"y":238,"wires":[[]]},{"id":"10e9c09c.4ed167","type":"hubitat command","z":"5b27ad0.730cdd4","deviceLabel":"Downstairs Bathroom Lights (Lutron S)","name":"","server":"cd816c39.6978b","deviceId":"1010","command":"","commandArgs":"","x":1952,"y":578,"wires":[[]]},{"id":"ffaa1af6.f637f8","type":"hubitat command","z":"5b27ad0.730cdd4","deviceLabel":"Downstairs Bathroom Fan (Lutron S)","name":"","server":"cd816c39.6978b","deviceId":"1011","command":"","commandArgs":"","x":1952,"y":697,"wires":[[]]},{"id":"319c6842.9a57d8","type":"hubitat config","name":"Hubitat North","usetls":false,"host":"192.168.20.21","port":"80","appId":"1685","nodeRedServer":"http://192.168.20.35:1880/","webhookPath":"/hubitat/webhook_","autoRefresh":true,"useWebsocket":false},{"id":"cd816c39.6978b","type":"hubitat config","name":"Hubitat South","usetls":false,"host":"192.168.20.20","port":"80","appId":"2064","nodeRedServer":"http://192.168.20.35:1880","webhookPath":"/hubitat/webhook","autoRefresh":true,"useWebsocket":false}] ‘’’

3 Likes

This isn’t a Node-Red solution, but it’s an attempt to solve the same problem. There are a number of different use cases regarding whether the door is closed, open on entry and exit, so I’m finding it difficult to solve.

My latest attempt includes a motion sensor with a 1 minute timeout, and a contact sensor on the door, a virtual switch ,Motion Lighting app, and an RM rule to help with the change to unoccupied.


Based on what I’ve read in this thread I’m adding a Philips Hue motion sensor to the door threshold, as it has a configurable retrigger value. It remains to be seen if that will allow me to finally get this right for all use cases :slight_smile:

That looks nice! I've been messing around with finite state machines lately. Incorporating that concept the logic could be redone like this:

Finite State Machine Example

[{"id":"ba7e0603.6b0938","type":"inject","z":"af91369d.586338","name":"Motion = active","props":[{"p":"payload.value","v":"active","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":380,"y":460,"wires":[["6f7022d6.e3490c"]]},{"id":"b21ec898.15e9b8","type":"inject","z":"af91369d.586338","name":"Motion = inactive","props":[{"p":"payload.value","v":"inactive","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":380,"y":500,"wires":[["6f7022d6.e3490c"]]},{"id":"a50dd8b6.2561c8","type":"inject","z":"af91369d.586338","name":"Contact = open","props":[{"p":"payload.value","v":"open","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":380,"y":600,"wires":[["6f7022d6.e3490c"]]},{"id":"f649bf76.1cd48","type":"inject","z":"af91369d.586338","name":"Contact = closed","props":[{"p":"payload.value","v":"closed","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":380,"y":640,"wires":[["6f7022d6.e3490c"]]},{"id":"64ad2c72.b10f14","type":"debug","z":"af91369d.586338","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1470,"y":540,"wires":[]},{"id":"5a1f77aa.72cd88","type":"finite-state-machine","z":"af91369d.586338","name":"","fsmDefinition":"{\"state\":{\"status\":\"CLOSED/INACTIVE\"},\"transitions\":{\"CLOSED/INACTIVE\":{\"active\":\"CLOSED/ACTIVE\",\"open\":\"OPEN/INACTIVE\"},\"OPEN/INACTIVE\":{\"active\":\"OPEN/ACTIVE\",\"closed\":\"CLOSED/INACTIVE\"},\"CLOSED/ACTIVE\":{\"inactive\":\"CLOSED/INACTIVE\",\"open\":\"OPEN/ACTIVE\"},\"OPEN/ACTIVE\":{\"inactive\":\"OPEN/INACTIVE\",\"closed\":\"CLOSED/ACTIVE\"}}}","sendInitialState":false,"sendStateWithoutChange":false,"showTransitionErrors":false,"x":890,"y":540,"wires":[["84886862.faf398"]]},{"id":"6f7022d6.e3490c","type":"change","z":"af91369d.586338","name":"topic = payload.value","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":540,"wires":[["5a1f77aa.72cd88"]]},{"id":"84886862.faf398","type":"switch","z":"af91369d.586338","name":"CLOSED/INACTIVE \\n OPEN/INACTIVE \\n CLOSED/ACTIVE \\n OPEN/ACTIVE","property":"payload.status","propertyType":"msg","rules":[{"t":"eq","v":"CLOSED/INACTIVE","vt":"str"},{"t":"eq","v":"OPEN/INACTIVE","vt":"str"},{"t":"eq","v":"CLOSED/ACTIVE","vt":"str"},{"t":"eq","v":"OPEN/ACTIVE","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":1140,"y":540,"wires":[["64ad2c72.b10f14"],["64ad2c72.b10f14"],["64ad2c72.b10f14"],["64ad2c72.b10f14"]]}]

Note: you need the node-red-contrib-finite-statemachine node. I don't know if it is really any more efficient though.. but since I now have an FSM "hammer" in my NR "toolbox" everything looks like a nail... :laughing:

On a side note - recommend when posting a flow/sequence use three [` ] at the beginning and end of the code that way it's easier for people to cut and paste...

<details><summary>Posting Code Example</summary>
<p>

```
[your cool stuff here]
```
</p>
</details>

EDIT: I've likely missed a few state transitions but this should at least give you an idea of what I'm babbling about. I am currently interested in exploring these kinds of device interactions / aggregations in NR so thank you for posting your solution!

1 Like

I played with FSM some, but ultimately decided that most of my automations weren’t really going to become much more efficient by changing to that paradigm. It will also take a bit of work to wrap my head around it, and currently my home automations are on cruise control. :man_shrugging:

1 Like

It's not really for everything and I'm only beginning to understand how it works too. I think there is a limit to FSM - at a certain point things become too complex to parse.

I am using FSM for home/away + guest/no guest for my automated lighting sequences and using a node called node-red-contrib-presence-faker.

Your post gave me an excuse to fool around with FSM a bit more... :grinning_face_with_smiling_eyes:

1 Like