Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
lelandblue authored Nov 15, 2024
2 parents 1fa175e + 98b7d7d commit 14c8f8c
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 26 deletions.
1 change: 1 addition & 0 deletions drivers/SmartThings/matter-appliance/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ local function temperature_setpoint_attr_handler(driver, device, ib, response)
local range = {
minimum = min,
maximum = max,
step = 0.1
}
-- Only emit the capability for RPC version >= 5, since unit conversion for
-- range capabilities is only supported in that case.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ local function temperature_setpoint_attr_handler(driver, device, ib, response)
local range = {
minimum = min,
maximum = max,
step = 0.1
}

-- Only emit the capability for RPC version >= 5, since unit conversion for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ local function temperature_setpoint_attr_handler(driver, device, ib, response)
local range = {
minimum = min,
maximum = max,
step = 0.1
}

-- Only emit the capability for RPC version >= 5, since unit conversion for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ local function temperature_setpoint_attr_handler(driver, device, ib, response)
local range = {
minimum = min,
maximum = max,
step = 0.1
}

-- Only emit the capability for RPC version >= 5, since unit conversion for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ local function temperature_setpoint_attr_handler(driver, device, ib, response)
local range = {
minimum = min,
maximum = max,
step = 0.1
}

-- Only emit the capability for RPC version >= 5, since unit conversion for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=33.0,maximum=90.0}, unit = "C"}, {visibility = {displayed = false}}))
message = mock_device:generate_test_message("main", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=33.0,maximum=90.0, step = 0.1}, unit = "C"}, {visibility = {displayed = false}}))
},
{
channel = "capability",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=30.0,maximum=70.0}, unit = "C"}, {visibility = {displayed = false}}))
message = mock_device:generate_test_message("main", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=30.0,maximum=70.0, step = 0.1}, unit = "C"}, {visibility = {displayed = false}}))
},
{
channel = "capability",
Expand Down Expand Up @@ -604,7 +604,7 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=27.0,maximum=80.0}, unit = "C"}, {visibility = {displayed = false}}))
message = mock_device:generate_test_message("main", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=27.0,maximum=80.0, step = 0.1}, unit = "C"}, {visibility = {displayed = false}}))
},
{
channel = "capability",
Expand Down Expand Up @@ -660,7 +660,7 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device_washer:generate_test_message("main", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=15.0,maximum=50.0}, unit = "C"}, {visibility = {displayed = false}}))
message = mock_device_washer:generate_test_message("main", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=15.0,maximum=50.0, step = 0.1}, unit = "C"}, {visibility = {displayed = false}}))
},
{
channel = "capability",
Expand Down Expand Up @@ -716,7 +716,7 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device_washer:generate_test_message("main", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=13.0,maximum=55.0}, unit = "C"}, {visibility = {displayed = false}}))
message = mock_device_washer:generate_test_message("main", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=13.0,maximum=55.0, step = 0.1}, unit = "C"}, {visibility = {displayed = false}}))
},
{
channel = "capability",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("tccOne", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=128.0,maximum=200.0}, unit = "C"}, {visibility = {displayed = false}}))
message = mock_device:generate_test_message("tccOne", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=128.0,maximum=200.0, step = 0.1}, unit = "C"}, {visibility = {displayed = false}}))
},
{
channel = "capability",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("refrigerator", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=0.0,maximum=15.0}, unit = "C"}))
message = mock_device:generate_test_message("refrigerator", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=0.0,maximum=15.0, step = 0.1}, unit = "C"}))
},
{
channel = "capability",
Expand Down Expand Up @@ -236,7 +236,7 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("refrigerator", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=-6.0,maximum=20.0}, unit = "C"}))
message = mock_device:generate_test_message("refrigerator", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=-6.0,maximum=20.0, step = 0.1}, unit = "C"}))
},
{
channel = "capability",
Expand Down Expand Up @@ -292,7 +292,7 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("freezer", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=-22.0,maximum=-14.0}, unit = "C"}))
message = mock_device:generate_test_message("freezer", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=-22.0,maximum=-14.0, step = 0.1}, unit = "C"}))
},
{
channel = "capability",
Expand Down Expand Up @@ -348,7 +348,7 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("freezer", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=-24.0,maximum=-12.0}, unit = "C"}))
message = mock_device:generate_test_message("freezer", capabilities.temperatureSetpoint.temperatureSetpointRange({value = {minimum=-24.0,maximum=-12.0, step = 0.1}, unit = "C"}))
},
{
channel = "capability",
Expand Down
6 changes: 6 additions & 0 deletions drivers/SmartThings/matter-sensor/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ matterManufacturer:
vendorId: 0x115F
productId: 0x2003
deviceProfileName: motion-illuminance-battery
#Elko
- id: "5170/4098"
deviceLabel: RFWD-100/MT
vendorId: 0x1432
productId: 0x1002
deviceProfileName: contact-battery
#Eve
- id: "Eve Motion"
deviceLabel: Eve Motion
Expand Down
16 changes: 16 additions & 0 deletions drivers/SmartThings/matter-switch/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ matterManufacturer:
vendorId: 0x1426
productId: 0x0003
deviceProfileName: plug-binary
#Elko
- id: "5170/4096"
deviceLabel: RFSAI-62B-SL/MT
vendorId: 0x1432
productId: 0x1000
deviceProfileName: switch-binary
- id: "5170/4097"
deviceLabel: RFGB-40B(W)/MT
vendorId: 0x1432
productId: 0x1001
deviceProfileName: 4-button-battery
- id: "5170/4099"
deviceLabel: RFWB-40G/MT
vendorId: 0x1432
productId: 0x1003
deviceProfileName: 4-button-battery
#Eve
- id: "Eve/Energy/US"
deviceLabel: Eve Energy
Expand Down
30 changes: 27 additions & 3 deletions drivers/SmartThings/matter-thermostat/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -720,8 +720,32 @@ end

local function temp_event_handler(attribute)
return function(driver, device, ib, response)
local temp = ib.data.value / 100.0
local unit = "C"

-- Only emit the capability for RPC version >= 5, since unit conversion for
-- range capabilities is only supported in that case.
if version.rpc >= 5 then
local event
if attribute == capabilities.thermostatCoolingSetpoint.coolingSetpoint then
local range = {
minimum = device:get_field(setpoint_limit_device_field.MIN_COOL) or THERMOSTAT_MIN_TEMP_IN_C,
maximum = device:get_field(setpoint_limit_device_field.MAX_COOL) or THERMOSTAT_MAX_TEMP_IN_C,
step = 0.1
}
event = capabilities.thermostatCoolingSetpoint.coolingSetpointRange({value = range, unit = unit})
device:emit_event_for_endpoint(ib.endpoint_id, event)
elseif attribute == capabilities.thermostatHeatingSetpoint.heatingSetpoint then
local range = {
minimum = device:get_field(setpoint_limit_device_field.MIN_HEAT) or THERMOSTAT_MIN_TEMP_IN_C,
maximum = device:get_field(setpoint_limit_device_field.MAX_HEAT) or THERMOSTAT_MAX_TEMP_IN_C,
step = 0.1
}
event = capabilities.thermostatHeatingSetpoint.heatingSetpointRange({value = range, unit = unit})
device:emit_event_for_endpoint(ib.endpoint_id, event)
end
end

local temp = ib.data.value / 100.0
device:emit_event_for_endpoint(ib.endpoint_id, attribute({value = temp, unit = unit}))
end
end
Expand Down Expand Up @@ -1172,7 +1196,7 @@ local heating_setpoint_limit_handler_factory = function(minOrMax)
-- Only emit the capability for RPC version >= 5 (unit conversion for
-- heating setpoint range capability is only supported for RPC >= 5)
if version.rpc >= 5 then
device:emit_event_for_endpoint(ib.endpoint_id, capabilities.thermostatHeatingSetpoint.heatingSetpointRange({ value = { minimum = min, maximum = max }, unit = "C" }))
device:emit_event_for_endpoint(ib.endpoint_id, capabilities.thermostatHeatingSetpoint.heatingSetpointRange({ value = { minimum = min, maximum = max, step = 0.1 }, unit = "C" }))
end
else
device.log.warn_with({hub_logs = true}, string.format("Device reported a min heating setpoint %d that is not lower than the reported max %d", min, max))
Expand All @@ -1196,7 +1220,7 @@ local cooling_setpoint_limit_handler_factory = function(minOrMax)
-- Only emit the capability for RPC version >= 5 (unit conversion for
-- cooling setpoint range capability is only supported for RPC >= 5)
if version.rpc >= 5 then
device:emit_event_for_endpoint(ib.endpoint_id, capabilities.thermostatCoolingSetpoint.coolingSetpointRange({ value = { minimum = min, maximum = max }, unit = "C" }))
device:emit_event_for_endpoint(ib.endpoint_id, capabilities.thermostatCoolingSetpoint.coolingSetpointRange({ value = { minimum = min, maximum = max, step = 0.1 }, unit = "C" }))
end
else
device.log.warn_with({hub_logs = true}, string.format("Device reported a min cooling setpoint %d that is not lower than the reported max %d", min, max))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,24 @@ local function configure(device)
device.id,
clusters.Thermostat.attributes.OccupiedCoolingSetpoint:build_test_report_data(mock_device, 1, 2667) --26.67 celcius
})
test.socket.capability:__expect_send(
device:generate_test_message("main", capabilities.thermostatHeatingSetpoint.heatingSetpointRange({ value = { minimum = 5.00, maximum = 40.00, step = 0.1 }, unit = "C" }))
)
test.socket.capability:__expect_send(
device:generate_test_message("main", capabilities.thermostatHeatingSetpoint.heatingSetpoint({ value = 24.44, unit = "C" }))
)
test.socket.capability:__expect_send(
device:generate_test_message("main", capabilities.thermostatCoolingSetpoint.coolingSetpointRange({ value = { minimum = 5.00, maximum = 40.00, step = 0.1 }, unit = "C" }))
)
test.socket.capability:__expect_send(
device:generate_test_message("main", capabilities.thermostatCoolingSetpoint.coolingSetpoint({ value = 26.67, unit = "C" }))
)
test.wait_for_events()
end

