arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.04k stars 4.78k forks source link

let berry drivers provide "after_teleperiod" handlers #21351

Closed dgwynne closed 5 months ago

dgwynne commented 5 months ago

This is useful if you want to periodically report the state of something handled separately to the sensors output.

Description:

I'm working on Yet Another(tm) driver for micradar devices, the R60ASM1 in particular, which seems to work in a similar fashion to a TuyaMCU device in that it has a concept of independent datapoints that report at different times. Because there are so many different datapoints, the driver relays their updates as separate mqtt topics, (eg, tele/%topic%/R60ASM1/BreathingRate or tele/%topic%/R60ASM1/MonitorSwitch) rather than shove several dozen bits of info into the SENSORS or STATE payloads. Some datapoints are updated very infrequently, so it's handy to report them every teleperiod so stupid downstream systems (eg, HA) don't forget what's going on.

C drivers can hook FUNC_AFTER_TELEPERIOD for similar reasons. This extends it to Berry drivers too.

Checklist:

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

dgwynne commented 5 months ago

https://github.com/dgwynne/berry is where the berry driver is atm.

s-hadinger commented 5 months ago

Awesome, thanks