Skip to content
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

Support for event data in proper JSON format #20

Open
mguntli opened this issue Jun 20, 2018 · 2 comments
Open

Support for event data in proper JSON format #20

mguntli opened this issue Jun 20, 2018 · 2 comments

Comments

@mguntli
Copy link
Contributor

mguntli commented Jun 20, 2018

Problem:
The current plugin requires it's own syntax of how data is published to particle (key=value):
Particle.publish("tvalue", "temperature=20.7");

Proposal:
It's a common approach to group multiple values together in a single event with JSON format in order to limit the number of messages to the particle cloud.

https://www.w3schools.com/js/js_json_objects.asp
JSON objects are surrounded by curly braces {}.
JSON objects are written in key/value pairs.
Keys must be strings, and values must be a valid JSON data type (string, number, object, array, boolean or null).
Keys and values are separated by a colon.
Each key/value pair is separated by a comma.

As an example, an indoor room sensor might transfer the following values:

  • temperature [°C]
  • humidity [%RH]
  • CO2 [ppm]
  • VOC [ppb]

The corresponding particle event would look like this (data is limited to 255 byte):
Particle.publish("airquality", "{\"temp\":20.7,\"humid\":45,\"voc\":98,\"co2\":410\"}");

@mguntli
Copy link
Contributor Author

mguntli commented Jun 20, 2018

As a first approach see #21 as a start (only a single value, but with a custom split character for key / value pairs).

@norman-thomas
Copy link
Owner

Hi @mguntli,
I'm familiar with JSON. This project is work in progress and, tbh, I haven't continued implementing it in a long time because out of connection stability and speed reasons, I switched to using MQTT for my own projects. What I implemented you can check here: https://github.com/norman-thomas/omni-sense. There I already use JSON as well as single values.
If you would like to have JSON support in this project and have a bit of time, feel free to implement it and I will merge it. I would like to implement it, but sadly am a bit short on time these days.

Thanks for your pull request #21 , I already merged it and hope it helps you for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants