MQTT switch - off not send

  • Platform information:
    • Hardware: Raspberry PI 4
    • OS: Raspian
    • Java Runtime Environment: JRE 11
    • openHAB version: 3

I have setup my sonoff (with Tasmoto firmware) to use the MQTT (version 1.5.7). Situation is that the ‘ON’ command is send to the MQTT topic, but when I switch in openhab the switch back to off, the ‘OFF’ command appears not to be send to the topic.

If I change the custom-on-value to ‘OFF’ (inversing the switch), it is send. It looks like the switch only sends the MQTT command when the item switch is turned on.

Code for the thing/channel:

UID: mqtt:topic:6f14af6b44:757a3400a1
label: V2-SO-Zolderverwarming
thingTypeUID: mqtt:topic
  payloadNotAvailable: Offline
  availabilityTopic: tele/V2-SO-ZolderVerwarming/LWT
  payloadAvailable: Online
bridgeUID: mqtt:broker:6f14af6b44
location: Zolder
  - id: cmndV2SOZolderverwarming
    channelTypeUID: mqtt:switch
    label: Zolderverwarming
    description: ""
      postCommand: false
      retained: false
      qos: 1
      commandTopic: cmnd/V2-SO-ZolderVerwarming/POWER
      stateTopic: stat/V2-SO-ZolderVerwarming/POWER
      off: OFF
      on: ON

Looking at the MQTT using the MQTT explorer:
Start: cmnd and stat POWER is ‘OFF’.
I toggle the switch in openhab to on. MQTT explorer shows the cmnd power is updated to ‘ON’ and the stat power follows directly.
I toggle the switch in openhab to off. MQTT explorer shows the cmnd power is not updated.

Openhab log only states the on command:

2022-03-09 19:54:53.840 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'V2SOZolderverwarming_Zolderverwarming' received command ON
2022-03-09 19:54:53.842 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'V2SOZolderverwarming_Zolderverwarming' predicted to become ON

As I am new to openhab, the first question is: what am I doing incorrect?

I think your problem isat the GUI end.

This confirms it. If no Item command, we simply do not get as far as the MQTT binding.

Unfortunately, I had found the link you provided. I tried the “implicit user role for unauthenticated requests” option with no succes. I can also state that i have not found any system in place that intercepts the calls to the MQTT system. Unlinke this this in my case, the off commands are not even pubished to the topic.

Continue reading on - there’s talk of better behaviour in different browsers, or once some antivirus has been disabled.