New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json payload #49

Closed
1technophile opened this Issue May 20, 2017 · 16 comments

Comments

Projects
4 participants
@1technophile
Copy link
Owner

1technophile commented May 20, 2017

instead of passing parameters into the MQTT subject use json

@1technophile 1technophile modified the milestone: V0.5 May 20, 2017

@marksev1

This comment has been minimized.

Copy link

marksev1 commented May 23, 2017

It might be also cool if it was definable to use either way? (the old or the new way)

@1technophile

This comment has been minimized.

Copy link
Owner Author

1technophile commented May 23, 2017

yes good idea at short term, at mid term I will remove the old way.
This way the transition can be progressive. Thanks for the idea!

@jumpalottahigh

This comment has been minimized.

Copy link
Contributor

jumpalottahigh commented Jun 9, 2017

What do you think about the ArduinoJSON library? In my tests it has worked nicely. Maybe we can consider using it for the JSON payload?
https://github.com/bblanchon/ArduinoJson/

@1technophile

This comment has been minimized.

Copy link
Owner Author

1technophile commented Jun 9, 2017

Yes I think it is a good path

@posicat

This comment has been minimized.

Copy link
Contributor

posicat commented Jan 18, 2018

I just got my IR detection working, and saw that I get 4 MQTT messages back for each time I press the button. I would definitely prefer to get the data back as one JSON message with fields for each of the parameters. My main concerns is that I want to have multiple IR gateways, and if 2 devices report at the same time it's harder to determine which go together.

1technophile added a commit that referenced this issue Mar 8, 2018

@posicat

This comment has been minimized.

Copy link
Contributor

posicat commented Mar 26, 2018

It seems like we could have 2 .cpp files, one that would create an MQTT message for each return parameter, and another that would accumulate a JSON message for each of those parameters.

ReporterJSON report // Uncomment only one to enable that reporting method
#ReporterMQTT report

For example if we added a device for light sensing that returned RGB values, it could call:
report.channel("LightSense");
report.value("Red",128);
report.value("Green ",200);
report.value("Blue ",59);
report.send();

if we include the MQTT reporter library it would send back:
home/LighSense/Red 128
home/LightSense/Green 200
home/LightSense/Blue 59

If we included the JSON reporter library it would instead return
home/json/ {"LightSense":"{"Red":128,"Green":200,"Blue":59}}

This might help reduce a lot of redundant code across the project, and allow people to add new sensors/features to the software more readily (They just hook into the same reporting method to send back data)

@1technophile

This comment has been minimized.

Copy link
Owner Author

1technophile commented Mar 26, 2018

I agree that we should reduce redundant code, for sensors @broekema proposed an implementation #168
that can be transposed to gateways.
Meaning that one object could manage:
-publishing
-receiving
once instanciated for a particular gateway
Json could be handled in this object.

Regarding the division in two cpp files depending on the publishing methods I don't know what are the cons and pros

I was thinking about begining by json implementation with the current code, publish a new release and refactor it for the next version. But if there is people for helping me refactoring it in the same time we can do both for the next version.

@posicat

This comment has been minimized.

Copy link
Contributor

posicat commented Mar 26, 2018

I'd love to help with the refactor, I'll take a look at the code and the @brokema code and see if there's something I can add to it.

@1technophile

This comment has been minimized.

Copy link
Owner Author

1technophile commented Mar 27, 2018

great, don't hesitate to submit a pull request for one gateway for example.
The goal would be to handle all the mechanism that are proper to a gateway on this object

@1technophile

This comment has been minimized.

Copy link
Owner Author

1technophile commented Apr 4, 2018

@posicat hello, did you progressed in your searches ?

@posicat

This comment has been minimized.

Copy link
Contributor

posicat commented Apr 5, 2018

I cloned the code at home and read through quite a lot of it. I have some ideas on how to create a common report library that all the modules can use, but life has been busy and I haven't gotten time to really do much coding yet.

@1technophile

This comment has been minimized.

Copy link
Owner Author

1technophile commented Apr 21, 2018

@posicat Hello,

I'm asking myself if I wait for json to be implemented to release v0.7, what is your opinion?

@posicat

This comment has been minimized.

Copy link
Contributor

posicat commented Apr 26, 2018

Life's gotten busy lately, I've had relatives moving, and house projects I've had to get to first. I do want to work on the JSON code but I'm not sure I'll have time to do that anytime soon.

@1technophile 1technophile modified the milestones: V0.7, v0.8 Apr 29, 2018

@1technophile 1technophile added this to To do in V0.8 Jul 22, 2018

@1technophile 1technophile removed this from To do in V0.8 Aug 23, 2018

@1technophile 1technophile modified the milestones: v0.8, V0.9 Aug 23, 2018

@1technophile 1technophile added this to In progress in V0.9 Sep 24, 2018

@1technophile 1technophile self-assigned this Sep 24, 2018

@1technophile

This comment has been minimized.

Copy link
Owner Author

1technophile commented Sep 24, 2018

Hello,

I'm going to work on this for info

@1technophile

This comment has been minimized.

Copy link
Owner Author

1technophile commented Nov 5, 2018

#298 done

@1technophile

This comment has been minimized.

Copy link
Owner Author

1technophile commented Nov 5, 2018

to deactivate jsonpublishing:
comment this line

to deactivatesimple publishing:
comment this line

@1technophile 1technophile moved this from In progress to Done in V0.9 Nov 25, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment