Hi,
I’m trying to use MQTT to control some Shellys.
I have the input sorted and can read that fine as I get a dedicated MQTT topic:
The output only seems to be available in the full message in ‘switch:0’ and ‘switch:1’.
I am using text configuration files for my MQTT things. Here is my current version:
Thing mqtt:topic:shelly:H1_MainAttic_CeilingLight "Switch,H1,Main Attic,Ceiling Light" (mqtt:broker:aab6726def) [ availabilityTopic="shelly:H1_MainAttic/online", payloadAvailable="true", payloadNotAvailable="false" ] {
Channels:
Type switch : input "Switch On/Off" [
stateTopic="shelly:H1_MainAttic/status/input:0",
transformationPattern= "JSONPATH:$.state",
on= "true",
off= "false"
]
Type switch : output "Output On/Off" [
stateTopic="shelly:H1_MainAttic/status/switch:0",
commandTopic="shelly:H1_MainAttic/command/switch:0",
formatBeforePublish= ""{'id':0, 'source': 'switch', 'output': %s, 'apower': JSONPATH:$.apower, 'voltage': JSONPATH:$.voltage, 'freq': JSONPATH:$.freq, 'current': JSONPATH:$.current, 'aenergy':{'total': JSONPATH:$.aenergy.total,'by_minute':[0.000,0.000,0.000],'minute_ts':1726649820}, 'ret_aenergy':{'total':0.000,'by_minute': JSONPATH:$.aenergy.by_minute,'minute_ts': JSONPATH:$.aenergy.minute_ts},'temperature':{'tC': JSONPATH:$.temperature.tC, 'tF': JSONPATH:$.temperature.tF}}",
transformationPattern= "JSONPATH:$.output",
on= "true",
off= "false"
]
I am unsure about the ‘commandTopic’ and the ‘formatBeforePublish’. I can read the value, so the state topic is working, but I can’t send a command.
Can anyone help? I found some posts in the forum that I thought would help, but this is as far as I can get on my own.