Zigbee2tasmota mqtt command

I am trying to send on/off mqtt command to a zigbee plug binded to my zigbee2tasmota bridge.Command topic is cmnd/zbBridge/ZbSend but i somehow have to send with that a payload like { “device”:“zbPlug1”, “send”:{“Power”:“On”} } or { “device”:“zbPlug1”, “send”:{“Power”:“Off”} } .I clearly have no idea how to do that :slight_smile: .
i have setup my channel like this

and i can now get the state of my plug.How can i set the command topic?

Click “Show Advanced”, then check the binding documentation for how to use to Format Before Publish stuff.

1 Like

got it mate ,many thnx

Hi

I’m struggling with the same, but can’t find a solution. To toggle a zigbee switch I can execute the command : ZbSend {"Device":"niko_socket_01","Send":{"Power":toggle}}

I’ve this in my Thing, but the command is not working. Reading the state of the switch is working perfect.

- id: power2
    channelTypeUID: mqtt:string
    label: Power switch
    description: null
    configuration:
      commandTopic: cmnd/sonoffbridge/ZbSend
      transformationPatternOut: {"Device":"niko_socket_01","Send":{"Power":toggle}}
      stateTopic: tele/sonoffbridge/niko_socket_01/SENSOR
      transformationPattern: REGEX:(.*\"Power\".*)∩JSONPATH:$.ZbReceived.niko_socket_01.Power

You need to use the format before publish feature, as mentioned two posts above yours.

tried it today (was on holiday last week), bit without luck.

Sending a the command {"Device":"niko_socket_01","Send":{"Power":0}} or {"Device":"niko_socket_01","Send":{"Power":1}} to topic cmnd/sonoffbridge/ZbSend via eg MQTT Explorer works.

  - id: power2
    channelTypeUID: mqtt:switch
    label: Power switch
    description: null
    configuration:
      commandTopic: cmnd/sonoffbridge/ZbSend
      formatBeforePublish: '{"Device":"niko_socket_01","Send":{"Power":%s}}'
      stateTopic: tele/sonoffbridge/niko_socket_01/SENSOR
      transformationPattern: REGEX:(.*\"Power\".*)∩JSONPATH:$.ZbReceived.niko_socket_01.Power
      off: "0"
      on: "1"

What am I missing?

What do you see in MQTT Explorer when you command the linked Item from with openHAB?

Nothing to see in MQTT Explorer, it seems that OH doesn’t sent anything.
I think this has to do because I’m sending a json and not a normal string.

I saw another post and tried this: '{\"Device\":\"niko_socket_01\",\"Send\":{\"Power\":%s}}', but without luck.

Others do it via a rule, this is working fine:

val value = '{\"Device\":\"niko_socket_01\",\"Send\":{\"Power\":toggle}}'  
val actions = getActions("mqtt","mqtt:broker:mosquitto")
actions.publishMQTT("cmnd/sonoffbridge/ZbSend",value)

So maybe I need to continue from the rule…