Need help with mqqt thing configuration

Hello all,

getting a warning in my mqtt configuration thing

Command 'off' from channel 'mqtt:topic:statusdisplay:status' not supported by type 'OnOffValue': No enum constant

this is my thing configuration:

Thing mqtt:topic:statusdisplay (mqtt:broker:mosquitto) {
Type switch : status "Status" [ stateTopic="HomeStatusDisplay/status", on="ON", off="OFF"]

Where is the issue here?

I think it should be ON and OFF in uppercase letters

in the example it’s lowercase

Are you trying to turn something on or off with this thing or is it just status?

This mine

Type switch : power       "Power"                [stateTopic="stat/snugthermostat/POWER", commandTopic="cmnd/snugthermostat/POWER", on="ON", off="OFF"]

I hope this helps

it’s just a status

I think you need to add some sort of transformation path to extract the information. a bit like this:

Thing mqtt:topic:myMQTTBroker:myDeviceStatusThing (mqtt:broker:myMQTTBroker) {
        Type string : statusChannel "Status Channel" [ stateTopic="your/status/topic",transformationPattern="JSONPATH:$.status ]

if you haven’t already download the jsonpath transformation addon in your bindings section on the webui.

I’m a bit old school on here and still write my items and things files. I’m sure there’s someone on here that can tell you an easier way to do it via the openhab webui.

The lowercase string 'off' is what is coming through from your mqtt topic. However, you have not configured your channel to handle this situation:

Because 'off' does not match either 'ON' or 'OFF', the channel passes the received value directly onto the the linked switch item, and 'off' is not a valid command for a switch item.

When the docs say:

The switch channel by default recognizes "ON" and "OFF" .

what this means is that if those two values are the ones that come through from your topic, then you don’t have to configure the on and off properties. In your case, it appears that the ON state is supposed to be triggered by 'on' and the off state by 'off', so these are the values you have to put into the properties.

Thing mqtt:topic:statusdisplay (mqtt:broker:mosquitto) {
Type switch : status "Status" [ stateTopic="HomeStatusDisplay/status", on="on", off="off"]

In this case, you could get the same effect by writing a quick script that converts the incoming values to uppercase and applying that script as the transformationPattern. Then you wouldn’t have to have the on or off properties because the channel would be handling 'ON' and 'OFF' inputs instead.

I agree with you tried it also with lowercase as you wrote it…same error…and this warning is there since oh4.1m1 that confuses me…

Do you get the same log line when the channel receives 'on'?

UI would look something like this:

I rebooted my system several times and cleared the cache…now no error anymore…so it was a phantom warning…