Rule Trigger for a Zigbee (JSON Message)

68 views
Skip to first unread message

Reimer Prochnow

unread,
Jun 10, 2020, 9:38:48 AM6/10/20
to TasmotaUsers

Hi all,

an Ikea TradFriRemote sends these JSON on left resp. right arrow buttons:

left:

{"ZbReceived":{"0xE588":{"0005!07":"01010D00","ArrowClick":1,"Endpoint":1,"Group":58076,"LinkQuality":34}}}
right: 
{"ZbReceived":{"0xE588":{"0005!07":"00010D00","ArrowClick":0,"Endpoint":1,"Group":58076,"LinkQuality":57}}}

and I cannot figure out the correct rule to trigger an MQTT publish on another Topic:

it should be:

Rule 2
 ON ZbReceived#0xE588#ArrowClick==1 DO publish %topic%/ikearemote {"action": "brightness_left_click"} BREAK
 ON ZbReceived#0xE588#ArrowClick==0 DO publish %topic%/ikearemote {"action": "brightness_right_click"} BREAK

but it does not fire. Any suggestions are appreciated. Thank you for your great work !!!

Stephan Hadinger

unread,
Jun 10, 2020, 6:13:40 PM6/10/20
to TasmotaUsers
You're missing the 'endon' at the end of each statement. The rules will never fire without it.

Reimer Prochnow

unread,
Jun 11, 2020, 4:24:48 AM6/11/20
to sonof...@googlegroups.com
Hi Stephan,

I tried ENDON, but it is still not working.

BTW I used BREAK in a similar context for the simpler IKEA On/Off switch. The rules are working there, because there is a simlpler JSON Structure: All Buttons have distinct JSON Keys which are empty and therefor no need to be inspected

Button ON:   {"ZbReceived":{"0x030E":{"0006!01":"","Power":1,"Endpoint":1,"LinkQuality":63}}}
Button OFF: {"ZbReceived":{"0x030E":{"0006!00":"","Power":0,"Endpoint":1,"LinkQuality":26}}}

This is working: (from the Documentation -- but with BREAK)
Rule1
 ON ZbReceived#0x030E#0006!00 DO publish %topic%/ikeaonoff {"click":"off"} BREAK
 ON ZbReceived#0x030E#0006!01 DO publish %topic%/ikeaonoff {"click":"on"} BREAK

I tried the same device with rules on the "Power" JSON Key
Rule1
 ON ZbReceived#0x030E#Power==1 DO publish %topic%/ikeaonoff {"click":"on"} BREAK
 ON ZbReceived#0x030E#Power==0 DO publish %topic%/ikeaonoff {"click":"off"} BREAK

working as expected.... It should work the same way for the other device bur it doesn't...

knowles...@gmail.com

unread,
Jun 11, 2020, 5:37:24 AM6/11/20
to TasmotaUsers, Reimer Prochnow

I'm not sure why you are using break anyway. Those rules don't need it - break stops processing of following rules but these are mutually exclusive anyway.

Try it with Endon instead of break and see what happens.

You don't need Endon if you've used break.so that’s a red herring.

However you’re missing an ‘=’ sign in the rule

I THINK it should be

ON ZbReceived#0x030E=0006!00 DO publish %topic%/ikeaonoff {"click":"off"} Endon

 

Regards

 

Phil K

From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Reimer Prochnow <heim...@gmail.com>
Sent: Thursday, June 11, 2020 9:24:48 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: Rule Trigger for a Zigbee (JSON Message)

 

Hi Stephan,

 

I tried ENDON, but it is still not working.

 

BTW I used BREAK in a similar context for the simpler IKEA On/Off switch. The rules are working there, because there is a simlpler JSON Structure: All Buttons have distinct JSON Keys which are empty and therefor no need to be inspected

 

Button ON:   {"ZbReceived":{"0x030E":{"0006!01":"","Power":1,"Endpoint":1,"LinkQuality":63}}}

Button OFF: {"ZbReceived":{"0x030E":{"0006!00":"","Power":0,"Endpoint":1,"LinkQuality":26}}}

 

