I hope you’re doing great = ]
I wanted to report an issue with the device.emit_event_for_endpoint
resource, because it seems that it is only pointing capability updates to the main
component (in my case, endpoint 1) regardless of the endpoint number passed.
This is the piece of code calling that API:
local function _send_device_event(endpoint, device, event, state_change)
event.state_change = state_change
return pcall(
device.emit_event_for_endpoint,
device,
endpoint,
event)
end
local function send_button_capability_setup(device, buttons_number, button_events)
assert(_send_device_event(
1, -- "main" profile component
device,
button.numberOfButtons(buttons_number)))
-- configure supported values for
-- each profile component
for ep=1, buttons_number do
print(ep) <<< This is printed in following snippet
assert(_send_device_event(
ep,
device,
button.supportedButtonValues(button_events)))
end
end
And the logs look like this:
2022-02-12T00:23:03.132787408+00:00 INFO button-battery-v1.3.0
<ZigbeeDevice: ... [0x581E] (Scene Switch)> emitting event:
{ "attribute_id": "numberOfButtons",
"component_id": "main",
"capability_id": "button",
"state":{"value":3}}
2022-02-12T00:23:03.150639741+00:00 PRINT button-battery-v1.3.0 1 << endpoint ref
2022-02-12T00:23:03.160293074+00:00 INFO button-battery-v1.3.0
<ZigbeeDevice: ... [0x581E] (Scene Switch)> emitting event:
{ "attribute_id": "supportedButtonValues",
"component_id": "main",
"capability_id": "button",
"state":{"value":["pushed","double","held"]}}
2022-02-12T00:23:03.177856074+00:00 PRINT button-battery-v1.3.0 2 << endpoint ref
2022-02-12T00:23:03.184973741+00:00 INFO button-battery-v1.3.0
<ZigbeeDevice: ... [0x581E] (Scene Switch)> emitting event:
{ "attribute_id": "supportedButtonValues",
"component_id": "main",
"capability_id": "button",
"state":{"value":["pushed","double","held"]}}
2022-02-12T00:23:03.203620741+00:00 PRINT button-battery-v1.3.0 3 << endpoint ref
2022-02-12T00:23:03.211192408+00:00 INFO button-battery-v1.3.0
<ZigbeeDevice: ... [0x581E] (Scene Switch)> emitting event:
{ "attribute_id": "supportedButtonValues",
"component_id": "main",
"capability_id": "button",
"state":{"value":["pushed","double","held"]}}
Also, I think it is important to notice that the endpoint reference is being defined by device:component_count()
.
For more details, you can review the code: erickv-edge-drivers/zigbee/button-battery at develop · erickvneri/erickv-edge-drivers · GitHub