I implemented a primitive extra-slow PWM to control a heater with a zero-cross SSR. Used Tasmota and some of its rules voodoo. I plan to show it as a slider or knob in UI.
Problem is, the PWM state is not reported in any repetitive way, I need to poll for it. When PWM receives a message at cmnd/pwm/PulseTime, it sends the value to stat/pwm/RESULT. Until that, the heater level is unknown. In other words, despite the “MQTT State Topic” exists, nothing is published there until a polling completes.
The problem could be bypassed of course. The PWM may be modified so it will reset to zero after start (maybe not a bad idea actually). The polling may be happening in a crone Rule (ugly). Also I can probably modify the PWM so it will report its state per each cycle.
I wonder though, is there a way to have smth like pre-hook that will be issued when OH is interested in the Thing’s state? Or maybe there is some other standard way to achieve that?