Tesla Location & node-red-node-geofence

Heyo, not sure how to get the correct formatting from the node-red-contrib-tesla to node-red-node-geofence.

Here's the output of the node-red-contrib-tesla driveState command:

{"_msgid":"15f2c9c.3bb0a36","payload":{"gps_as_of":1620781503,"heading":94,"latitude":xxxx,"longitude":-xxxx,"native_latitude":xxxx,"native_location_supported":1,"native_longitude":-xxxx,"native_type":"wgs","power":0,"shift_state":null,"speed":null,"timestamp":1620781574744},"topic":""}

I believe the payload.latitude & payload.longitude need to be msg.location.lat & msg.location.lon so I put the below into a change rule but that doesn't seem to have done anything.
image

Here's the output of the change rule:

{"_msgid":"15f2c9c.3bb0a36","payload":{"gps_as_of":1620781503,"heading":94,"latitude":xxxx,"longitude":-xxxx,"native_latitude":xxxx,"native_location_supported":1,"native_longitude":-xxxx,"native_type":"wgs","power":0,"shift_state":null,"speed":null,"timestamp":1620781574744},"topic":""}

I'm quite new to using Node-RED and not good with any type of JSON so was hoping someone here could help.

Thanks!

You have the arguments wrong way round in the change node.
you should read it as set msg.something to the value of something.

You might also need to set msg.location to JSON {} first (first row of change node) to initialise the location as an object before setting the lat & lon.

Or change the set to move

I appreciate the help, I made the below change and it worked!

image

1 Like

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