Publish MQTT from "String" Item

I have a TV “Thing” with multiple channels linking Items such as POWER, VOL, INPUT, MUTE. The items which are Switch Type such as POWER and MUTE I am able to publish MQTT when using “.sendCommand(ON)” in a rule, but the String Items such as VOL and INPUT won’t publish.

.thing file

Thing mqtt:topic:MBR_Vizio "Master Bedroom TV" (mqtt:broker:unRAID-mosquitto) @ "Master Bedroom"{    
    Type switch : Power         [stateTopic="stat/MBR_Vizio/POWER" , transformationPattern="JSONPATH:$.ITEMS.[0].VALUE", commandTopic="cmnd/MBR_Vizio/POWER" ]
    Type string : Volume        [stateTopic="stat/MBR_Vizio/VOLUME", transformationPattern="JSONPATH:$.ITEMS.[0].VALUE"] 
    Type string : Input         [stateTopic="stat/MBR_Vizio/INPUT", transformationPattern="JSONPATH:$.ITEMS.[0].VALUE", commandTopic="cmnd/MBR_Vizio/INPUT", postCommand="true"]
    Type switch : Mute          [stateTopic="stat/MBR_Vizio/MUTE" , transformationPattern="JSONPATH:$.ITEMS[0].INDEX", commandTopic="cmnd/MBR_Vizio/MUTE" ]

Item file

Switch MBR_Vizio_Power      "Power ON / OFF"    { channel="mqtt:topic:MBR_Vizio:Power" }
String MBR_Vizio_Volume     "Volume [%s ]"      { channel="mqtt:topic:MBR_Vizio:Volume" }
String MBR_Vizio_Input      "Input"             { channel="mqtt:topic:MBR_Vizio:Input" }
Switch MBR_Vizio_Mute       "Mute"              { channel="mqtt:topic:MBR_Vizio:Mute" }

sample rule

rule "TEST Input"
    Time cron "0 30 06 ? * MON,TUE,WED,THU,FRI *"

I thought maybe the “postCommand=“true”” might be the issue but that didn’t change anything and the Power works fine without it. It only seems to be an issue with the “string” items, all of my switches work just fine. Everything receives the stateTopics and updates fine, it’s only the publishing of the string.

This converts incoming MQTT messages received on stateTopic into openHAB commands on the channel to the linked Item, instead of the usual state update.
Careful to understand the consequences when using this option on channels with commandTopic also specified, because the incoming command will trigger an outgoing publish to that as well.

The channel linked to this Item has no commandTopic, so nothing will ever be published.

This one looks more promising, it should be publishing to cmnd/MBR_Vizio/INPUT

Note that if you’ve been editing your Things file you may need to restart the binding to be sure the latest edits are actually in use.

Thanks for the explanation on the “postCommand” functionality, that makes sense.
Good catch on the Volume. As for the Input section, after a few reboots I finally got it to work.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.