I’m running OH3 and try to find clean way to control my RF sockets over MQTT with the OpenMQTTGateway.
Actually I use a rule that sends a constant JSON formatted string to a EXEC thing that I achieve a output like this: Full:
mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoRF2 -m “{“groupBit”:0,“period”:273,“address”:54668270,“unit”:1,“switchType”:0}” Reduced
mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoRF2 -m “{“address”:54668270,“unit”:1,“switchType”:0}”
The Rule
rule "Alex Desk Lamp"
when Item Alex_LED_Desk changed
then
if(Alex_LED_Desk.state == ON)
rfExec.sendCommand("\"{\"groupBit\":0,\"period\":273,\"address\":54668270,\"unit\":1,\"switchType\":1}\"")
else
rfExec.sendCommand("\"{\"groupBit\":0,\"period\":273,\"address\":54668270,\"unit\":1,\"switchType\":0}\"")
end
As you can see there are 3 parameters I have to cover.
The switchType Bit is eq. to ON/OFF.
Is it possible to create things/items, that have the adress and unit JSON item in a static way,
so that I only have to pass the ON/OFF value?
If you must publish from a rule (for example, you want to publish JSON based on the state of two different Items), then use the MQTT Action instead of exec.