[OH3] MQTT Device not turning off

  • Platform information:
    • Hardware: Pi4
    • OS: openhabian
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version:3
  • Issue of the topic: OH3 does not appear to be trying to turn off the switch

I have been using OH2.4 for years and now just learning OH3.
I have an extensive MQTT network running on OH2.4 and enabled Autodiscovery on two devices so that OH3 could pick these up and bring them in. In addition, I created a new MQTT thing from scratch.

All of these are detected and online. Using the GUI switch in the thing/item editor, I can turn them on via a MQTT message but when I toggle the switch back to off, OH3 doesn’t do anything.

When viewing with the tail viewer I get the below entries showing OH3 acknowledging my request to turn the switch On and sending out the command.

When toggling the switch Off. There is nothing at all in the tale viewer and nothing being transmitted on the MQTT network (Verified via MQTTLens). Note using MQTTLens I can turn the device On/Off via MQTTLens.

2020-12-30 16:11:47.097 [INFO ] [openhab.event.ItemCommandEvent ] - Item ‘GenioAdaptor_Relay’ received command ON

2020-12-30 16:11:47.101 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item ‘GenioAdaptor_Relay’ predicted to become ON

2020-12-30 16:11:47.107 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘GenioAdaptor_Relay’ changed from OFF to ON

This is my item configuration

UID: mqtt:topic:genio_adaptor
label: Genio Adaptor
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:f44b9520f1
channels:

  • id: relay
    channelTypeUID: mqtt:switch
    label: Relay
    description: “”
    configuration:
    commandTopic: tuya/genio_adaptor/dps/1/command
    stateTopic: tuya/genio_adaptor/dps/1/state
    off: “false”
    on: “true”

Any ideas?

Interesting! Here’s a post from yesterday with the same issue - MQTT device won’t turn off. No idea why it’s happening - my devices seem to work fine, though I don’t use auto discovery. Not very helpful, I know!

Did you upgrade to OH3, or is this a clean install? What Java version have you got installed?

I have exactly the same issue here with my Tradfri light bulbs.
I´will try another bulbs maybe later this day…

This is a clean openhabian install.
I would think this install has put in the required java version but not sure how to check.

In MainUI go to Help & About and click on Technical Information.

I will assume you have the spaces correct after the configuration like

  - id: relay
    channelTypeUID: mqtt:switch
    label: Relay
    description: ""
    configuration:
      commandTopic: tuya/genio_adaptor/dps/1/command
      stateTopic: tuya/genio_adaptor/dps/1/state
      off: "false"
      on: "true"

this code is working for me in both directions

Can you connect another client like http://mqtt-explorer.com/ and confirm that the messages are being sent to the MQTT broker from openHAB

You can then publish messages to the state topic simulating changes from the tuya script/api that you are running.

Which TUYA MQTT script/program are you using?

2020-12-31 12:56:29.000 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'GenericMQTTThing_Relay' received command ON
2020-12-31 12:56:29.002 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'GenericMQTTThing_Relay' predicted to become ON
2020-12-31 12:56:29.012 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GenericMQTTThing_Relay' changed from OFF to ON
2020-12-31 12:56:37.067 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'GenericMQTTThing_Relay' received command OFF
2020-12-31 12:56:37.070 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'GenericMQTTThing_Relay' predicted to become OFF
2020-12-31 12:56:37.073 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GenericMQTTThing_Relay' changed from ON to OFF

Maybe delete the thing and start again you cant change the channelTypeUID: after it has been created

It turns out that in the other thread it was a device/browser issue - perhaps try a different browser on a different device?

Same here… I was struggling the whole evening, trying to switch a bulb on and off in chrome.
opened the page on my android using chrome, works like a charm. :grimacing:

There is now an open issue with some successes for some: Switch OFF Command stuck · Issue #731 · openhab/openhab-webui · GitHub