MQTT commandTopic is not updating for Tuya TS011F_plug_1

  • OS: Ubuntu
  • Java Runtime Environment: openjdk 17.0.5 2022-10-18
  • openHAB version: openHAB 4.0.0~S3292-1

I have a problem with Tuya TS011F_plug_1 - it’s with original soft.
State switch is not properly working - I can get a proper state, but it seems commandTopic is not sending data.
In general - states of the rest channels are readable and properly updated.

Channel configuration:

  • id: state
    channelTypeUID: mqtt:switch
    label: state
    description: null
    configuration:
    commandTopic: zigbee2mqtt/zigbee_gn/set/state
    stateTopic: zigbee2mqtt/zigbee_gn/state
    off: OFF
    on: ON

I’ve tried with:

  • formatBeforePublish: ‘{“state”:“%s”}’
    commandTopic: zigbee2mqtt/zigbee_gn/set

and it’s also not working.
When I’m trying to set OFF state using BasicUI it’s off for few seconds and back to state ON.

Any ideas what could be wrong?

We need more information. What’s in the logs? In particular errors in openhab.log and the relevant entries in events.log.

When posting code or logs, please use code fences.

```
code goes here
```

What specifically is not working? No MQTT message is sent at all? The format of the message sent is incorrect? The end device is not reading the message?

It’s another problem :slight_smile: - I don’t see anything in logs for mqtt.
I’ve tried to set logging for all MQTT bundles to DEBUG in karaf but it’s still no info.
I have some old pax.logging file - can it cause it?

If it’s not the standard one than yes, Karaf is updating a logging config that it can’t read.

But you should at least be seeing events on the Item in events.log. You should be seeing the Things come ONLINE or go OFFLINE as they are initialized or encounter an error.

Any error should appear in the logs no matter what.

I think that I don’t have events.log enabled :slight_smile:
When I’m checking /var/log/openhab it doesn’t exist.
It thought, everything should go to openhab.log but it seems it’s not :slight_smile:

Edit:
I finally ‘update’ logging events :smiley:
What I got


2023-02-02 18:12:10.373 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'gniazdkoSzafa' received command OFF
2023-02-02 18:12:10.375 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'gniazdkoSzafa' predicted to become OFF
2023-02-02 18:12:10.380 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'gniazdkoSzafa' changed from ON to OFF
2023-02-02 18:12:13.134 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'gniazdkoSzafa' changed from OFF to ON

Update to the latest snap 4.0.0~S3299-1 didn’t help :frowning:

I’ve changed logging:

openHAB Add-ons :: Bundles :: MQTT Broker Binding
openHAB Add-ons :: Bundles :: MQTT Things and Channels
openHAB Core :: Bundles :: MQTT Transport

to DEBUG, but I still don’t see information from MQTT like:

..[mqtt.generic.AbstractMQTTThingHandler] - Successfully published value...

List all MQTT related bindings:

openhab> list | grep -i mqtt
236 x Active x  80 x 1.2.2                  x hivemq-mqtt-client
267 x Active x  80 x 3.4.0.202212140352     x openHAB Add-ons :: Bundles :: MQTT Broker Binding
268 x Active x  81 x 3.4.0.202212140422     x openHAB Add-ons :: Bundles :: MQTT EspMilightHub
269 x Active x  81 x 3.4.0.202212140422     x openHAB Add-ons :: Bundles :: MQTT Things and Channels
270 x Active x  82 x 3.4.0.202212140423     x openHAB Add-ons :: Bundles :: MQTT HomeAssistant Convention
271 x Active x  82 x 3.4.0.202212140423     x openHAB Add-ons :: Bundles :: MQTT Homie Convention
290 x Active x  80 x 3.4.0.202212131823     x openHAB Core :: Bundles :: MQTT Transport

Use mosquitto_sub -u <user> -P <pwd> -v -t zigbee2mqtt/# | grep zigbee_gn to sniff relevant MQTT messages.

FWIW, the channel configuration of my TS011F_plug_1:

channels:
  - id: Switch
    channelTypeUID: mqtt:switch
    label: Switch
    description: ""
    configuration:
      commandTopic: zigbee2mqtt/0xa4c1387f88XXXXXX/set/state
      stateTopic: zigbee2mqtt/0xa4c1387f88XXXXXX
      transformationPattern: JSONPATH:$.state
  - id: Power
    channelTypeUID: mqtt:number
    label: Power
    description: ""
    configuration:
      stateTopic: zigbee2mqtt/0xa4c1387f88XXXXXX
      transformationPattern: JSONPATH:$.power
      unit: W
  - id: Current
    channelTypeUID: mqtt:number
    label: Current
    description: ""
    configuration:
      stateTopic: zigbee2mqtt/0xa4c1387f88XXXXXX
      transformationPattern: JSONPATH:$.current
      unit: A
  - id: Voltage
    channelTypeUID: mqtt:number
    label: Voltage
    description: ""
    configuration:
      stateTopic: zigbee2mqtt/0xa4c1387f88XXXXXX
      transformationPattern: JSONPATH:$.voltage
      unit: V
  - id: Energy
    channelTypeUID: mqtt:number
    label: Energy
    description: ""
    configuration:
      stateTopic: zigbee2mqtt/0xa4c1387f88XXXXXX
      transformationPattern: JSONPATH:$.energy
      unit: kWh

And does the ON command MQTT message go out? If the format of the message what the destination requires?

As I mention I couldn’t find any mqtt notifications regarding sending a message. Do I need to install any additional bundles or configure a thing ? Mosquitto bridge is rather set properly - values are readable.
Manual publishing with mosquitto_pub is working fine.

How do you initiate a state change that doesn’t work?

Unfortunately not, even directly from channel it’s not working :frowning:

Very strange - I’m out of ideas.

Try setting up a new minimal Thing:
Settings → Things → [+] → MQTT Binding → Generic MQTT Thing, connect it to your MQTT Bridge and add and configure an ON/OFF channel for your plug.

But you said that in an ambiguous way. You imply you’ve only tried looking at logs. I’m asking about what’s seen on the broker using MQTTExplorer or mosquitto_sub or the like.

Ok, I found an issue - there was a problem with a channel.
In a main view it was recognized as Switch:

image

but when I enter it there was a String:

image

I’ve deleted channel and add it again, then it helps :slight_smile:

Thanks for info and suggestions :smiley: