Owntracks GPS Presence in Node-RED

Hi All,

I figured i’d pass this on to anyone also interested. I put this together using elements from other articles I found online and it’s been great. My wife and I use both Unifi (WiFI) and now Owntracks (GPS) for presence mainly because her iPhone would constantly drop on and off the WiFi as it slept.

Nodes used: node-red-contrib-boolean-logic-ultimate, node-red-contrib-unifi, node-red-node-geofence and node-red-contrib-owntracks

Step 1) Sign up for a free service with HiveMQ . This service offers a cloud hosted (Azure or AWS you choose) secure service

Step 2) Install Owntracks on either your Android or iPhone devices and set encryption key.

Step 3) Configure Owntracks public secure connection to MQTT and enter details from the HiveMQ service.

Step 4) Configure Node-RED to (as per image) or develop your own flow (your call). Note: I also push this and the Unifi (WiFi) payloads into a boolean logic ultimate node so they work together. Note: set the same encryption key as mobile app in node-red-contrib-owntracks node.

Anyways I won’t bother sharing the flow with this one given it’s a all custom to my setup but I do suggest looking into this because it’s made a significant difference in our house. I can share components you need though if interested and again if you do it another way and or make it better share back here for others.

4 Likes

My lady is not interested in participating so my flow is much simpler.

And I can’t blame her because all I’m doing is keeping a local log, as you can see. So far there is just nothing I care to use this presence for as I automate only those things that make our life easier and nothing just because I can. Blasphemy, I’m sure, to those who never pass on a chance to automate. :rofl:

4 Likes

How do you find accuracy with owntracks?

I currently use tasker with autolocation for presence and can’t fault it (yet!)
Just another suggestion if anyone is looking!

2 Likes

It can be quite good, depending on the chosen mode and distance settings. I use the “significant changes” mode but “move monitoring” is much more sensitive which causes too much reporting for my taste.

2 Likes

Agree with @LosinIt I also use it in the default “significant mode” and it works great I don’t even notice any changes to my battery life either which is nice.

2 Likes

I notice that none of you are bothering to encrypt your location for added privacy making you all dead simple to track if i wanted too… Why???

Also anyone up for a game of i know where you are right now? hehe :stuck_out_tongue:

Yes, well… ahem… it’s an issue with getting a psk setup in Mosquitto. I wasn’t able to get it worked out but recently there was an update that supposedly fixed some issues with it. I just haven’t got back to trying again. But it doesn’t matter near as much as you seem to think because OT → Mosquitto only happens on either MY Wi-Fi or over MY VPN when on cell data so go ahead and find my phone. OTOH, I know for sure you can find my IP that is in use ALL the time when I’m using YOUR discourse instance. :stuck_out_tongue_winking_eye:

1 Like

I was actually talking about the inbuilt encryption within the OT app. Encrypts the location data with a key of your choosing and then gets decrypted inside your node-red instance.

As great as the added security of wifi and vpn connections are, exploits get released for them like everything else and the encryption option is just another easily added layer of protection so it surprised me you guys arent utilizing it,

It turns out that OT doesn’t support a psk to mosquitto. It seems the only way for that is TLS certs which are too much of a PITA for my liking. I’m also not seeing how to decrypt, in either mosquitto or node-red, the location data from OT’s encryption. Care to enlighten me?

All you need to do is deploy the node-red-contrib-owntracks and put that in your flow with your encryption key. that node will then decrypt the data when matched to the same encryption key you entered into the advanced encryption section of the mobile app.

2 Likes

D’oh! I didn’t even look for such a node. :roll_eyes:

2 Likes

No worries. I had it in my flow previously. I clearly forgot to put it back. All good :ok_hand:

2 Likes

Hoping for some advice on this, I spent quite a few hours trying to get the Unifi Node to talk to my UDM pro but Im not having any luck.

I also downloaded a different unifi node and that one works just fine with basically the same settings?

The debug log shows an empty array for the problem node, and an array of 61 in the working one.

image

image

Cant get this node to work?
image

1 Like

I’ll get mine up here in a bit to help. Have company atm.

Is this a local user? If not, you need to create a local user on your UDMP. I assume by the name that it is. But, I wanted to reiterate that.

Here is my presence flow. I had help with this, so I’m happy to share it. This checks active devices on Unifi and also checks owntracks for presence. Owntracks is a beast. But I’m not going to skimp the flow because I think someone could and would use the entire flow.

[{"id":"fbe411534cd57d36","type":"subflow","name":"Ping Status","info":"","category":"","in":[{"x":40,"y":140,"wires":[{"id":"da3e45d275aeb5dd"},{"id":"3147d2f356c74496"},{"id":"639e734e5e945a1f"}]}],"out":[{"x":1140,"y":200,"wires":[{"id":"404ab9a4eff10c45","port":"0"},{"id":"6addbc0af6da3997","port":"1"}]}],"env":[{"name":"ip","type":"str","value":"127.0.0.1"}],"meta":{},"color":"#DDAA99","status":{"x":700,"y":260,"wires":[{"id":"8b557b207283261a","port":0}]}},{"id":"be981b11edd798c0","type":"bigssh","z":"fbe411534cd57d36","name":"","commandLine":"ping -W 1 -c 1 ","commandArgs":"","minError":"2","minWarning":1,"noStdin":true,"format":"ascii","payloadIsArg":true,"myssh":"5c03f08e973d95fe","x":340,"y":200,"wires":[["8b557b207283261a"],[],[]]},{"id":"8b557b207283261a","type":"function","z":"fbe411534cd57d36","name":"Ping Phone Presence","func":"if(msg.payload.indexOf(\"ping statistics\") >= 0) {\n   msg.payload = msg.payload.indexOf(\"100% packet loss\") < 0;\n   node.status({fill:\"green\", shape:\"dot\", text:msg.payload});\n    return msg\n}\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":200,"wires":[["404ab9a4eff10c45"]]},{"id":"404ab9a4eff10c45","type":"switch","z":"fbe411534cd57d36","name":"","property":"payload","propertyType":"msg","rules":[{"t":"false"},{"t":"true"}],"checkall":"true","repair":false,"outputs":2,"x":730,"y":200,"wires":[[],["6addbc0af6da3997"]]},{"id":"3147d2f356c74496","type":"stoptimer","z":"fbe411534cd57d36","duration":"1","units":"Minute","payloadtype":"num","payloadval":"0","name":"","x":180,"y":80,"wires":[["508beb86a3062ce7"],[]]},{"id":"f881b94cd7c6620e","type":"delay","z":"fbe411534cd57d36","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":700,"y":100,"wires":[["da3e45d275aeb5dd"]]},{"id":"639e734e5e945a1f","type":"change","z":"fbe411534cd57d36","name":"","rules":[{"t":"set","p":"#:(ram)::withinMinute","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":40,"wires":[[]]},{"id":"508beb86a3062ce7","type":"change","z":"fbe411534cd57d36","name":"","rules":[{"t":"set","p":"#:(ram)::withinMinute","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":80,"wires":[[]]},{"id":"6addbc0af6da3997","type":"switch","z":"fbe411534cd57d36","name":"","property":"#:(ram)::withinMinute","propertyType":"flow","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":910,"y":220,"wires":[["f881b94cd7c6620e"],[]]},{"id":"da3e45d275aeb5dd","type":"change","z":"fbe411534cd57d36","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"ip","tot":"env"},{"t":"delete","p":"reset","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":140,"wires":[["be981b11edd798c0"]]},{"id":"5c03f08e973d95fe","type":"SSH_Credentials","host":"192.168.40.20","port":"22","userlabel":"[email protected]"},{"id":"6ebf835ed9fa5711","type":"Unifi","z":"985c4b52f04e10f7","name":"Get Active Devices","ip":"192.168.40.1","port":"443","site":"default","command":"20","unifios":true,"x":390,"y":600,"wires":[["253da6469cb1be99"]]},{"id":"253da6469cb1be99","type":"function","z":"985c4b52f04e10f7","name":"Check Presence","func":"const lastSeenSeconds = 20;\nlet presenceCutoff = (new Date() - (lastSeenSeconds * 1000)) / 1000; \nconst people = {\n    \"presence/April\": \"30:24:67:53:b2:db\",\n    \"presence/Jeff\": \"30:74:67:c5:7a:29\",\n    \"presence/Sarah\": \"44:91:60:bc:8d:57\",\n};\n\nreturn Object.keys(people).map(function(topic) {\n    //let devices = msg.payload[0].filter(device => device.name === people[topic] && device.last_seen > presenceCutoff);\n    let devices = msg.payload[0].filter(device => device.mac === people[topic]);\n    return {\n      topic: topic,\n      retain: true,\n      payload: devices.length > 0\n    };\n});","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":580,"y":600,"wires":[["cb2409cab52beedc"],["13b84e07dfb7a414"],["f0ac9fb19fd54128"]]},{"id":"dc352ba808e7e150","type":"inject","z":"985c4b52f04e10f7","name":"run every 30s","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"30","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":200,"y":600,"wires":[["6ebf835ed9fa5711"]]},{"id":"cb2409cab52beedc","type":"rbe","z":"985c4b52f04e10f7","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":750,"y":580,"wires":[["44a19d5c550ce643"]]},{"id":"13b84e07dfb7a414","type":"rbe","z":"985c4b52f04e10f7","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":750,"y":620,"wires":[["96e8b40c581271aa"]]},{"id":"e7dfa14e8a1aac38","type":"change","z":"985c4b52f04e10f7","name":"JeffUnifi","rules":[{"t":"delete","p":"JeffUnifiPresence","pt":"global"},{"t":"set","p":"JeffUnifiPresence","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":620,"wires":[["101484ecd93f0ba0"]]},{"id":"4da0e55633a0eea1","type":"change","z":"985c4b52f04e10f7","name":"AprilUnifi","rules":[{"t":"delete","p":"AprilUnifiPresence","pt":"global"},{"t":"set","p":"AprilUnifiPresence","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":580,"wires":[["176573af33ba33d9"]]},{"id":"6598384a10d838d0","type":"function","z":"985c4b52f04e10f7","name":".event->payload","func":"return {\n    payload:msg.payload.event,\n            }\n;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":520,"wires":[["10a7b4b09804e447"]]},{"id":"10a7b4b09804e447","type":"rbe","z":"985c4b52f04e10f7","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":850,"y":520,"wires":[["1c8097f67cb50b71"]]},{"id":"1c8097f67cb50b71","type":"change","z":"985c4b52f04e10f7","name":"enter->home, leave->away","rules":[{"t":"change","p":"payload","pt":"msg","from":"enter","fromt":"str","to":"home","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"leave","fromt":"str","to":"away","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1040,"y":520,"wires":[["400c47487c9d2652"]]},{"id":"400c47487c9d2652","type":"change","z":"985c4b52f04e10f7","name":"Set Global April OwnTracks ","rules":[{"t":"set","p":"OwnTrxA","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1300,"y":520,"wires":[["422b4ff55edbfaca"]]},{"id":"951ed37ee860947c","type":"function","z":"985c4b52f04e10f7","name":".event->payload","func":"return {\n    payload:msg.payload.event,\n            }\n;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":680,"wires":[["b8efdf5f39d0cccb"]]},{"id":"b8efdf5f39d0cccb","type":"rbe","z":"985c4b52f04e10f7","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":850,"y":680,"wires":[["7fbd51ea1e64d937"]]},{"id":"7fbd51ea1e64d937","type":"change","z":"985c4b52f04e10f7","name":"enter->home, leave->away","rules":[{"t":"change","p":"payload","pt":"msg","from":"enter","fromt":"str","to":"home","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"leave","fromt":"str","to":"away","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1040,"y":680,"wires":[["4c2f88994f4e2183"]]},{"id":"4c2f88994f4e2183","type":"change","z":"985c4b52f04e10f7","name":"Set Global Jeff OwnTracks ","rules":[{"t":"set","p":"OwnTrxJ","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1300,"y":680,"wires":[["7b59bc903065aa1f"]]},{"id":"96e8b40c581271aa","type":"change","z":"985c4b52f04e10f7","name":"false->away,true->home","rules":[{"t":"change","p":"payload","pt":"msg","from":"false","fromt":"bool","to":"away","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"bool","to":"home","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":620,"wires":[["e7dfa14e8a1aac38"]]},{"id":"44a19d5c550ce643","type":"change","z":"985c4b52f04e10f7","name":"false->away,true->home","rules":[{"t":"change","p":"payload","pt":"msg","from":"false","fromt":"bool","to":"away","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"bool","to":"home","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":580,"wires":[["4da0e55633a0eea1"]]},{"id":"176573af33ba33d9","type":"switch","z":"985c4b52f04e10f7","name":"Unifi Status","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"home","vt":"str"},{"t":"eq","v":"away","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1290,"y":580,"wires":[["2c19bfc72685c936"],["4b8eb856a35a7c77"]]},{"id":"101484ecd93f0ba0","type":"switch","z":"985c4b52f04e10f7","name":"Unifi Status","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"away","vt":"str"},{"t":"eq","v":"home","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1290,"y":620,"wires":[["f91b7eaf7e5afe39"],["76f45c58c569de01"]]},{"id":"4b8eb856a35a7c77","type":"switch","z":"985c4b52f04e10f7","name":"OwnTracks Away","property":"OwnTrxA","propertyType":"global","rules":[{"t":"eq","v":"away","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1510,"y":580,"wires":[["cc127bea6c55c2fe"]]},{"id":"f91b7eaf7e5afe39","type":"switch","z":"985c4b52f04e10f7","name":"OwnTracks Away","property":"OwnTrxJ","propertyType":"global","rules":[{"t":"eq","v":"away","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1510,"y":620,"wires":[["c7966d57349ba5bf"]]},{"id":"7b59bc903065aa1f","type":"switch","z":"985c4b52f04e10f7","name":"Owntracks Status","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"home","vt":"str"},{"t":"eq","v":"away","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1530,"y":680,"wires":[["76f45c58c569de01"],["d9157c7cc0044776","8a5d2d74a1d8e2f4"]]},{"id":"d9157c7cc0044776","type":"switch","z":"985c4b52f04e10f7","name":"Unifi away","property":"#:(file)::JeffUnifiPresence","propertyType":"global","rules":[{"t":"eq","v":"away","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1730,"y":700,"wires":[["c7966d57349ba5bf"]]},{"id":"1a1e3c087162d891","type":"switch","z":"985c4b52f04e10f7","name":"Unifi away","property":"AprilUnifiPresence","propertyType":"global","rules":[{"t":"eq","v":"away","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1710,"y":480,"wires":[["cc127bea6c55c2fe"]]},{"id":"422b4ff55edbfaca","type":"switch","z":"985c4b52f04e10f7","name":"Owntracks Status","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"away","vt":"str"},{"t":"eq","v":"home","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1530,"y":520,"wires":[["41d6be1c237c59fe","1a1e3c087162d891"],["2c19bfc72685c936"]]},{"id":"cc127bea6c55c2fe","type":"change","z":"985c4b52f04e10f7","name":"set away","rules":[{"t":"set","p":"payload","pt":"msg","to":"away","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1900,"y":580,"wires":[["afe0b5a619dc1205"]]},{"id":"2c19bfc72685c936","type":"change","z":"985c4b52f04e10f7","name":"set home","rules":[{"t":"set","p":"payload","pt":"msg","to":"home","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1900,"y":540,"wires":[["afe0b5a619dc1205"]]},{"id":"afe0b5a619dc1205","type":"rbe","z":"985c4b52f04e10f7","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":2070,"y":560,"wires":[["9bdfc7af9d2849d1"]]},{"id":"c7966d57349ba5bf","type":"change","z":"985c4b52f04e10f7","name":"set away","rules":[{"t":"set","p":"payload","pt":"msg","to":"away","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1900,"y":620,"wires":[["60129b31481223d7"]]},{"id":"76f45c58c569de01","type":"change","z":"985c4b52f04e10f7","name":"set home","rules":[{"t":"set","p":"payload","pt":"msg","to":"home","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1900,"y":660,"wires":[["60129b31481223d7"]]},{"id":"60129b31481223d7","type":"rbe","z":"985c4b52f04e10f7","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":2070,"y":640,"wires":[["df6cd38ecea59e98"]]},{"id":"9bdfc7af9d2849d1","type":"change","z":"985c4b52f04e10f7","name":"Set April Home Status","rules":[{"t":"set","p":"topic","pt":"msg","to":"April","tot":"str"},{"t":"set","p":"AprilStatus","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2240,"y":560,"wires":[[]]},{"id":"df6cd38ecea59e98","type":"change","z":"985c4b52f04e10f7","name":"Set Jeff Home Status","rules":[{"t":"set","p":"topic","pt":"msg","to":"Jeff","tot":"str"},{"t":"set","p":"JeffStatus","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2240,"y":640,"wires":[[]]},{"id":"6d2ca8dcbb1b4a08","type":"mqtt in","z":"985c4b52f04e10f7","name":"Jeff","topic":"owntracks/roger/JeffB/event","qos":"2","datatype":"auto","broker":"3f792c51bc3d4765","nl":false,"rap":true,"rh":0,"inputs":0,"x":270,"y":680,"wires":[["cc61fdeff0f68e68"]]},{"id":"e231b9167d714952","type":"mqtt in","z":"985c4b52f04e10f7","name":"April","topic":"owntracks/roger/AprilB/event","qos":"2","datatype":"auto","broker":"3f792c51bc3d4765","nl":false,"rap":true,"rh":0,"inputs":0,"x":270,"y":520,"wires":[["c1833444f2dc49ac"]]},{"id":"c1833444f2dc49ac","type":"owntracks","z":"985c4b52f04e10f7","x":410,"y":520,"wires":[["12c01b9931a4ac61"]]},{"id":"cc61fdeff0f68e68","type":"owntracks","z":"985c4b52f04e10f7","x":410,"y":680,"wires":[["5c2dbcb701d9f8b8"]]},{"id":"12c01b9931a4ac61","type":"switch","z":"985c4b52f04e10f7","name":"","property":"payload.desc","propertyType":"msg","rules":[{"t":"eq","v":"Home","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":550,"y":520,"wires":[["6598384a10d838d0"]]},{"id":"41d6be1c237c59fe","type":"subflow:fbe411534cd57d36","z":"985c4b52f04e10f7","name":"April","env":[{"name":"ip","value":"192.168.10.12","type":"str"}],"x":1570,"y":420,"wires":[["8b252df5e6672c42"]]},{"id":"8a5d2d74a1d8e2f4","type":"subflow:fbe411534cd57d36","z":"985c4b52f04e10f7","name":"Jeff","env":[{"name":"ip","value":"192.168.10.10","type":"str"}],"x":1590,"y":760,"wires":[["901b599064b0ac88"]]},{"id":"8b252df5e6672c42","type":"switch","z":"985c4b52f04e10f7","name":"PingAway","property":"payload","propertyType":"msg","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":1720,"y":420,"wires":[["cc127bea6c55c2fe"]]},{"id":"901b599064b0ac88","type":"switch","z":"985c4b52f04e10f7","name":"PingAway","property":"payload","propertyType":"msg","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":1740,"y":760,"wires":[["c7966d57349ba5bf"]]},{"id":"5c2dbcb701d9f8b8","type":"switch","z":"985c4b52f04e10f7","name":"","property":"payload.desc","propertyType":"msg","rules":[{"t":"eq","v":"home","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":550,"y":680,"wires":[["951ed37ee860947c"]]},{"id":"f0ac9fb19fd54128","type":"rbe","z":"985c4b52f04e10f7","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":750,"y":720,"wires":[["85bb8aaba3be0940"]]},{"id":"bfd564828b49aa6c","type":"change","z":"985c4b52f04e10f7","name":"SarahUnifi","rules":[{"t":"delete","p":"SarahUnifiPresence","pt":"global"},{"t":"set","p":"SarahUnifiPresence","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1130,"y":720,"wires":[[]]},{"id":"85bb8aaba3be0940","type":"change","z":"985c4b52f04e10f7","name":"false->away,true->home","rules":[{"t":"change","p":"payload","pt":"msg","from":"false","fromt":"bool","to":"away","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"bool","to":"home","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":720,"wires":[["bfd564828b49aa6c"]]},{"id":"3f792c51bc3d4765","type":"mqtt-broker","name":"CORE Clean1","broker":"10.10.2.1","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"5","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]

So the unifi flow injects every 30 seconds to check active devices. The node puts out a bit of data, so use the function that’s there. That moves in to the filter that filters each device by topic. Changes true and false to home and away for reference and sets a global to be used later. Then it filters the status and moves through to the appropriate command. Mode. St the end it will set the combined status of owntracks and unifi.

@RRodman helped me with some of the logic & @jchurch helped me with the functions on this. Take this and tailor it to your needs. It’s been solid. Owntracks is a different beast. Once you get it set up, its a matter of using it here. I’ve changed ip addresses and secrets. Use your own.

The end outputs: see what they put out for data. use this to trigger other flows.

3 Likes

At this point I just need the Unifi node (node-red-contrib-unifi 0.1.18 ) to actually produce the array before I can really go any farther.

The user is a local user, but for some reason the node will not return any items in the array.

Basically the setup is the same with the other node (node-red-contrib-unifi-os 0.7.1) and that one produces the array just fine, but not in the same format for me to be able to use the example code in the function block, and I don’t know enough about the node-red code syntax to get it working with the other format yet.

**** Edit I was able to get it to work by changing the port from 8443 to 443 on the node-red-contrib-unifi 0.1.18 and now it works. Odd that one node works fine using 8443, and one doesn’t.

4 Likes

Small steps lead to big discoveries!. UDM’s have strange quirks ! We’ll probably never know why either.

1 Like

Is there any way to remove the persistent icon from the Android notification bar? (without affecting monitoring). Currently in significant changes mode.

Does anyone else finds it takes ages for unifi to drop a device when it disconnects?

No. I’ve not found a way. It’s what keeps the service alive.