Mobile Home 

NB Dashboard template theme dark

The Address Resolution Protocol node is accessed, as set at initialisation, every minute . The node contains the comma separated MAC addresses of the household mobile phones. If the mobiles are present on the local network their address is returned in the output msg.payload within the array of objects containing :

ip : the IP address of the device.

mac : the MAC address of the device.

iface : the network interface of the device.

The msg.payload  is split into the number of household mobiles as separate message streams to assign an individual's name as a msg.topic and associate a y value for the mobile's axes location on the line chart in the Function node. A Switch node is then used with a JSONATA expression for each payload topic stream to ascertain whether the MAC address associated with that individual is present.

'xx:xx:xx:xx:xx:xx' in payload.mac

If the MAC address is present the Function node (is home) leaves the y  value unchanged, sets the payload to current time, and creates a location msg and colour in the msg.payload.

msg.payload = Date.now();

msg.locate = msg.topic +" arrived home at ";

msg.color = "green";

return msg;


 but if away then the Function node (not home) sets y  to 0

msg.payload = Date.now();

msg.y = 0;

msg.locate = msg.topic + " left home at ";

msg.color = "red";

return msg;


Any spurious loss of mobile local network connectivity would result in false away from homes, this is mitigated by only registering an away from home if there have been at least three y values of 0 by using the Smooth node to return the maximum value seen over the most recent 4 values, with each individual msg.topic treated as separate stream. A 3 minute correction for the last recorded timing if y=0 is made by the Change node.

y=0 ? payload-(1000*60*3):payload

Only message streams with a change in the y value pass through the RBE node and they are then sifted by msg.topic for the appropriate dashboard Text node.

The Text nodes have:

Label - <font color={{color}}>{{msg.locate}}

Value format - <font color= {{msg.color}} > {{payload| date: 'EEEE'}} <br> {{payload| date: 'h:mm a'}} </font>

The msg.y of the message streams are assigned to msg.payload for displaying a line in accordance with msg.topic in the dashboard Chart node (occupancy) which has its maximum y axis set to one more than the number of mobile phones in the household.


The JSONata debug converts the payload from milliseconds to date and time and adds the Topic. 

$fromMillis(payload, '[D01]/[M01]/[Y0001] [h#1]:[m01][P]')&" "&topic

[see JSONata date time functions for more details]

Wiced Comments (Responses)