Skip to content

Commit ca5b1d0

Browse files
committed
fixup! update test and fix syntax bug
1 parent 8e59891 commit ca5b1d0

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

drivers/SmartThings/matter-switch/src/init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,8 +1412,8 @@ local function device_added(driver, device)
14121412
local switch_eps = device:get_endpoints(clusters.OnOff.ID)
14131413
table.sort(switch_eps)
14141414
local electrical_tags = ""
1415-
if electrical_sensor_eps[1].power then electrical_tags = electrical_tags + "-power" end
1416-
if electrical_sensor_eps[1].energy then electrical_tags = electrical_tags + "-energy-powerConsumption" end
1415+
if electrical_sensor_eps[1].power then electrical_tags = electrical_tags .. "-power" end
1416+
if electrical_sensor_eps[1].energy then electrical_tags = electrical_tags .. "-energy-powerConsumption" end
14171417
device:set_field(profiling_data.ELECTRICAL_TOPOLOGY, {topology = clusters.PowerTopology.types.Feature.NODE_TOPOLOGY, tags_on_ep = {[switch_eps[1]] = electrical_tags}})
14181418
device:set_field(ELECTRICAL_SENSOR_EPS, nil)
14191419
end

drivers/SmartThings/matter-switch/src/test/test_aqara_light_switch_h2.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ local aqara_mock_device = test.mock_device.build_test_matter_device({
3939
{cluster_id = clusters.Basic.ID, cluster_type = "SERVER"},
4040
{cluster_id = clusters.ElectricalPowerMeasurement.ID, cluster_type = "SERVER", cluster_revision = 1, feature_map = 2 },
4141
{cluster_id = clusters.ElectricalEnergyMeasurement.ID, cluster_type = "SERVER", cluster_revision = 1, feature_map = 5 },
42-
{cluster_id = clusters.PowerTopology.ID, cluster_type = "SERVER", cluster_revision = 1, feature_map = 2 } -- NODE_TOPOLOGY
42+
{cluster_id = clusters.PowerTopology.ID, cluster_type = "SERVER", cluster_revision = 1, feature_map = 1 } -- NODE_TOPOLOGY
4343
},
4444
device_types = {
4545
{device_type_id = 0x0016, device_type_revision = 1}, -- RootNode
@@ -178,11 +178,12 @@ local function test_init()
178178
end
179179
end
180180
test.socket.matter:__expect_send({aqara_mock_device.id, subscribe_request})
181-
aqara_mock_device:set_field("__ELECTRICAL_TOPOLOGY", {topology = clusters.PowerTopology.types.Feature.NODE_TOPOLOGY, tags_on_ep = {[1] = "-power-energy-powerConsumption"}}, {persist = false}) -- since we're assuming this would have happened during device_added in this case.
181+
182+
-- Test added -> doConfigure logic
183+
test.socket.device_lifecycle:__queue_receive({ aqara_mock_device.id, "added" })
184+
test.socket.matter:__expect_send({aqara_mock_device.id, subscribe_request})
182185
test.socket.device_lifecycle:__queue_receive({ aqara_mock_device.id, "doConfigure" })
183-
test.mock_devices_api._expected_device_updates[aqara_mock_device.device_id] = "00000000-1111-2222-3333-000000000001"
184-
test.mock_devices_api._expected_device_updates[1] = {device_id = "00000000-1111-2222-3333-000000000001"}
185-
test.mock_devices_api._expected_device_updates[1].metadata = {deviceId="00000000-1111-2222-3333-000000000001", profileReference="4-button"}
186+
aqara_mock_device:expect_metadata_update({ profile = "4-button" })
186187
aqara_mock_device:expect_metadata_update({ provisioning_state = "PROVISIONED" })
187188
test.mock_device.add_test_device(aqara_mock_device)
188189
-- to test powerConsumptionReport

0 commit comments

Comments
 (0)