Thank you for this tutorial @rlkoshak
I attach a modified tested version of Rules DSL, which is coherent with the naming above
rule "Send commands to HestiaPi"
when
Item vHeating_Mode received command
then
val mqttActions = getActions("mqtt","<broker Thing ID>") // replace <broker Thing ID with the Thing UID for your Broker Thing
// Only publish the command if the new state is different from the message currently on the MQTT topic.
// This will prevent loops.
if(vHeating_Mode.state != vHeating_Mode_Stat.state) {
mqttActions.publishMQTT("hestia/local/stat/heatingmode", receivedCommand.toString, true) // the last true makes the message retained
}
if(vHeating_Mode.state != vHeating_Mode_Cmnd.state) {
mqttActions.publishMQTT("hestia/local/cmnd/heatingmode", receivedCommand.toString, true)
}
end
rule "Updates from HestiaPi"
when
Item vHeating_Mode_Stat changed or
Item vHeating_Mode_Cmnd changed
then
// Only update the proxy if the change is different from the current proxy state. This helps
// avoid loops.
if(triggeringItem.state != vHeating_Mode.state) vHeating_Mode.postUpdate(triggeringItem.state)
end