Node Red Flow troubleshooting - presence based mode switch

Trying to setup my first few Node Red flows. This one is supposed to check my wife's presence if my presence changes to "not present" - if she's also "not present", the mode should change to "Away". Then if either of our presences change to "present", it should change to "Home".

[{"id":"e06f6b3d.f2c298","type":"tab","label":"Home/Away","disabled":false,"info":""},{"id":"cabf58d2.37cbe8","type":"hubitat device","z":"e06f6b3d.f2c298","name":"Chris's Phone","server":"6e159515.db052c","deviceId":"80","attribute":"presence","sendEvent":true,"x":180,"y":80,"wires":[["dde88371.1d796"]]},{"id":"dde88371.1d796","type":"switch","z":"e06f6b3d.f2c298","name":"not present","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"not present","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":350,"y":80,"wires":[["e826eb27.2dbb88"]]},{"id":"e826eb27.2dbb88","type":"hubitat device","z":"e06f6b3d.f2c298","name":"Mattie's Phone","server":"6e159515.db052c","deviceId":"80","attribute":"presence","sendEvent":true,"x":540,"y":80,"wires":[["d8b841aa.3130c"]]},{"id":"d8b841aa.3130c","type":"switch","z":"e06f6b3d.f2c298","name":"not present","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"not present","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":710,"y":80,"wires":[["cd823346.0953f"]]},{"id":"b9e82acd.85f158","type":"hubitat mode-setter","z":"e06f6b3d.f2c298","name":"Set Away","server":"6e159515.db052c","modeId":"4","x":1200,"y":120,"wires":[[]]},{"id":"9eaca493.905278","type":"hubitat device","z":"e06f6b3d.f2c298","name":"Chris's Phone","server":"6e159515.db052c","deviceId":"80","attribute":"presence","sendEvent":true,"x":540,"y":160,"wires":[["c913561.813e2a8"]]},{"id":"4ec74ec1.374ec","type":"switch","z":"e06f6b3d.f2c298","name":"not present","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"not present","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":350,"y":160,"wires":[["9eaca493.905278"]]},{"id":"f210c245.046fa","type":"hubitat device","z":"e06f6b3d.f2c298","name":"Mattie's Phone","server":"6e159515.db052c","deviceId":"80","attribute":"presence","sendEvent":true,"x":180,"y":160,"wires":[["4ec74ec1.374ec"]]},{"id":"c913561.813e2a8","type":"switch","z":"e06f6b3d.f2c298","name":"not present","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"not present","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":710,"y":160,"wires":[["cd823346.0953f"]]},{"id":"cd823346.0953f","type":"hubitat device","z":"e06f6b3d.f2c298","name":"House Guests","server":"6e159515.db052c","deviceId":"97","attribute":"switch","sendEvent":true,"x":910,"y":120,"wires":[["a8dbeae1.1a2b38"]]},{"id":"a8dbeae1.1a2b38","type":"switch","z":"e06f6b3d.f2c298","name":"off","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1070,"y":120,"wires":[["b9e82acd.85f158"]]},{"id":"1007714d.a88b6f","type":"hubitat device","z":"e06f6b3d.f2c298","name":"Chris's Phone","server":"6e159515.db052c","deviceId":"80","attribute":"presence","sendEvent":true,"x":180,"y":300,"wires":[["7f6eb399.3d123c"]]},{"id":"7f6eb399.3d123c","type":"switch","z":"e06f6b3d.f2c298","name":"present","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"present","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":340,"y":300,"wires":[["889135d0.68f028"]]},{"id":"889135d0.68f028","type":"hubitat mode-setter","z":"e06f6b3d.f2c298","name":"Set Home","server":"6e159515.db052c","modeId":"4","x":500,"y":340,"wires":[[]]},{"id":"f7b25e4a.eac4f","type":"switch","z":"e06f6b3d.f2c298","name":"present","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"present","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":340,"y":380,"wires":[["889135d0.68f028"]]},{"id":"9289327f.3f7e1","type":"hubitat device","z":"e06f6b3d.f2c298","name":"Mattie's Phone","server":"6e159515.db052c","deviceId":"80","attribute":"presence","sendEvent":true,"x":180,"y":380,"wires":[["f7b25e4a.eac4f"]]},{"id":"6e159515.db052c","type":"hubitat config","z":"","name":"Hubitat","usetls":false,"host":"192.168.11.124","port":"80","appId":"46","nodeRedServer":"http://localhost:1880","webhookPath":"/hubitat/webhook","autoRefresh":true,"useWebsocket":false}]

I deployed this, turned off my presence sensor, and in Hubitat the device went into "not present" mode, but the Mode still says Home...any ideas why?

No idea why it didn't work.

But there's an error in your sequence that is irrelevant to issue of the mode not changing. Uncheck "Send Events" from the intervening device nodes. It should only be checked for the device nodes that initiate each sequence.

Edit: From the screenshot, it looks like Mode didn't change because the sequence wasn't "deployed" after it was edited.

Thanks, but the screenshot was just out of date. I did deploy and it still doesn't work.

Thanks for the heads up on Send Events - wasn't sure whether that should be checked or not. Still no luck after disabling them on everything but the initiating device nodes.

Does it work if you connect an inject node directly to the Change Mode node? If so, can you confirm (using a debug node) that a message is being received by the Change Mode node in your original sequence?

Edit: Sorry, didn't see the second half of your message. Yes, injecting the Change Mode node works, but no it doesn't seem like a debug node right before the Change Mode node is receiving anything when I disconnect my phone from Wifi and wait several minutes.

Maybe I'm completely missing something with how Node Red works...when I turn on that "House Guests" virtual switch, shouldn't that node reflect that change? When I do that, it stays "Off" despite the device showing "On" in Hubitat.

You'll need the send events on the first two nodes.

But not on the other two, and also send events on, on the House Guests switch.
From what I see (hopefully) :wink:

1 Like

I don't think you want Send Events checked on House Guests either. Generally a Device Node in the middle of a flow should not have Send Events checked. That bites me all the time forgetting to uncheck. When unchecked, the box underneath the node will be hollow.

I'd recommend putting some debug nodes in there to trace what's happening. Put an inject node before Chris' Phone so you can run it.

Visually it looks like it should work exactly how you intend it to.

To me, both these statements indicate that Node-RED isn't receiving events from Hubitat. Resolving this issue will solve the problem because you have already indicated that you have unchecked send events from intervening device nodes.

Are you using webhooks or websockets to receive events from MakerAPI?

If you are using webhooks, make sure that the URL used in MakerAPI to post events exactly matches the URL in the Node-RED Hubitat nodes configuration node.

3 Likes

Looks like the URL was the issue. I have Node Red running locally on my laptop while I'm testing things out, and had the URL set to "localhost:1880". Changed that to my laptop's IP address and it's working now.

Though, the iPhone Wifi Presence app is pretty slow - takes about a minute to recognize a change in presence...

1 Like

I don't use that app. I use OwnTracks + a self-hosted MQTT server for presence, and pull the data directly into NR. Combining it with node-red-node-geofence allows one to create a variety of presence and tracking options.

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.