Hi,
Is seems device:emit_component_event (and also component:emit_event) modify the passed event.
For the following code:
local event = st_capabilities.button.supportedButtonValues(supported)
for _, component in pairs(device.profile.components) do
if device:supports_capability(st_capabilities.button, component.id) then
-- component:emit_event( event )
device:emit_component_event(component,event)
end
end
I get the following:
2022-04-14T20:25:53.755161482+00:00 INFO Zigbee Button Remote Driver [YG] <ZigbeeDevice: d7e16b5d-77fe-4812-b476-6c9c9abd844a [0x49DC] (6 button remote)> emitting event: {"attribute_id":"supportedButtonValues","capability_id":"button","component_id":"button6","state":{"value":["pushed","held"]}}
2022-04-14T20:25:53.775900482+00:00 INFO Zigbee Button Remote Driver [YG] <ZigbeeDevice: d7e16b5d-77fe-4812-b476-6c9c9abd844a [0x49DC] (6 button remote)> emitting event: {"attribute_id":"supportedButtonValues","capability_id":"button","component_id":"button1","state":{"value":{}}}
2022-04-14T20:25:53.797442482+00:00 INFO Zigbee Button Remote Driver [YG] <ZigbeeDevice: d7e16b5d-77fe-4812-b476-6c9c9abd844a [0x49DC] (6 button remote)> emitting event: {"attribute_id":"supportedButtonValues","capability_id":"button","component_id":"button5","state":{"value":{}}}
2022-04-14T20:25:53.818411815+00:00 INFO Zigbee Button Remote Driver [YG] <ZigbeeDevice: d7e16b5d-77fe-4812-b476-6c9c9abd844a [0x49DC] (6 button remote)> emitting event: {"attribute_id":"supportedButtonValues","capability_id":"button","component_id":"button2","state":{"value":{}}}
2022-04-14T20:25:53.839763148+00:00 INFO Zigbee Button Remote Driver [YG] <ZigbeeDevice: d7e16b5d-77fe-4812-b476-6c9c9abd844a [0x49DC] (6 button remote)> emitting event: {"attribute_id":"supportedButtonValues","capability_id":"button","component_id":"button3","state":{"value":{}}}
2022-04-14T20:25:53.860387815+00:00 INFO Zigbee Button Remote Driver [YG] <ZigbeeDevice: d7e16b5d-77fe-4812-b476-6c9c9abd844a [0x49DC] (6 button remote)> emitting event: {"attribute_id":"supportedButtonValues","capability_id":"button","component_id":"button4","state":{"value":{}}}
If I deep copy the event before emitting, everything works as expected
device:emit_component_event(component,st_utils.deep_copy(event))
I think before the last hub update, deep copy wasn’t required.
Is it a new requirement that once the event is emitted, it can no longer be used?
I think other multicomponent devices (like switches) might be affected by this change.
Thanks
P.S.
I was looking into lua_libs-api_v0x40 code and couldn’t find any modification of the passed event