Best practice to check state as result of command [jython]?

I use Homie (convention for MQTT) for my home automation.

If you don’t know it, the important concept is, that the state is updated via a command to set set the state, e.g. send message “ON” to homie/switch/light/state/set". After the device switched on the switch it answers with message "ON" tohomie/switch/light/state". Other said: the Openhab COMMAND is send on the .../set topic and the device itseld answers with the actual state.

Is there a simple way using jython scripting to check if the state is updated within a configurable time and trigger an action (e.g. telegram message) otherwise?

Please note, that the MQTT items are configured to post commands to MQTT, receive updates from MQTT and autoupdate is false, so the item already has the correct behaviour.

In detail:

  • If a command does not result in a state change within time t_rb a action shall be triggered.
  • If a new command is received within t_rb, the previous supervision shall be cancelled.

Optional/extension:

  • It should be possible to compare the state with another item, e.g. a contact that closes as a result of switching ON a switch.