FUXA icon indicating copy to clipboard operation
FUXA copied to clipboard

[Question] Parsing Object in the MQTT payload

Open henjoe opened this issue 10 months ago • 10 comments

Hi @unocelli , how can I parse data when the data format of my MQTT is in an object (nested object)? How can I drill down to that object so I can only choose one of its data?

image

henjoe avatar Apr 15 '24 03:04 henjoe

The only way of doing it (at least how I did it) was to create a new option within TagOptions

image

and then define the mqttTagConverter function within FUXA scripts.

Note: all above require changing FUXA (programming)

bogdanvaduva avatar Apr 19 '24 14:04 bogdanvaduva

Hi @bogdanvaduva ,

Thanks for suggesting. Care to share your code, client and server to achive this?

This is interesting. I actually managed it too (I adjust the server program) so simply add the "/" for every JSON key.

For example, if I have a JSON payload of data:{ temp: { value: 23.5 } }

I just simply set the address to be data/temp/value

But I am interested on scripting too. Thanks!

Regards, Henjoe

henjoe avatar Apr 19 '24 15:04 henjoe

You can find the code at https://github.com/bogdanvaduva/FUXA-B

bogdanvaduva avatar Apr 19 '24 15:04 bogdanvaduva

Thank you very much.

henjoe avatar Apr 19 '24 15:04 henjoe

convert using a function is available only on my branch. sorry!

On Sunday, July 21, 2024 at 12:35:54 AM GMT+3, haslish ***@***.***> wrote:  

@bogdanvaduva How do i get the convert using a function? My tag options dont look the same. Skarmbild.fran.2024-07-20.23-32-15.png (view on web) Skarmbild.fran.2024-07-20.23-34-54.png (view on web)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

bogdanvaduva avatar Jul 21 '24 06:07 bogdanvaduva

Not yet included in the latest released (v1.9) but upon checking the Master branch (v1.2), frangoteam already included it. So expect on the sooner released we will have this functionalities.

henjoe avatar Jul 21 '24 06:07 henjoe

Hi @henjoe , I see that you have implemented data through/to drill down, can you show the code you modified? Thank you very much.

love2koko avatar Jul 22 '24 09:07 love2koko

Hi @henjoe , I see that you have implemented data through/to drill down, can you show the code you modified? Thank you very much.

I Actually copied the forked version with "data convertion". I realized it's a much better than what I had.

henjoe avatar Jul 22 '24 10:07 henjoe

Have you try to define a script bind to the tag?

unocelli avatar Aug 01 '24 11:08 unocelli

@unocelli i have not (thanks for the ideea), but I've wanted to save the values into the database and for that I've used device's option(s) (it was the whole reason for adding that option). Great job!

bogdanvaduva avatar Aug 01 '24 11:08 bogdanvaduva