Skip to content
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

29-July-24 Production Deploy Main to Beta #1552

Merged
merged 3 commits into from
Jul 29, 2024
Merged
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
12 changes: 6 additions & 6 deletions drivers/SmartThings/matter-lock/src/aqara-lock/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ local function device_init(driver, device)
end

local function device_added(driver, device)
device:emit_event(capabilities.lockAlarm.alarm.clear())
device:emit_event(capabilities.lockAlarm.alarm.clear({state_change = true}))
end

local function lock_state_handler(driver, device, ib, response)
Expand All @@ -75,15 +75,15 @@ local function alarm_event_handler(driver, device, ib, response)
local DlAlarmCode = DoorLock.types.DlAlarmCode
local alarm_code = ib.data.elements.alarm_code
if alarm_code.value == DlAlarmCode.LOCK_JAMMED then
device:emit_event(capabilities.lockAlarm.alarm.unableToLockTheDoor())
device:emit_event(capabilities.lockAlarm.alarm.unableToLockTheDoor({state_change = true}))
elseif alarm_code.value == DlAlarmCode.LOCK_FACTORY_RESET then
device:emit_event(capabilities.lockAlarm.alarm.lockFactoryReset())
device:emit_event(capabilities.lockAlarm.alarm.lockFactoryReset({state_change = true}))
elseif alarm_code.value == DlAlarmCode.WRONG_CODE_ENTRY_LIMIT then
device:emit_event(capabilities.lockAlarm.alarm.attemptsExceeded())
device:emit_event(capabilities.lockAlarm.alarm.attemptsExceeded({state_change = true}))
elseif alarm_code.value == DlAlarmCode.FRONT_ESCEUTCHEON_REMOVED then
device:emit_event(capabilities.lockAlarm.alarm.damaged())
device:emit_event(capabilities.lockAlarm.alarm.damaged({state_change = true}))
elseif alarm_code.value == DlAlarmCode.DOOR_FORCED_OPEN then
device:emit_event(capabilities.lockAlarm.alarm.forcedOpeningAttempt())
device:emit_event(capabilities.lockAlarm.alarm.forcedOpeningAttempt({state_change = true}))
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.lockAlarm.alarm.unableToLockTheDoor()),
message = mock_device:generate_test_message(
"main",
capabilities.lockAlarm.alarm.unableToLockTheDoor({state_change = true})
),
},
{
channel = "matter",
Expand All @@ -173,7 +176,10 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.lockAlarm.alarm.lockFactoryReset()),
message = mock_device:generate_test_message(
"main",
capabilities.lockAlarm.alarm.lockFactoryReset({state_change = true})
),
},
{
channel = "matter",
Expand All @@ -188,7 +194,10 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.lockAlarm.alarm.attemptsExceeded()),
message = mock_device:generate_test_message(
"main",
capabilities.lockAlarm.alarm.attemptsExceeded({state_change = true})
),
},
{
channel = "matter",
Expand All @@ -203,7 +212,10 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.lockAlarm.alarm.damaged()),
message = mock_device:generate_test_message(
"main",
capabilities.lockAlarm.alarm.damaged({state_change = true})
),
},
{
channel = "matter",
Expand All @@ -218,7 +230,10 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.lockAlarm.alarm.forcedOpeningAttempt()),
message = mock_device:generate_test_message(
"main",
capabilities.lockAlarm.alarm.forcedOpeningAttempt({state_change = true})
),
},
}
)
Expand All @@ -229,7 +244,10 @@ test.register_coroutine_test(
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "added" })

test.socket.capability:__expect_send(
mock_device:generate_test_message("main", capabilities.lockAlarm.alarm.clear())
mock_device:generate_test_message(
"main",
capabilities.lockAlarm.alarm.clear({state_change = true})
)
)
end
)
Expand Down
43 changes: 2 additions & 41 deletions drivers/SmartThings/matter-sensor/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,9 @@ if version.api < 10 then
end

local BATTERY_CHECKED = "__battery_checked"
local TEMP_BOUND_RECEIVED = "__temp_bound_received"
local TEMP_MIN = "__temp_min"
local TEMP_MAX = "__temp_max"

local HUE_MANUFACTURER_ID = 0x100B

local function get_field_for_endpoint(device, field, endpoint)
return device:get_field(string.format("%s_%d", field, endpoint))
end

local function set_field_for_endpoint(device, field, endpoint, value, additional_params)
device:set_field(string.format("%s_%d", field, endpoint), value, additional_params)
end

local function supports_battery_percentage_remaining(device)
local battery_eps = device:get_endpoints(clusters.PowerSource.ID,
{feature_bitmap = clusters.PowerSource.types.PowerSourceFeature.BATTERY})
Expand Down Expand Up @@ -132,30 +121,6 @@ local function temperature_attr_handler(driver, device, ib, response)
end
end

