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

JSON output and single query? #12

Open
ctschach opened this issue May 3, 2022 · 2 comments
Open

JSON output and single query? #12

ctschach opened this issue May 3, 2022 · 2 comments

Comments

@ctschach
Copy link

ctschach commented May 3, 2022

Thanks for the brilliant work on this project. Pretty amazing what you have created so far.

I totally understand your approach of getting data in the MQTT. However, I would love to use it for single queries. So instead of running a delay and then query the device again, I would like to just quit the script. In addition I would love you you could do a JSON encoded output to stdout.

I'm not that familiar with Python, so not sure if I would be able to change the code accordingly (and pretty).

But is this anything which we could add to the project? Or would this be against the overall concept?

@birdie1
Copy link
Owner

birdie1 commented May 8, 2022

Thanks!
I already thought about something like that and started some time ago to introduce the "direct disconnect method". I can improve it to quit after getting the data once. At least for serial and bluetooth-ble connection method. The bluetooth connection method get its data via async functions and not always all data, but I could add an config parameter to define for which data should be waited.

The output via JSON shouldn't be to complicated.

Hopefully I find the time next weekend for some programming...

@birdie1
Copy link
Owner

birdie1 commented May 29, 2022

Sorry for the delay.
I have added json as output option in configfile. For serial and bluetooth-ble there is a --direct-disconnect option to run only once. I will try to add a similar option for bluetooth connection method soon.
You may want to add an collection to your configfile and run the program with -c, otherwise it will print the first single value as a single json output and then exit if you use --direct-disconnect. With a collection you can "merge" it into one output with all values.

If it is not clear from my comments in the configfile, I can provide you with a sample config, if you tell me which device and connection method you are using,

Is the output what you expected?

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