test.register_coroutine_test(
"Heat setpoint lower than min",
function()
configure(mock_device)
test.socket.matter:__queue_receive({
mock_device.id,
clusters.Thermostat.attributes.AbsMinHeatSetpointLimit:build_test_report_data(mock_device, 1, 1000)
Expand All @@ -126,9 +132,9 @@ test.register_coroutine_test(
clusters.Thermostat.attributes.AbsMaxHeatSetpointLimit:build_test_report_data(mock_device, 1, 3222)
})
test.socket.capability:__expect_send(
mock_device:generate_test_message("main", capabilities.thermostatHeatingSetpoint.heatingSetpointRange({ value = { minimum = 10.00, maximum = 32.22 }, unit = "C" }))
mock_device:generate_test_message("main", capabilities.thermostatHeatingSetpoint.heatingSetpointRange({ value = { minimum = 10.00, maximum = 32.22, step = 0.1 }, unit = "C" }))
)
configure(mock_device)
test.wait_for_events()
test.socket.capability:__queue_receive({
mock_device.id,
{ capability = "thermostatHeatingSetpoint", component = "main", command = "setHeatingSetpoint", args = { 9 } }
Expand All @@ -142,6 +148,7 @@ test.register_coroutine_test(
test.register_coroutine_test(
"Cool setpoint lower than min",
function()
configure(mock_device)
test.socket.matter:__queue_receive({
mock_device.id,
clusters.Thermostat.attributes.AbsMinCoolSetpointLimit:build_test_report_data(mock_device, 1, 1000)
Expand All @@ -151,9 +158,9 @@ test.register_coroutine_test(
clusters.Thermostat.attributes.AbsMaxCoolSetpointLimit:build_test_report_data(mock_device, 1, 3222)
})
test.socket.capability:__expect_send(
mock_device:generate_test_message("main", capabilities.thermostatCoolingSetpoint.coolingSetpointRange({ value = { minimum = 10.00, maximum = 32.22 }, unit = "C" }))
mock_device:generate_test_message("main", capabilities.thermostatCoolingSetpoint.coolingSetpointRange({ value = { minimum = 10.00, maximum = 32.22, step = 0.1 }, unit = "C" }))
)
configure(mock_device)
test.wait_for_events()
test.socket.capability:__queue_receive({
mock_device.id,
{ capability = "thermostatCoolingSetpoint", component = "main", command = "setCoolingSetpoint", args = { 9 } }
Expand All @@ -167,6 +174,7 @@ test.register_coroutine_test(
test.register_coroutine_test(
"Heat setpoint higher than max",
function()
configure(mock_device)
test.socket.matter:__queue_receive({
mock_device.id,
clusters.Thermostat.attributes.AbsMinHeatSetpointLimit:build_test_report_data(mock_device, 1, 1000)
Expand All @@ -176,9 +184,9 @@ test.register_coroutine_test(
clusters.Thermostat.attributes.AbsMaxHeatSetpointLimit:build_test_report_data(mock_device, 1, 3222)
})
test.socket.capability:__expect_send(
mock_device:generate_test_message("main", capabilities.thermostatHeatingSetpoint.heatingSetpointRange({ value = { minimum = 10.00, maximum = 32.22 }, unit = "C" }))
mock_device:generate_test_message("main", capabilities.thermostatHeatingSetpoint.heatingSetpointRange({ value = { minimum = 10.00, maximum = 32.22, step = 0.1 }, unit = "C" }))
)
configure(mock_device)
test.wait_for_events()
test.socket.capability:__queue_receive({
mock_device.id,
{ capability = "thermostatHeatingSetpoint", component = "main", command = "setHeatingSetpoint", args = { 33 } }
Expand All @@ -192,6 +200,7 @@ test.register_coroutine_test(
test.register_coroutine_test(
"Cool setpoint higher than max",
function()
configure(mock_device)
test.socket.matter:__queue_receive({
mock_device.id,
clusters.Thermostat.attributes.AbsMinCoolSetpointLimit:build_test_report_data(mock_device, 1, 1000)
Expand All @@ -201,9 +210,9 @@ test.register_coroutine_test(
clusters.Thermostat.attributes.AbsMaxCoolSetpointLimit:build_test_report_data(mock_device, 1, 3222)
})
test.socket.capability:__expect_send(
mock_device:generate_test_message("main", capabilities.thermostatCoolingSetpoint.coolingSetpointRange({ value = { minimum = 10.00, maximum = 32.22 }, unit = "C" }))
mock_device:generate_test_message("main", capabilities.thermostatCoolingSetpoint.coolingSetpointRange({ value = { minimum = 10.00, maximum = 32.22, step = 0.1 }, unit = "C" }))
)
configure(mock_device)
test.wait_for_events()
test.socket.capability:__queue_receive({
mock_device.id,
{ capability = "thermostatCoolingSetpoint", component = "main", command = "setCoolingSetpoint", args = { 33 } }
Expand All @@ -217,11 +226,12 @@ test.register_coroutine_test(
test.register_coroutine_test(
"Heat setpoint inside deadband",
function()
configure(mock_device)
test.socket.matter:__queue_receive({
mock_device.id,
clusters.Thermostat.attributes.MinSetpointDeadBand:build_test_report_data(mock_device, 1, 16) --1.6 celcius
})
configure(mock_device)
test.wait_for_events()
test.socket.capability:__queue_receive({
mock_device.id,
{ capability = "thermostatHeatingSetpoint", component = "main", command = "setHeatingSetpoint", args = { 26 } }
Expand All @@ -235,11 +245,12 @@ test.register_coroutine_test(
test.register_coroutine_test(
"Cool setpoint inside deadband",
function()
configure(mock_device)
test.socket.matter:__queue_receive({
mock_device.id,
clusters.Thermostat.attributes.MinSetpointDeadBand:build_test_report_data(mock_device, 1, 16) --1.6 celcius
})
configure(mock_device)
test.wait_for_events()
test.socket.capability:__queue_receive({
mock_device.id,
{ capability = "thermostatCoolingSetpoint", component = "main", command = "setCoolingSetpoint", args = { 25 } }
Expand Down Expand Up @@ -285,7 +296,7 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.thermostatCoolingSetpoint.coolingSetpointRange({ value = { minimum = 10.00, maximum = 32.22 }, unit = "C" }))
message = mock_device:generate_test_message("main", capabilities.thermostatCoolingSetpoint.coolingSetpointRange({ value = { minimum = 10.00, maximum = 32.22, step = 0.1 }, unit = "C" }))
}
}
)
Expand All @@ -312,7 +323,7 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.thermostatHeatingSetpoint.heatingSetpointRange({ value = { minimum = 10.00, maximum = 32.22 }, unit = "C" }))
message = mock_device:generate_test_message("main", capabilities.thermostatHeatingSetpoint.heatingSetpointRange({ value = { minimum = 10.00, maximum = 32.22, step = 0.1 }, unit = "C" }))
}
}
)
Expand Down
8 changes: 8 additions & 0 deletions drivers/SmartThings/zigbee-switch/src/aqara/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ local function wireless_switch_handler(driver, device, value, zb_rx)
end

local function energy_meter_power_consumption_report(driver, device, value, zb_rx)
-- ignore unexpected event when the device is private mode
local private_mode = device:get_field(PRIVATE_MODE) or 0
if private_mode == 1 then return end

local raw_value = value.value
-- energy meter
local offset = device:get_field(constants.ENERGY_METER_OFFSET) or 0
Expand Down Expand Up @@ -196,6 +200,10 @@ local function energy_meter_power_consumption_report(driver, device, value, zb_r
end

local function power_meter_handler(driver, device, value, zb_rx)
-- ignore unexpected event when the device is private mode
local private_mode = device:get_field(PRIVATE_MODE) or 0
if private_mode == 1 then return end

local raw_value = value.value -- '10W'
raw_value = raw_value / 10
device:emit_event(capabilities.powerMeter.power({ value = raw_value, unit = "W" }))
Expand Down
4 changes: 4 additions & 0 deletions drivers/SmartThings/zigbee-switch/src/aqara/version/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ local function round(num)
end

local function present_value_handler(driver, device, value, zb_rx)
-- ignore unexpected event when the device is not private mode
local private_mode = device:get_field(PRIVATE_MODE) or 0
if private_mode == 0 then return end

local src_endpoint = zb_rx.address_header.src_endpoint.value
if src_endpoint == POWER_METER_ENDPOINT then
-- power meter
Expand Down

0 comments on commit 14c8f8c

Please sign in to comment.