Skip to content
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
8 changes: 8 additions & 0 deletions drivers/SmartThings/zigbee-illuminance-sensor/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ local capabilities = require "st.capabilities"
local ZigbeeDriver = require "st.zigbee"
local defaults = require "st.zigbee.defaults"

local do_configure = function(self, device)
device:configure()
device:refresh()
end

local zigbee_illuminance_driver = {
supported_capabilities = {
capabilities.illuminanceMeasurement,
Expand All @@ -24,6 +29,9 @@ local zigbee_illuminance_driver = {
sub_drivers = {
require("aqara")
},
lifecycle_handlers = {
doConfigure = do_configure,
},
health_check = false,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ test.register_coroutine_test(
zigbee_test_utils.build_bind_request(mock_device, zigbee_test_utils.mock_hub_eui, PowerConfiguration.ID)
}
)
test.socket.zigbee:__expect_send({ mock_device.id, IlluminanceMeasurement.attributes.MeasuredValue:read(mock_device) })
test.socket.zigbee:__expect_send({ mock_device.id, PowerConfiguration.attributes.BatteryPercentageRemaining:read(mock_device) })
end
)

Expand Down
3 changes: 2 additions & 1 deletion drivers/SmartThings/zigbee-lock/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ local do_configure = function(self, device)

device:send(device_management.build_bind_request(device, Alarm.ID, self.environment_info.hub_zigbee_eui))
device:send(Alarm.attributes.AlarmCount:configure_reporting(device, 0, 21600, 0))

device:send(LockCluster.attributes.LockState:read(device))
device:send(PowerConfiguration.attributes.BatteryPercentageRemaining:read(device))
-- Don't send a reload all codes if this is a part of migration
if device.data.lockCodes == nil or device:get_field(lock_utils.MIGRATION_RELOAD_SKIPPED) == true then
device.thread:call_with_delay(2, function(d)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ end

local function do_configure(driver, device)
device:configure()
device:send(DoorLock.attributes.LockState:read(device))
device:send(PowerConfiguration.attributes.BatteryPercentageRemaining:read(device))
end

local function handle_lock_door(driver, device, zb_rx)
Expand Down
2 changes: 2 additions & 0 deletions drivers/SmartThings/zigbee-lock/src/test/test_c2o_lock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ test.register_coroutine_test(
DoorLock.attributes.LockState:configure_reporting(mock_device, 0, 3600, 1)
}
)
test.socket.zigbee:__expect_send({ mock_device.id, PowerConfiguration.attributes.BatteryPercentageRemaining:read(mock_device) })
test.socket.zigbee:__expect_send({ mock_device.id, DoorLock.attributes.LockState:read(mock_device) })
mock_device:expect_metadata_update({ provisioning_state = "PROVISIONED" })
end
)
Expand Down
2 changes: 2 additions & 0 deletions drivers/SmartThings/zigbee-lock/src/test/test_zigbee_lock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ test.register_coroutine_test(
0,
21600,
0) })
test.socket.zigbee:__expect_send({ mock_device.id, DoorLock.attributes.LockState:read(mock_device) })
test.socket.zigbee:__expect_send({ mock_device.id, PowerConfiguration.attributes.BatteryPercentageRemaining:read(mock_device) })

mock_device:expect_metadata_update({ provisioning_state = "PROVISIONED" })
test.wait_for_events()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ test.register_coroutine_test(
0,
21600,
0) })

test.socket.zigbee:__expect_send({ mock_device.id, PowerConfiguration.attributes.BatteryPercentageRemaining:read(mock_device) })
test.socket.zigbee:__expect_send({ mock_device.id, DoorLock.attributes.LockState:read(mock_device) })
mock_device:expect_metadata_update({ provisioning_state = "PROVISIONED" })
-- Validate migration reload skipped datastore
test.wait_for_events()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ test.register_coroutine_test(
0,
21600,
0) })

test.socket.zigbee:__expect_send({ mock_device.id, DoorLock.attributes.LockState:read(mock_device) })
test.socket.zigbee:__expect_send({ mock_device.id, PowerConfiguration.attributes.BatteryPercentageRemaining:read(mock_device) })
mock_device:expect_metadata_update({ provisioning_state = "PROVISIONED" })
test.wait_for_events()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,9 @@ test.register_coroutine_test(
3
):to_endpoint(3)
})
test.socket.zigbee:__expect_send({ mock_base_device.id, OnOff.attributes.OnOff:read(mock_base_device) })
test.socket.zigbee:__expect_send({ mock_base_device.id, OnOff.attributes.OnOff:read(mock_base_device):to_endpoint(2) })
test.socket.zigbee:__expect_send({ mock_base_device.id, OnOff.attributes.OnOff:read(mock_base_device):to_endpoint(3) })
mock_base_device:expect_metadata_update({ provisioning_state = "PROVISIONED" })
end
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ local test = require "integration_test"
local clusters = require "st.zigbee.zcl.clusters"
local capabilities = require "st.capabilities"
local SimpleMetering = clusters.SimpleMetering
local ElectricalMeasurement = clusters.ElectricalMeasurement
local OnOff = clusters.OnOff
local zigbee_test_utils = require "integration_test.zigbee_test_utils"
local t_utils = require "integration_test.utils"

