MQTT initial state

In OH 2.4 i did this with a rule, which kicks off when system starts. This rule is sending an empty MQTT message to all my ESP devices, which replies with their actual status. Tasmota firmware does it out of the box, but you can implement this function easily in your own Arduino code as well. So OH will know all devices’ actual state immediately after starting, no need to play with retain flag or persistent services. Rule engine has changed in OH 2.5, no idea if this is still possible, but i assume yes.

Here is my code, if someone needs an example:

rule "Sonoff init"
when
    System started
then
    publish("broker", "cmnd/sonofftouch1/POWER", "")
    publish("broker", "cmnd/sonoff1/POWER", "")
    publish("broker", "cmnd/sonoff2/POWER", "")
    publish("broker", "cmnd/sonoff_s26_1/POWER", "")
end