Looking for help with an automation flow in Node Red.
I am streaming telemetry data from my Meraki wireless APs via mqtt to Home Assistant and am seeing it come into the mqtt in node when I attach a debug to it.
The automation flow goes like this:
Garage Door opens → check for sun below horizon → check if my iPhone was just seen by the network in the last 30 seconds (some sort of state change to verify that I’ve arrived home rather than am leaving) → turn on entryway lights.
I setup a switch node off of the mqtt listener and used a “contains” and pasted in the MAC of my iphone. Problem is that nothing seems to be coming out of that node. I must be missing something format or structure wise and am stuck.
Are you using an mqtt in node? What’s the topic that put out what you see in MQTT explorer, and did you specify it in the mqtt in node? It also looks like you will want the output as a parsed json object as there are multiple objects put out in the subscribed topic, and this will break them up.
Then once the mqtt in node is outputting a JSON object, you then can do a switch node to only pass on messages where msg.payload.clientMac equals your MAC address
I am now seeing the debug output off the switch node. Didn’t realize the msg field was case sensitive.
So now back to making this work. I’m receiving messages every 10 seconds that my phone is associated to the network.
With the goal of using this as a presence sensor to trigger an automation when I arrive home, how can I best leverage this into a flow as I don’t have a “not associated” state to trigger from a state change.
There is a time stamp in UTC… Trying to think how that can be leveraged to perform some sort of calculation.
Using a flow variable and a 5 minute timer from the stop timer palette should work. The stop timer will continuously reset the countdown until the phone is gone, then after 5 minutes (or whatever time you want) set the flow variable to False, indicating the phone isn’t there anymore.
I managed to do this with a trigger. Took me a while to figure out (not to mention I didn’t use node-red before).
Fact is that there will be no new topics published to MQTT by Meraki if the device is no longer on the network. That can be leveraged.
The MQTT in listens on the mqtt/meraki topic. It then passes through the “payload.clientMac” filter onto the trigger. The trigger sends “home” as payload, waits for 10 seconds, and then there are 2 options
1- it receives a new message (thus the device is still on the network), and then extends the delay.
2- sends “not_home” if it doesn’t receive a new message.