hello,
In OH2 I had inbound MQTT command messages that would drive a OH switch to toggle ON or OFF.
This was applied in the items file.
The channels line items shown in the example below is me trying out channels to migrate OH2->OH3.
Example OH2 item below
Switch KitchenLightSwitch1 "Kitchen 1" <light> (gAllLights,gAllKitchenLights) [ "Lighting" ]
{channel = "mqtt:topic:pi4MqttBroker:KitchenLightSwitch1:light",
channel = "mqtt:topic:pi4MqttBroker:Switchboard1:shieldA_switch_Relay1",
channel = "mqtt:topic:pi4MqttBroker:HMI:KitchenLightSwitch1",
channel = "mqtt:topic:pi4MqttBroker:HMI_listen_commands:KitchenLightSwitch1",
autoupdate="false" ,mqtt="
<[broker:myhome/kitchen/light/switch/row1/command:command:MAP(arduino.map)],]
<[broker:myhome/kitchen/light/switch/row1/command:command:MAP(arduino.map)],
>[broker:myhome/switchboard/switchboard1/command:command:ON:A,1,1],
>[broker:myhome/switchboard/switchboard1/command:command:OFF:A,1,0],
>[broker:myhome/HMI/page0/kitchen/light/switch/row1/state:state:ON:1],
>[broker:myhome/HMI/page0/kitchen/light/switch/row1/state:state:OFF:0],
<[broker:myhome/switchboard/switchboard1/shieldA/relay1/state:state:MAP(switchboard.map)],
<[broker:myhome/switchboard/switchboard1/shieldA/relay1/state:state:MAP(switchboard.map)],"}
The example above shows an exernal Arduino client can send a MQTT COMMAND topic “:command”
it is inbound to Moquitto broker on OH server denoted by “<”
<[broker:topic:command:]
The inbound COMMAND message would drive the OH switch item to switch ON
The actual status of the switch (i,e.: glowing light bulb) would not change until the required state message had been received.
In OH3, I have been unable to work out how to send a command to command a switch to be ON or OFF.
I’ve only been able to get inbound messages to be received by the stateTopic.
I haved tried to create a Thing in OH3 and experimenting with the “isCommand=true” parameter… but my inbound messages to the stateTopic are only ever treated as a change of state, and the switch is never commanded “ON” or “OFF”
any advice on how I should correctly command OH3 switches from an external device appreciated.
YAML extract below from OH3 testing
UID: mqtt:topic:pi4MqttBroker:HMI_listen_commands
label: HMI _listen_commands .HMI_thing
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:pi4MqttBroker
location: HMI
channels:
- id: KitchenLightSwitch1
channelTypeUID: mqtt:switch
label: KitchenLightSwitch1 .HMI_listen_commands
description: null
configuration:
retained: false
postCommand: false
formatBeforePublish: “%s”
isCommand: true
stateTopic: myhome/kitchen/light/switch/row1/command
off: “0”
on: “1”