local temp_attr_handler_factory = function(minOrMax)
return function(driver, device, ib, response)
-- Return if no data or RPC version < 4 (unit conversion for temperature
-- range capability is only supported for RPC >= 4)
if ib.data.value == nil or version.rpc < 4 then
return
end
local temp = ib.data.value / 100.0
local unit = "C"
set_field_for_endpoint(device, TEMP_BOUND_RECEIVED..minOrMax, ib.endpoint_id, temp)
local min = get_field_for_endpoint(device, TEMP_BOUND_RECEIVED..TEMP_MIN, ib.endpoint_id)
local max = get_field_for_endpoint(device, TEMP_BOUND_RECEIVED..TEMP_MAX, ib.endpoint_id)
if min ~= nil and max ~= nil then
if min < max then
device:emit_event_for_endpoint(ib.endpoint_id, capabilities.temperatureMeasurement.temperatureRange({ value = { minimum = min, maximum = max }, unit = unit }))
set_field_for_endpoint(device, TEMP_BOUND_RECEIVED..TEMP_MIN, ib.endpoint_id, nil)
set_field_for_endpoint(device, TEMP_BOUND_RECEIVED..TEMP_MAX, ib.endpoint_id, nil)
else
device.log.warn_with({hub_logs = true}, string.format("Device reported a min temperature %d that is not lower than the reported max temperature %d", min, max))
end
end
end
end

