Convert namedtuple to json for mqtt - thingsboard
-
I am attempting to upload data in json format to thingsboard from a ruuvitag. I have the data from the device as a namedtuple but need to convert it.
What is the best way to convert this?data
RuuviTagRAW(mac='aa:aa:aa:aa:aa:aa', rssi=-49, format=5, humidity=47.7525, temperature=22.25, pressure=102188, acceleration_x=8, acceleration_y=-16, acceleration_z=1008, battery_voltage=2953, power_info=4, movement_counter=24, measurement_sequence=6190)required json
{ "RuuviTagRAW": [ { "mac": "aa:aa:aa:aa:aa:aa", "rssi": "-49", "format": "5", "humidity": "47.7525", "temperature": "22.25", "pressure": "102188", "acceleration_x": "8", "acceleration_y": "-16", "acceleration_z": "1008", "battery_voltage": "2953", "power_info": "4", "movement_counter": "24", "measurement_sequence": "6190" } ] }
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login