Have you tried the following?
local function on_handler(_, device, command)
-- capability reference
local attr = capabilities.switch.switch
-- parse component to endpoint
local endpoint = device:get_endpoint_for_component_id(command.component)
-- send zigbee event
device:send(OnOff.server.commands.On(device):to_endpoint(endpoint))
-- send platform event
device:emit_event_for_endpoint(
endpoint,
attr.on())
end
Notice how the switch event is divided into two additional tasks:
- Send the Zigbee message to the device.
- Push platform event to confirm the device command.