Skip to content

Added binding requests for each endpoint. #2178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@ test.register_coroutine_test(
mock_device.id,
PowerConfiguration.attributes.BatteryVoltage:read(mock_device)
})
for endpoint = 1,4 do
test.socket.zigbee:__expect_send({
mock_device.id,
zigbee_test_utils.build_bind_request(mock_device,
zigbee_test_utils.mock_hub_eui,
OnOff.ID, endpoint)
})
end
test.socket.zigbee:__expect_add_hub_to_group(0x0000)
test.socket.zigbee:__expect_send({mock_device.id,
Groups.commands.AddGroup(mock_device, 0x0000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ local clusters = require "st.zigbee.zcl.clusters"
local battery_defaults = require "st.zigbee.defaults.battery_defaults"
local PowerConfiguration = clusters.PowerConfiguration
local OnOff = clusters.OnOff
local device_management = require "st.zigbee.device_management"
local Groups = clusters.Groups

local SHINASYSTEM_BUTTON_FINGERPRINTS = {
{ mfr = "ShinaSystem", model = "MSM-300Z" },
{ mfr = "ShinaSystem", model = "BSM-300Z" },
{ mfr = "ShinaSystem", model = "SBM300ZB1" },
{ mfr = "ShinaSystem", model = "SBM300ZB2" },
{ mfr = "ShinaSystem", model = "SBM300ZB3" },
{ mfr = "ShinaSystem", model = "MSM-300Z", endpoint_num = 0x04 },
{ mfr = "ShinaSystem", model = "BSM-300Z", endpoint_num = 0x01 },
{ mfr = "ShinaSystem", model = "SBM300ZB1", endpoint_num = 0x01 },
{ mfr = "ShinaSystem", model = "SBM300ZB2", endpoint_num = 0x02 },
{ mfr = "ShinaSystem", model = "SBM300ZB3", endpoint_num = 0x03 },
}

local is_shinasystem_button = function(opts, driver, device)
Expand All @@ -36,6 +37,14 @@ local is_shinasystem_button = function(opts, driver, device)
return false
end

local function get_ep_num_shinasystem_button(device)
for _, fingerprint in ipairs(SHINASYSTEM_BUTTON_FINGERPRINTS) do
if device:get_model() == fingerprint.model then
return fingerprint.endpoint_num
end
end
end

local function build_button_handler(pressed_type)
return function(driver, device, zb_rx)
local additional_fields = {
Expand All @@ -56,6 +65,9 @@ end
local do_configure = function(self, device)
device:configure()
device:send(PowerConfiguration.attributes.BatteryVoltage:read(device))
for endpoint = 1, get_ep_num_shinasystem_button(device) do
device:send(device_management.build_bind_request(device, OnOff.ID, self.environment_info.hub_zigbee_eui, endpoint))
end
self:add_hub_to_zigbee_group(0x0000)
device:send(Groups.commands.AddGroup(device, 0x0000))
end
Expand Down
Loading