I am exploring multiple routes to get the location from a iphone to my HomeRemote app. I used to work with PHLocation that is no more supported. I am now looking both the MQTT route and the node red route. as I am not a developer I am struggling a lot when comes time to do some programming so please bare with me.
I just installed Node-red and started playing with it and it seems to be an incredible power tool. I am trying to figure out how I can merge two values from a Node message and set a device status containing this cancatenated result.
I am able to update a device status using Node-red, I at least figured that out but my problem is to merge values. Let say I have the following Message coming out of a Node: (extracted from a debud node)
object
refreshTimeStamp: "2020-11-14 19:53:42"
what would be the best way to create a msg.payload.status containing "latitude,longitude" ?
****** update *****
I found a way, may be not the best but it works, I added a function node with the following:
var lati1 = String(msg.payload.iPhone[0].locationInfo.latitude);
var long1 = String(msg.payload.iPhone[0].locationInfo.longitude);
msg.payload.status = lati1 + "," + long1;
return msg;
I just installed Node-red and started playing with it and it seems to be an incredible power tool. I am trying to figure out how I can merge two values from a Node message and set a device status containing this cancatenated result.
I am able to update a device status using Node-red, I at least figured that out but my problem is to merge values. Let say I have the following Message coming out of a Node: (extracted from a debud node)
object
iPhone: array[1]
0: object
modelName: "iPhone 12 Pro"
deviceID: "/xyz="
displayName: "iPhone12"
batteryLevel: 82
batteryState: "NotCharging"
locationInfo: object
altitude: 0
latitude: 45.76989884492547
longitude: -74.11944542087066
displayName: "iPhone12"
batteryLevel: 82
batteryState: "NotCharging"
locationInfo: object
altitude: 0
latitude: 45.76989884492547
longitude: -74.11944542087066
locationTimeStamp: "2020-11-14 19:52"
refreshTimeStamp: "2020-11-14 19:53:42"
what would be the best way to create a msg.payload.status containing "latitude,longitude" ?
****** update *****
I found a way, may be not the best but it works, I added a function node with the following:
var lati1 = String(msg.payload.iPhone[0].locationInfo.latitude);
var long1 = String(msg.payload.iPhone[0].locationInfo.longitude);
msg.payload.status = lati1 + "," + long1;
return msg;
Comment