bt-mqtt-gateway
bt-mqtt-gateway copied to clipboard
Feature: On demand device polling
Description
This adds on-demand polling to the devices which support it.
It is used by publishing an empty MQTT message to the /poll topic of a device or device-type.
Usage examples:
# Will poll the scale
mosquitto_pub -h localhost -t 'miscale/poll' -m ''
# Will poll all MiFlora devices
mosquitto_pub -h localhost -t 'miflora/poll' -m ''
# Will poll the specified MiFlora device
mosquitto_pub -h localhost -t 'miflora/herbs/poll' -m ''
Motivation for this change:
It may be desirable to set a long update_interval to conserve battery, but situations can arise which require quicker updates.
An example of this would be using MiFlora devices, you may have them set to update once per 30mins-1hr, however when watering you may want to check their status on demand in order to prevent over-watering.
Or when using BLE tracking, you may want to dynamically poll based on attributes such as GPS location, movement or RSSI values.
Type of change
- [x] New feature (non-breaking change which adds functionality)
- [x] This change requires a documentation update (has been updated)
Hi
thanks for great PR. Added some thoughts. Also maybe we should also do something like /poll_all , and run update_all ?
Thanks heaps @zewelor for the feedback! I was a little hesitant to add heaps for the PR but now I know you like the idea I'll implement the changes you have suggested 😄 👍 I'm thinking maybe changing the poll terminology to update, to keep it consistent with update_interval and update_all.
Seems this is a py3 project would you be okay for me to implement the @property decorator across all the workers for the getter/setter (where applicable)? (https://docs.python.org/3/library/functions.html#property)
Changing poll to some update sounds good, maybe something like flower/force_update or flower/update_stat(e|us). Only flower/update seems a bit non informative, but maybe its just me.
I've looked at @property and sound great. I'm not a python programmer, just learning, that's also why this project, so any python specific improvements or others are welcome :D Project targets python 3.5 so everything supported since 3.5 suits.