Expand All @@ -17,7 +19,7 @@ local mock_device = test.mock_device.build_test_zigbee_device(
id = 1,
manufacturer = "DAWON_DNS",
model = "PM-B430-ZB",
server_clusters = {}
server_clusters = { 0x0000, 0x0002, 0x0003, 0x0006, 0x0702, 0x0B04 }
}
}
}
Expand Down Expand Up @@ -81,4 +83,69 @@ test.register_message_test(
}
)

test.register_coroutine_test(
"Configure should configure all necessary attributes and refresh device",
function()
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "doConfigure" })
test.socket.zigbee:__set_channel_ordering("relaxed")
test.socket.zigbee:__expect_send({
mock_device.id,
zigbee_test_utils.build_bind_request(mock_device, zigbee_test_utils.mock_hub_eui, OnOff.ID)
})
test.socket.zigbee:__expect_send({
mock_device.id,
zigbee_test_utils.build_bind_request(mock_device, zigbee_test_utils.mock_hub_eui, ElectricalMeasurement.ID)
})
test.socket.zigbee:__expect_send({
mock_device.id,
zigbee_test_utils.build_bind_request(mock_device, zigbee_test_utils.mock_hub_eui, SimpleMetering.ID)
})
test.socket.zigbee:__expect_send(
{
mock_device.id,
OnOff.attributes.OnOff:configure_reporting(mock_device, 0, 300, 1)
}
)
test.socket.zigbee:__expect_send(
{
mock_device.id,
ElectricalMeasurement.attributes.ACPowerMultiplier:configure_reporting(mock_device, 1, 43200, 1)
}
)
test.socket.zigbee:__expect_send(
{
mock_device.id,
ElectricalMeasurement.attributes.ACPowerDivisor:configure_reporting(mock_device, 1, 43200, 1)
}
)
test.socket.zigbee:__expect_send(
{
mock_device.id,
ElectricalMeasurement.attributes.ActivePower:configure_reporting(mock_device, 5, 3600, 5)
}
)
test.socket.zigbee:__expect_send(
{
mock_device.id,
SimpleMetering.attributes.InstantaneousDemand:configure_reporting(mock_device, 5, 3600, 5)
}
)
test.socket.zigbee:__expect_send(
{
mock_device.id,
SimpleMetering.attributes.CurrentSummationDelivered:configure_reporting(mock_device, 5, 3600, 1)
}
)

test.socket.zigbee:__expect_send({ mock_device.id, OnOff.attributes.OnOff:read(mock_device) })
test.socket.zigbee:__expect_send({ mock_device.id, ElectricalMeasurement.attributes.ActivePower:read(mock_device) })
test.socket.zigbee:__expect_send({ mock_device.id, ElectricalMeasurement.attributes.ACPowerDivisor:read(mock_device) })
test.socket.zigbee:__expect_send({ mock_device.id, ElectricalMeasurement.attributes.ACPowerMultiplier:read(mock_device) })
test.socket.zigbee:__expect_send({ mock_device.id, SimpleMetering.attributes.InstantaneousDemand:read(mock_device) })
test.socket.zigbee:__expect_send({ mock_device.id, SimpleMetering.attributes.CurrentSummationDelivered:read(mock_device) })

mock_device:expect_metadata_update({ provisioning_state = "PROVISIONED" })
end
)

test.run_registered_tests()
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ end

local do_configure = function(self, device)
device:configure()
device:refresh()
end

local device_init = function(self, device)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ local do_configure = function(self, device)
device:send(WindowCovering.attributes.CurrentPositionLiftPercentage:configure_reporting(device, 1, 3600, 1))
device:send(device_management.build_bind_request(device, PowerConfiguration.ID, self.environment_info.hub_zigbee_eui))
device:send(PowerConfiguration.attributes.BatteryPercentageRemaining:configure_reporting(device, 1, 3600, 1))
device:refresh()
end

local device_added = function(self, device)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ end
local do_configure = function(self, device)
device:send(device_management.build_bind_request(device, Level.ID, self.environment_info.hub_zigbee_eui))
device:send(Level.attributes.CurrentLevel:configure_reporting(device, 1, 3600, 1))
device:refresh()
end

local feibit_handler = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,8 @@ test.register_coroutine_test(
zigbee_test_utils.mock_hub_eui,
PowerConfiguration.ID)
})
test.socket.zigbee:__expect_send({ mock_device.id, PowerConfiguration.attributes.BatteryPercentageRemaining:read(mock_device) })
test.socket.zigbee:__expect_send({ mock_device.id, WindowCovering.attributes.CurrentPositionLiftPercentage:read(mock_device) })
end
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ local capabilities = require "st.capabilities"
local t_utils = require "integration_test.utils"

local Level = clusters.Level
local WindowCovering = clusters.WindowCovering

local mock_device = test.mock_device.build_test_zigbee_device(
{ profile = t_utils.get_profile_definition("window-treatment-profile.yml"),
Expand Down Expand Up @@ -396,6 +397,7 @@ test.register_coroutine_test(
zigbee_test_utils.mock_hub_eui,
Level.ID)
})
test.socket.zigbee:__expect_send({ mock_device.id, WindowCovering.attributes.CurrentPositionLiftPercentage:read(mock_device) })
mock_device:expect_metadata_update({ provisioning_state = "PROVISIONED" })
end
)
Expand Down
Loading