This is working: (from the Documentation -- but with BREAK)

Rule1

 ON ZbReceived#0x030E#0006!00 DO publish %topic%/ikeaonoff {"click":"off"} BREAK

 ON ZbReceived#0x030E#0006!01 DO publish %topic%/ikeaonoff {"click":"on"} BREAK

 

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/c0cddfea-5c18-4b8b-9c6f-8117399abfbbo%40googlegroups.com.

Norbert R.

unread,
Jun 12, 2020, 4:06:56 AM6/12/20
to sonof...@googlegroups.com


On Thursday, 11 June 2020 11:37:24 UTC+2, knowles...@gmail.com wrote:

However you’re missing an ‘=’ sign in the rule

I THINK it should be

ON ZbReceived#0x030E=0006!00 DO publish %topic%/ikeaonoff {"click":"off"} Endon


No, the value of ZbReceived#0x030E is the json {"0006!00":"","Power":0,"Endpoint":1,"LinkQuality":26}.
A comparision with 0006!00 will be False anyway.
"0006!00" is a key like "Power" and the value for key "0006!00"  is an empty string "".

So the origin triggers ZbReceived#0x030E#0006!00 and ZbReceived#0x030E#0006!01 are correct, because they trigger for existing json key only - the values for these keys are unimportant 'cause empty strings and comparison unneeeded.
Using a comparision you mean ZbReceived#0x030E#0006!00="", but that's also a wrong syntax because you can't compare to an empty string.

Reimer Prochnow

unread,
Jun 12, 2020, 10:23:09 AM6/12/20
to sonof...@googlegroups.com
Hello, thank you all for your comments, I think ttis Device is rather buggy, since the JSON Messages are a bit out ouf sync (e.g. the long press on the toggle button) and they include some randomness in the JSON values for the arrow keys...

I resetted my work an finally got this working, even for the click, hold and release actions:
I had to split the rules to avoid errors (how long can a command get in console  or web?)

I like this approach because it emulates the zigbee2mqtt messages, but I am running out of rules capacity now :(


 Rule2
 ON ZbReceived#0xE588#Power==2 DO publish zigbee/ikearemote {"action":"toggle"} BREAK
 ON ZbReceived#0xE588#ArrowClick==2 DO publish zigbee/ikearemote {"action":"toggle_hold"} BREAK
 ON ZbReceived#0xE588#DimmerUp DO publish zigbee/ikearemote {"action":"brightness_up_click"} BREAK
 ON ZbReceived#0xE588#DimmerMove==0 DO publish zigbee/ikearemote {"action":"brightness_up_hold"} BREAK
 ON ZbReceived#0xE588#DimmerStop DO publish zigbee/ikearemote {"action":"brightness_release"} BREAK
 ON ZbReceived#0xE588#0008!02 DO publish zigbee/ikearemote {"action":"brightness_down_click"} BREAK
Rule3
 ON ZbReceived#0xE588#DimmerMove==1 DO publish zigbee/ikearemote {"action":"brightness_down_hold"} BREAK
 ON ZbReceived#0xE588#ArrowClick==1 DO publish zigbee/ikearemote {"action":"arrow_left_click"} BREAK
 ON ZbReceived#0xE588#ArrowHold==1 DO publish zigbee/ikearemote {"action":"arrow_left_hold"} BREAK
 ON ZbReceived#0xE588#ArrowRelease DO publish zigbee/ikearemote {"action":"arrow_release"} BREAK
 ON ZbReceived#0xE588#ArrowClick==0 DO publish zigbee/ikearemote {"action":"arrow_right_click"} BREAK
 ON ZbReceived#0xE588#ArrowHold==0 DO publish zigbee/ikearemote {"action":"arrow_right_hold"} BREAK

Reimer Prochnow

unread,
Jun 12, 2020, 11:47:07 AM6/12/20
to TasmotaUsers
Oh, I missed that rules are limited to 3 bur there is the append operation "Rule2 + ..."

 
Reply all
Reply to author
Forward
0 new messages