Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

esp32 zigbee onLightChange unwanted results #11495

Answered by P-R-O-C-H-Y
ilker-aktuna asked this question in Q&A
Discussion options

I am using Arduino zigbee library and ZigbeeDimmableLight profile for a simple device which requires level and on/off commands.
The device is configured as:
ZigbeeDimmableLight zbDimmableLight = ZigbeeDimmableLight(ZIGBEE_LIGHT_ENDPOINT);
And for the level/on/off devices I use the following method:

 zbDimmableLight.onLightChange(setLight);
void setLight(bool state, uint8_t level) {
 Serial.println("state:");
 Serial.println(state);
 Serial.println("level:");
 Serial.println(level);
}

I use Hubitat as my Zigbee controller and I send zigbee on / off commands as:

off:
[he cmd 0x0C0F 0x0A 0x0006 0x00 {0x0A}, delay 2000]
on:
[he cmd 0x0C0F 0x0A 0x0006 0x01 {0x0A}, delay 2000]

the device id is 0A and the hub sends 00 or 01 commands to the 0x0006 cluster.
That's the only command it sends. It does not send any level command.

However, on serial monitor , I see the following output for on and off commads:

off:
state : 1
level: 0
state: 0
level: 0

on:
state : 1
level: 0
state: 1
level: 255

So the esp32 zigbee library adds unwanted commands.
When there is no level command sent from the hub, it changes the levels. And additionally it sends unwanted state commands (2 instead of 1) so I can't act according to the received command.
Why is this happening ?

@P-R-O-C-H-Y , maybe you can comment...

thanks.

You must be logged in to vote

This is not issue on the Zigbee library side. I have already explained.
What is does on OFF command - sending separate 2 messages:

  1. Send STATE
  2. Send LEVEL

What is does on ON command - sending separate 2 messages:

  1. Send STATE
  2. Send LEVEL

It's 2 separate messages which can be in any order. But I can't tell from the code if its final message or not. So any message have to trigger the onLightChange.
And the onLightChange will be triggered with both parameters - state and level.

Is that understandable now? :)

Replies: 6 comments 2 replies

Comment options

Hi @ilker-aktuna, if I get it correctly when setting to OFF you receive those 2 commands:
state : 1, level: 0 + state: 0, level: 0

when setting to ON you receive this:
state : 1, level: 0 + state: 1, level: 255

Is that correct?

You must be logged in to vote
0 replies
Comment options

yes, exactly.
so why is that ?

You must be logged in to vote
0 replies
Comment options

That's how Zigbee communication works. It's always sending level + state. And as its 2 separate messages its triggering twice the onLightChanged. So you need to check both state and level. If state is 0 keep light off whatever level is. If state is 1, check the level.

You must be logged in to vote
0 replies
Comment options

but I see it receives 2 x state and 2x level commands as I wrote above.
for example for the off command:
1st state : 1, level: 0
2nd state: 0, level: 0

that is 4 messages and onLightChanged triggers twice

You must be logged in to vote
1 reply
Comment options

So its 4 messages or 2 messages as the onLightChanged is triggered twice?

Comment options

I am sending only 1 message from the Hubitat controller.
onLightChanged is triggered twice.
I understand that each level command should normally trigger the onLightChanged once but with two parameters (state and level)
So normally I should expect one level and one state log (according to my code in the first post) per each command sent from hubitat.
However, I see 4 lines of log as I shared above.
So it gets triggered twice per one message from the controller.
How does that happen , and how can I distinguish between an "on" and "off" command ? Because for one "off" command I receive:
state : 1
level: 0
state: 0
level: 0

You must be logged in to vote
1 reply
Comment options

This is not issue on the Zigbee library side. I have already explained.
What is does on OFF command - sending separate 2 messages:

  1. Send STATE
  2. Send LEVEL

What is does on ON command - sending separate 2 messages:

  1. Send STATE
  2. Send LEVEL

It's 2 separate messages which can be in any order. But I can't tell from the code if its final message or not. So any message have to trigger the onLightChange.
And the onLightChange will be triggered with both parameters - state and level.

Is that understandable now? :)

Answer selected by P-R-O-C-H-Y
Comment options

Hi,

I'm sorry ; I had some issues with the family and I didn't have a chance to come back to this thread earlier.
I understood the problem and will try a fix on the hub side.

Thanks for your answer.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /