Skip to content

Conversation

@rasher
Copy link
Contributor

@rasher rasher commented Aug 17, 2025

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-field option, data will be posted as individual topic below the device. E.g.: openant/HeartRate/54368/heart_rate will contain a single integer.

rasher added 6 commits August 17, 2025 17:21
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.
@rasher
Copy link
Contributor Author

rasher commented Aug 17, 2025

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".

@tuna-f1sh
Copy link
Collaborator

Thanks for the comprehensive PR including tidying some of the old code. The DataTarget is a nice abstraction. Looks good to me so I'll merge.

@tuna-f1sh tuna-f1sh merged commit 7399baf into Tigge:master Aug 18, 2025
9 checks passed
@rasher rasher deleted the mqtt-target branch August 18, 2025 09:56
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

Successfully merging this pull request may close these issues.

2 participants