Publish ANT+ data to MQTT server#123
Merged
Merged
Conversation
This adds an abstraction layer to the influx command, in preparation for adding an MQTT target. All ANT+ handling is moved into `base/datatarget.py` and only handling of Influx specifics is left in the influx command itself. The logic and code is essentially unchanged, although it has been moved around some, and changed into a class structure. The only visible change should be a slight formatting change in the influx command help, grouping the influx specific options.
Allows sending received ANT+ packets to an MQTT server, in a similar way to how the InfluxDB subparser works. By default, data will be posted to the topic `openant/<DeviceType>/<DeviceId>`. This can be overridden with the option `--device-topic`, which lets the user directly control which topic is used for a given device. By default, data will be posted as a single JSON data string to the topic, since this appears to be most common method in use. Alternatively, by enabling the `--topic-per-field` option, data will be posted as individual topic belov the device. E.g.: `openant/HeartRate/54368/heart_rate`.
datetime.UTC was added in 3.11.
Contributor
Author
|
As a bonus, this PR should also make it relatively simple to add other targets to send data to, as long as they can follow a simple pattern of "Perform initialisation, perform an action for every received packet, perform clean-up/close". |
Collaborator
|
Thanks for the comprehensive PR including tidying some of the old code. The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allows sending received ANT+ packets to an MQTT server, in a similar way to how the InfluxDB subparser works. This adds an optional dependency on paho-mqtt with the selector "mqtt".
By default, data will be posted to the topic
openant/<DeviceType>/<DeviceId>. This can be overridden with the option--device-topic, which lets the user directly control which topic is used for a given device. This might be needed for easier integration with external systems.By default, data will be posted as a single JSON data string to the topic (e.g.
openant/HeartRate/54368), since this appears to be most common method in use. Alternatively, by enabling the--topic-per-fieldoption, data will be posted as individual topic below the device. E.g.:openant/HeartRate/54368/heart_ratewill contain a single integer.