How to seperate endpoint status by mqtt for Tasmota zbbrdige

Hello Everyone

I bought the 3 gang zigbee light switch to making it use with Sonoff ZbBridge with tasmota firmware
I can easily command on off and get state of endpoint 1 which is look like this

Each switch is separated by endpoint. LSwitch = endpoint1, CSwitch=endpoint2 and RSwitch=endpoint3

Then I add another channel in things file to add another 2 switches

Type switch : LightSwitchL "LightSwitchLeft" [ stateTopic = "tele/lightswitch/SENSOR" , transformationPattern = "REGEX:(.*\"Power\".*)∩JSONPATH:$.ZbReceived.lightswitch.Power", commandTopic = "cmnd/tasmota_E304CB/ZbSend", formatBeforePublish = "{ \"device\":\"lightswitch\", \"send\":{\"Power\":\"%s\"},\"endpoint\":1 }", on = "1", off = "0" ]
Type switch : LightSwitchC "LightSwitchCenter" [ stateTopic = "tele/lightswitch/SENSOR" , transformationPattern = "REGEX:(.*\"Power\".*)∩JSONPATH:$.ZbReceived.lightswitch.Power", commandTopic = "cmnd/tasmota_E304CB/ZbSend", formatBeforePublish = "{ \"device\":\"lightswitch\", \"send\":{\"Power\":\"%s\"},\"endpoint\":2 }", on = "1", off = "0" ]
Type switch : LightSwitchR "LightSwitchRight" [ stateTopic = "tele/lightswitch/SENSOR" , transformationPattern = "REGEX:(.*\"Power\".*)∩JSONPATH:$.ZbReceived.lightswitch.Power", commandTopic = "cmnd/tasmota_E304CB/ZbSend", formatBeforePublish = "{ \"device\":\"lightswitch\", \"send\":{\"Power\":\"%s\"},\"endpoint\":3 }", on = "1", off = "0" ]

Everything looks fine. I can command to control 3 gang light switch to be ON or OFF separately.
But the problem is. Assume that the current actual light status is OFF OFF OFF. after I turn on left switch by openhab and actual light change to be ON OFF OFF. Actual is fine.
But all of 3 gang status in my openhab will get state data ON ON ON.

Same as if I turn 2nd switch on, let’s say ON ON OFF. All 3 gang status in openhab will get ALL ON (ON, ON, ON)
If I turn 1st switch off, let’s say OFF ON OFF. All 3 gang status in my openhab will get ALL OFF (OFF, OFF, OFF)

I understand that because of the stateTopic is no value to separate the status of the Power

[ stateTopic = "tele/lightswitch/SENSOR" , transformationPattern = "REGEX:(.*\"Power\".*)∩JSONPATH:$.ZbReceived.lightswitch.Power",

The question is. How can I separate MQTT stateTopic Power status by endpoint? Is there any trickery way to make it happen? :grin:

Can you copy/paste the Tasmota console log into code fences, instead of a screenshot?

How does Tasmota distinguish between the devices? Is it the device parameter? If so, what are the three device values?

Hi hafniumzinc

Here it is

10:09:28 ZIG: {"ZbZCLReceived":{"groupid":0,"clusterid":6,"srcaddr":"0xDC98","srcendpoint":3,"dstendpoint":1,"wasbroadcast":0,"LinkQuality":79,"securityuse":0,"seqnumber":40,"fc":"0x18","manuf":"0x0000","transact":59,"cmdid":"0x0A","payload":"00001001"}}
10:09:28 ZIG: ZbZCLRawReceived: {"0xDC98":{"0006/0000":1,"Endpoint":3,"LinkQuality":79}}
10:09:29 MQT: tele/lightswitch/SENSOR = {"ZbReceived":{"lightswitch":{"Device":"0xDC98","Name":"lightswitch","Power":1,"Endpoint":3,"LinkQuality":79}}}
10:09:30 ZIG: {"ZbEZSPReceived":"590098DC9B23FAFEFF142E8488BE00"}
10:09:30 ZIG: {"ZbEZSPReceived":"450000040106000201400100002994C198DCFFFF07183C0A0000100102"}
10:09:30 ZIG: {"ZbZCLReceived":{"groupid":0,"clusterid":6,"srcaddr":"0xDC98","srcendpoint":2,"dstendpoint":1,"wasbroadcast":0,"LinkQuality":63,"securityuse":0,"seqnumber":41,"fc":"0x18","manuf":"0x0000","transact":60,"cmdid":"0x0A","payload":"00001001"}}
10:09:30 ZIG: ZbZCLRawReceived: {"0xDC98":{"0006/0000":1,"Endpoint":2,"LinkQuality":63}}
10:09:30 MQT: tele/lightswitch/SENSOR = {"ZbReceived":{"lightswitch":{"Device":"0xDC98","Name":"lightswitch","Power":1,"Endpoint":2,"LinkQuality":63}}}
10:09:31 ZIG: {"ZbEZSPReceived":"590098DC9B23FAFEFF142E84B0C800"}
10:09:31 ZIG: {"ZbEZSPReceived":"450000040106000101400100002AB4C998DCFFFF07183D0A0000100102"}
10:09:31 ZIG: {"ZbZCLReceived":{"groupid":0,"clusterid":6,"srcaddr":"0xDC98","srcendpoint":1,"dstendpoint":1,"wasbroadcast":0,"LinkQuality":84,"securityuse":0,"seqnumber":42,"fc":"0x18","manuf":"0x0000","transact":61,"cmdid":"0x0A","payload":"00001001"}}
10:09:31 ZIG: ZbZCLRawReceived: {"0xDC98":{"0006/0000":1,"Endpoint":1,"LinkQuality":84}}
10:09:31 MQT: tele/lightswitch/SENSOR = {"ZbReceived":{"lightswitch":{"Device":"0xDC98","Name":"lightswitch","Power":1,"Endpoint":1,"LinkQuality":84}}}

Each gang are separated by “Endpoint”: parameter

chain another REGEX to filter messages on the endpoint too.

Thanks. But do you have any example or topic related to this?
I’m very new here try to read from Regex doc but still not able to apply it.

But you are already using a REGEX filter.

"REGEX:(.*\"Power\".*)∩JSONPATH:$.ZbReceived.lightswitch.Power"

Just do it again:

"REGEX:(.*\"Power\".*)∩REGEX:(.*\"Endpoint\":1.*)∩JSONPATH:$.ZbReceived.lightswitch.Power"

That will only process those message that have both “Power” and “endpoint1” in the message. You could do it all as part of the one REGEX if you wanted to.

"REGEX:(.*\"Power\".*\"Endpoint\":1.*)∩JSONPATH:$.ZbReceived.lightswitch.Power"
1 Like

Great!! That’s what I really need.
I’m not from programmer background. Many time I have to find an example and apply to my application :grin:
Thank you very much!

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.