Setting up Zigbee devices using Sonoff ZBBridge Tasmota 100 and MQTT

I’m trying to set up Zigbee devices to be controlled via MQTT and Tasmota10.0 on the Sonoff ZBBridge

All the components (Tasmota, ZB device, Broker, Integration) seem to be working.

I can publish topics manually on the MQTT Config page and control a device.
I can listen to topics and see devices status

But … there doesn’t seem to be either

a) and kind of discovery system (I’ve tried SetOption19 1 on the Tasmota console and nothing happens
b) any documentation as to how to set up configuration.yaml to access these devices

There are many simple examples that seem to define lights and switches in terms of a ‘topic’ that turns them off and on - but nothing that explains how to control devices when the ID is in the payload

Does any one have pointers to the appropriate documentation or examples? Or is there a discovery system that I’m completely failing to understand?

Ian B.

Using Zigbee2Tasmota, there is no discovery.

https://tasmota.github.io/docs/Zigbee/

Hi Francis

Do you know of any references for setting up configuration.yaml to control devices via zigbee2tasmota?
I have searched long and hard and found nothing?

Ian B

I have put some examples in the forum the last months. Maybe give an example of what you receive over mqtt.

Cheers - I’ll have a l look :grinning:

If I publish this topic:

cmnd/tasmota_AAB2FF/zbsend

with a payload

{"device":"0x5c23","send":{"Power":"Off"} }

The device operates and the response given is:

tele/tasmota_AAB2FF/SENSOR = {"ZbReceived":{"0x5C23" {"Device":"0x5C23","Power":0,"Endpoint":1,"LinkQuality":154}}}

My problem is how to represent this in configuration.yaml so that it works as a device or entity in HA …

I can’t find the information anywhere …

Ian B

Try this:

switch:
  - platform: mqtt
    unique_id: "996080f7-aaa9-4850-baed-31c9298d6956"
    name: "whatever"
    state_topic: "tele/tasmota_AAB2FF/SENSOR"
    value_template: "{{ value_json['ZbReceived']['0x5C23']['Power'] }}"
    state_on: 1 
    state_off: 0 
    command_topic: "cmnd/tasmota_AAB2FF/ZbSend"
    payload_on: '{"device":"0x5c23","send":{"Power":"On"} }' 
    payload_off: '{"device":"0x5c23","send":{"Power":"Off"} }'
    availability_topic: "tele/tasmota_AAB2FF/LWT"
    payload_available: "Online"
    payload_not_available: "Offline"
    optimistic: false
    qos: 0
2 Likes

Hi Francis - that’s great thank you. I will try that this morning! :slight_smile:

Hi Francis - have tried this with partial success

light:
  - platform: mqtt
    unique_id: "Woolley_Ox5c23"
    name: "Desk socket"
    command_topic: "cmnd/tasmota_AAB2FF/ZbSend"
    payload_on: '{"device":"0x5c23","send":{"Power": 1}}'
    payload_off: '{"device":"0x5c23","send":{"Power": 0}}'
    state_topic: "tele/tasmota_AAB2FF/SENSOR"
    state_value_template: '{{ trigger.payload["ZbReceived"]["0x5C23"]["Power"] }}'
    availability_topic: "tele/tasmota_AAB2FF/LWT"
    payload_available: "Online"
    payload_not_available: "Offline"
    optimistic: false
    qos: 0

Check config throws an error saying that state_on and state_off are not valid options.
Searched about a bit and found the ‘state_value_template’ used in a few places - tried that in this way

state_value_template: '{{ value_json["ZbReceived"]["0x5C23"]["Power"] }}

and

state_value_template: '{{ trigger.payload["ZbReceived"]["0x5C23"]["Power"] }}

But neither seem to update the state appropriately, so the lights shos as beign ‘off’ even when succesfully switched on …

Is there anyway to debug these templates (I’ve looked at the template checker in the development tools - but it doesnt seem to operate in content so value_json is not available to be evaluated

Cheers

Ian B.

It does not throw an error in config check if put under the switch domain. Did you try that ?

1 Like

MQTT lights are difficult

I tried this with the switch definition :

image

image

image

image

image

So you can create your light like this :

   - platform: switch
     name: Desk Light
     entity_id: switch.desk_light

That works!

Perfect thank you

MQTT lights are difficult

I always seem to pick the hardest implementation available!

Not sure how I translated switch → light bu that is indeed the issue.

Thanks again.

Ian B

Great job to both!

That’s exactly what I am trying now.
Can you please share the final yaml code?

Thanks

this works in case you’re still looking:

- platform: mqtt
  schema: template
  name: parking
  state_topic: tele/z2tgf/parking/SENSOR
  command_topic: cmnd/z2tgf/ZbSend
  command_on_template: '{"Device":"parking","Send":{"Power":1}}'
  command_off_template: '{"Device":"parking","Send":{"Power":0}}'
  optimistic: false
  qos: 1
  retain: false
  state_template: '{{value_json.ZbReceived["parking"].Power|replace("1","on")|replace("0","off")}}'
  icon: mdi:light-switch

you need to turn on the following:

By setting SetOption89 to 1, each device is given their own topic, tele/%topic%/<device>/SENSOR
SetOption112 to 1 so that the friendly name will be used in the MQTT topic instead of the unique identifier
etOption83 1 sensor readings will use the friendly name as JSON key,

2 Likes