local function humidity_attr_handler(driver, device, ib, response)
local measured_value = ib.data.value
if measured_value ~= nil then
Expand Down Expand Up @@ -202,9 +167,7 @@ local matter_driver_template = {
[clusters.RelativeHumidityMeasurement.attributes.MeasuredValue.ID] = humidity_attr_handler
},
[clusters.TemperatureMeasurement.ID] = {
[clusters.TemperatureMeasurement.attributes.MeasuredValue.ID] = temperature_attr_handler,
[clusters.TemperatureMeasurement.attributes.MinMeasuredValue.ID] = temp_attr_handler_factory(TEMP_MIN),
[clusters.TemperatureMeasurement.attributes.MaxMeasuredValue.ID] = temp_attr_handler_factory(TEMP_MAX),
[clusters.TemperatureMeasurement.attributes.MeasuredValue.ID] = temperature_attr_handler
},
[clusters.IlluminanceMeasurement.ID] = {
[clusters.IlluminanceMeasurement.attributes.MeasuredValue.ID] = illuminance_attr_handler
Expand All @@ -230,9 +193,7 @@ local matter_driver_template = {
clusters.RelativeHumidityMeasurement.attributes.MeasuredValue
},
[capabilities.temperatureMeasurement.ID] = {
clusters.TemperatureMeasurement.attributes.MeasuredValue,
clusters.TemperatureMeasurement.attributes.MinMeasuredValue,
clusters.TemperatureMeasurement.attributes.MaxMeasuredValue
clusters.TemperatureMeasurement.attributes.MeasuredValue
},
[capabilities.illuminanceMeasurement.ID] = {
clusters.IlluminanceMeasurement.attributes.MeasuredValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,7 @@ local function test_init()
clusters.RelativeHumidityMeasurement.attributes.MeasuredValue
},
[capabilities.temperatureMeasurement.ID] = {
clusters.TemperatureMeasurement.attributes.MeasuredValue,
clusters.TemperatureMeasurement.attributes.MinMeasuredValue,
clusters.TemperatureMeasurement.attributes.MaxMeasuredValue
clusters.TemperatureMeasurement.attributes.MeasuredValue
},
[capabilities.airQualityHealthConcern.ID] = {
clusters.AirQuality.attributes.AirQuality
Expand Down Expand Up @@ -248,9 +246,7 @@ local function test_init_common()
clusters.RelativeHumidityMeasurement.attributes.MeasuredValue
},
[capabilities.temperatureMeasurement.ID] = {
clusters.TemperatureMeasurement.attributes.MeasuredValue,
clusters.TemperatureMeasurement.attributes.MinMeasuredValue,
clusters.TemperatureMeasurement.attributes.MaxMeasuredValue
clusters.TemperatureMeasurement.attributes.MeasuredValue
},
[capabilities.airQualityHealthConcern.ID] = {
clusters.AirQuality.attributes.AirQuality
Expand Down Expand Up @@ -289,9 +285,7 @@ local function test_init_level()
clusters.AirQuality.attributes.AirQuality
},
[capabilities.temperatureMeasurement.ID] = {
clusters.TemperatureMeasurement.attributes.MeasuredValue,
clusters.TemperatureMeasurement.attributes.MinMeasuredValue,
clusters.TemperatureMeasurement.attributes.MaxMeasuredValue
clusters.TemperatureMeasurement.attributes.MeasuredValue
},
[capabilities.relativeHumidityMeasurement.ID] = {
clusters.RelativeHumidityMeasurement.attributes.MeasuredValue
Expand Down Expand Up @@ -650,4 +644,4 @@ test.register_coroutine_test(
{ test_init = test_init_level }
)

test.run_registered_tests()
test.run_registered_tests()
32 changes: 0 additions & 32 deletions drivers/SmartThings/matter-sensor/src/test/test_matter_sensor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ local mock_device = test.mock_device.build_test_matter_device({
local function subscribe_on_init(dev)
local subscribe_request = clusters.RelativeHumidityMeasurement.attributes.MeasuredValue:subscribe(mock_device)
subscribe_request:merge(clusters.TemperatureMeasurement.attributes.MeasuredValue:subscribe(mock_device))
subscribe_request:merge(clusters.TemperatureMeasurement.attributes.MinMeasuredValue:subscribe(mock_device))
subscribe_request:merge(clusters.TemperatureMeasurement.attributes.MaxMeasuredValue:subscribe(mock_device))
subscribe_request:merge(clusters.IlluminanceMeasurement.attributes.MeasuredValue:subscribe(mock_device))
subscribe_request:merge(clusters.BooleanState.attributes.StateValue:subscribe(mock_device))
subscribe_request:merge(clusters.OccupancySensing.attributes.Occupancy:subscribe(mock_device))
Expand All @@ -80,7 +78,6 @@ local function test_init()
test.mock_device.add_test_device(mock_device)
-- don't check the battery for this device because we are using the catch-all "sensor.yml" profile just for testing
mock_device:set_field("__battery_checked", 1, {persist = true})
test.set_rpc_version(4)
end
test.set_test_init_function(test_init)

Expand Down Expand Up @@ -240,8 +237,6 @@ test.register_message_test(
local function refresh_commands(dev)
local req = clusters.RelativeHumidityMeasurement.attributes.MeasuredValue:read(dev)
req:merge(clusters.TemperatureMeasurement.attributes.MeasuredValue:read(dev))
req:merge(clusters.TemperatureMeasurement.attributes.MinMeasuredValue:read(dev))
req:merge(clusters.TemperatureMeasurement.attributes.MaxMeasuredValue:read(dev))
req:merge(clusters.IlluminanceMeasurement.attributes.MeasuredValue:read(dev))
req:merge(clusters.BooleanState.attributes.StateValue:read(dev))
req:merge(clusters.OccupancySensing.attributes.Occupancy:read(dev))
Expand Down Expand Up @@ -271,31 +266,4 @@ test.register_message_test(
}
)

test.register_message_test(
"Min and max temperature attributes set capability constraint",
{
{
channel = "matter",
direction = "receive",
message = {
mock_device.id,
clusters.TemperatureMeasurement.attributes.MinMeasuredValue:build_test_report_data(mock_device, 1, 500)
}
},
{
channel = "matter",
direction = "receive",
message = {
mock_device.id,
clusters.TemperatureMeasurement.attributes.MaxMeasuredValue:build_test_report_data(mock_device, 1, 4000)
}
},
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.temperatureMeasurement.temperatureRange({ value = { minimum = 5.00, maximum = 40.00 }, unit = "C" }))
}
}
)

test.run_registered_tests()
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ local cluster_subscribe_list_humidity_no_battery = {

local cluster_subscribe_list_temp_humidity = {
clusters.RelativeHumidityMeasurement.attributes.MeasuredValue,
clusters.TemperatureMeasurement.attributes.MeasuredValue,
clusters.TemperatureMeasurement.attributes.MinMeasuredValue,
clusters.TemperatureMeasurement.attributes.MaxMeasuredValue
clusters.TemperatureMeasurement.attributes.MeasuredValue
}

local function test_init_humidity_battery()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ local cluster_subscribe_list = {
clusters.SmokeCoAlarm.attributes.HardwareFaultAlert,
clusters.SmokeCoAlarm.attributes.BatteryAlert,
clusters.TemperatureMeasurement.attributes.MeasuredValue,
clusters.TemperatureMeasurement.attributes.MinMeasuredValue,
clusters.TemperatureMeasurement.attributes.MaxMeasuredValue,
clusters.RelativeHumidityMeasurement.attributes.MeasuredValue,
clusters.CarbonMonoxideConcentrationMeasurement.attributes.MeasuredValue,
clusters.CarbonMonoxideConcentrationMeasurement.attributes.MeasurementUnit,
Expand Down
Loading
Loading