Skip to content

Commit

Permalink
Merge pull request #1575 from SmartThingsCommunity/beta
Browse files Browse the repository at this point in the history
Releasing Beta to Production
  • Loading branch information
lelandblue authored Aug 12, 2024
2 parents 2651248 + d7a1017 commit 588583b
Show file tree
Hide file tree
Showing 26 changed files with 184 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ components:
version: 1
- id: temperatureSetpoint
version: 1
config:
values:
- key: "temperatureSetpoint.value"
range: [ 0, 100 ]
- id: temperatureLevel
version: 1
- id: mode
Expand All @@ -28,3 +24,6 @@ components:
version: 1
categories:
- name: Dishwasher
metadata:
mnmn: SmartThingsEdge
vid: generic-dishwasher
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ components:
version: 1
- id: temperatureSetpoint
version: 1
config:
values:
- key: "temperatureSetpoint.value"
range: [ 0, 100 ]
- id: mode
version: 1
- id: waterFlowAlarm
Expand All @@ -26,3 +22,6 @@ components:
version: 1
categories:
- name: Dishwasher
metadata:
mnmn: SmartThingsEdge
vid: generic-dishwasher
3 changes: 3 additions & 0 deletions drivers/SmartThings/matter-appliance/profiles/dishwasher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ components:
version: 1
categories:
- name: Dishwasher
metadata:
mnmn: SmartThingsEdge
vid: generic-dishwasher
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ components:
version: 1
categories:
- name: Washer
metadata:
mnmn: SmartThingsEdge
vid: generic-laundry-washer
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ components:
version: 1
- id: temperatureSetpoint
version: 1
config:
values:
- key: "temperatureSetpoint.value"
range: [ 0, 100 ]
- id: operationalState
version: 1
- id: temperatureLevel
Expand All @@ -26,3 +22,6 @@ components:
version: 1
categories:
- name: Washer
metadata:
mnmn: SmartThingsEdge
vid: generic-laundry-washer
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ components:
version: 1
- id: temperatureSetpoint
version: 1
config:
values:
- key: "temperatureSetpoint.value"
range: [ 0, 100 ]
- id: operationalState
version: 1
- id: laundryWasherSpinSpeed
Expand All @@ -24,3 +20,6 @@ components:
version: 1
categories:
- name: Washer
metadata:
mnmn: SmartThingsEdge
vid: generic-laundry-washer
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ components:
version: 1
categories:
- name: Washer
metadata:
mnmn: SmartThingsEdge
vid: generic-laundry-washer
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ components:
version: 1
categories:
- name: Refrigerator
metadata:
mnmn: SmartThingsEdge
vid: generic-refrigerator
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ components:
version: 1
- id: temperatureSetpoint
version: 1
config:
values:
- key: "temperatureSetpoint.value"
range: [ 0, 100 ]
- id: temperatureMeasurement
version: 1
categories:
Expand All @@ -39,3 +35,6 @@ components:
version: 1
categories:
- name: Refrigerator
metadata:
mnmn: SmartThingsEdge
vid: generic-refrigerator
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ components:
version: 1
- id: temperatureSetpoint
version: 1
config:
values:
- key: "temperatureSetpoint.value"
range: [ 0, 100 ]
- id: temperatureMeasurement
version: 1
categories:
Expand All @@ -35,11 +31,10 @@ components:
version: 1
- id: temperatureSetpoint
version: 1
config:
values:
- key: "temperatureSetpoint.value"
range: [ 0, 100 ]
- id: temperatureMeasurement
version: 1
categories:
- name: Refrigerator
metadata:
mnmn: SmartThingsEdge
vid: generic-refrigerator
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ components:
version: 1
- id: temperatureSetpoint
version: 1
config:
values:
- key: "temperatureSetpoint.value"
range: [ 0, 100 ]
- id: temperatureLevel
version: 1
- id: temperatureMeasurement
Expand All @@ -37,13 +33,12 @@ components:
version: 1
- id: temperatureSetpoint
version: 1
config:
values:
- key: "temperatureSetpoint.value"
range: [ 0, 100 ]
- id: temperatureLevel
version: 1
- id: temperatureMeasurement
version: 1
categories:
- name: Refrigerator
metadata:
mnmn: SmartThingsEdge
vid: generic-refrigerator
101 changes: 66 additions & 35 deletions drivers/SmartThings/matter-appliance/src/matter-refrigerator/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ local setpoint_limit_device_field = {
}

local COMPONENT_TO_ENDPOINT_MAP = "__component_to_endpoint_map"
local SUPPORTED_TEMPERATURE_LEVEL = "__supported_temperature_levels"
local SUPPORTED_TEMPERATURE_LEVELS_MAP = "__supported_temperature_levels_map"
local SUPPORTED_REFRIGERATOR_TCC_MODES_MAP = "__supported_refrigerator_tcc_modes_map"

local function endpoint_to_component(device, ep)
Expand Down Expand Up @@ -96,15 +96,43 @@ local function is_matter_refrigerator(opts, driver, device)
return false
end

local function temperature_setpoint_attr_handler(driver, device, ib, response)
local tn_eps = embedded_cluster_utils.get_endpoints(device, clusters.TemperatureControl.ID, {feature_bitmap = clusters.TemperatureControl.types.Feature.TEMPERATURE_NUMBER})
local function supports_temperature_level_endpoint(device, endpoint)
local feature = clusters.TemperatureControl.types.Feature.TEMPERATURE_LEVEL
local tl_eps = embedded_cluster_utils.get_endpoints(device, clusters.TemperatureControl.ID, {feature_bitmap = feature})
if #tl_eps == 0 then
device.log.warn_with({ hub_logs = true }, string.format("Device does not support TEMPERATURE_LEVEL feature"))
return false
end
for i, eps in ipairs(tl_eps) do
if eps == endpoint then
return true
end
end
device.log.warn_with({ hub_logs = true }, string.format("Endpoint(%d) does not support TEMPERATURE_LEVEL feature", endpoint))
return false
end

local function supports_temperature_number_endpoint(device, endpoint)
local feature = clusters.TemperatureControl.types.Feature.TEMPERATURE_NUMBER
local tn_eps = embedded_cluster_utils.get_endpoints(device, clusters.TemperatureControl.ID, {feature_bitmap = feature})
if #tn_eps == 0 then
device.log.warn_with({ hub_logs = true }, string.format("Device does not support TEMPERATURE_NUMBER feature"))
return
return false
end
device.log.info_with({ hub_logs = true },
string.format("temperature_setpoint_attr_handler: %d", ib.data.value))
for i, eps in ipairs(tn_eps) do
if eps == endpoint then
return true
end
end
device.log.warn_with({ hub_logs = true }, string.format("Endpoint(%d) does not support TEMPERATURE_NUMBER feature", endpoint))
return false
end

local function temperature_setpoint_attr_handler(driver, device, ib, response)
if not supports_temperature_number_endpoint(device, ib.endpoint_id) then
return
end
device.log.info(string.format("temperature_setpoint_attr_handler: %d", ib.data.value))
local min_field = string.format("%s-%d", setpoint_limit_device_field.MIN_TEMP, ib.endpoint_id)
local max_field = string.format("%s-%d", setpoint_limit_device_field.MAX_TEMP, ib.endpoint_id)
local min = device:get_field(min_field) or 0
Expand All @@ -122,9 +150,7 @@ end

local function setpoint_limit_handler(limit_field)
return function(driver, device, ib, response)
local tn_eps = embedded_cluster_utils.get_endpoints(device,clusters.TemperatureControl.ID, {feature_bitmap = clusters.TemperatureControl.types.Feature.TEMPERATURE_NUMBER})
if #tn_eps == 0 then
device.log.warn_with({ hub_logs = true }, string.format("Device does not support TEMPERATURE_NUMBER feature"))
if not supports_temperature_number_endpoint(device, ib.endpoint_id) then
return
end
local field = string.format("%s-%d", limit_field, ib.endpoint_id)
Expand All @@ -135,17 +161,17 @@ local function setpoint_limit_handler(limit_field)
end

local function selected_temperature_level_attr_handler(driver, device, ib, response)
local tl_eps = embedded_cluster_utils.get_endpoints(device,clusters.TemperatureControl.ID, {feature_bitmap = clusters.TemperatureControl.types.Feature.TEMPERATURE_LEVEL})
if #tl_eps == 0 then
device.log.warn_with({ hub_logs = true }, string.format("Device does not support TEMPERATURE_LEVEL feature"))
if not supports_temperature_level_endpoint(device, ib.endpoint_id) then
return
end
device.log.info_with({ hub_logs = true },
string.format("selected_temperature_level_attr_handler: %s", ib.data.value))

local temperatureLevel = ib.data.value
local supportedTemperatureLevels = device:get_field(SUPPORTED_TEMPERATURE_LEVEL)
local supportedTemperatureLevelsMap = device:get_field(SUPPORTED_TEMPERATURE_LEVELS_MAP)
if not supportedTemperatureLevelsMap then
return
end
local supportedTemperatureLevels = supportedTemperatureLevelsMap[ib.endpoint_id]
for i, tempLevel in ipairs(supportedTemperatureLevels) do
device.log.info(string.format("selected_temperature_level_attr_handler: %d, %s", i, tempLevel))
if i - 1 == temperatureLevel then
device:emit_event_for_endpoint(ib.endpoint_id, capabilities.temperatureLevel.temperatureLevel(tempLevel))
break
Expand All @@ -154,18 +180,23 @@ local function selected_temperature_level_attr_handler(driver, device, ib, respo
end

local function supported_temperature_levels_attr_handler(driver, device, ib, response)
local tl_eps = embedded_cluster_utils.get_endpoints(device,clusters.TemperatureControl.ID, {feature_bitmap = clusters.TemperatureControl.types.Feature.TEMPERATURE_LEVEL})
if #tl_eps == 0 then
device.log.warn_with({ hub_logs = true }, string.format("Device does not support TEMPERATURE_LEVEL feature"))
if not supports_temperature_level_endpoint(device, ib.endpoint_id) then
return
end
local supportedTemperatureLevelsMap = device:get_field(SUPPORTED_TEMPERATURE_LEVELS_MAP) or {}
local supportedTemperatureLevels = {}
for _, tempLevel in ipairs(ib.data.elements) do
log.info_with({ hub_logs = true },
string.format("supported_temperature_levels_attr_handler: %s", tempLevel.value))
device.log.info(string.format("supported_temperature_levels_attr_handler: %s", tempLevel.value))
table.insert(supportedTemperatureLevels, tempLevel.value)
end
device:set_field(SUPPORTED_TEMPERATURE_LEVEL, supportedTemperatureLevels, { persist = true })
for ep = 1, ib.endpoint_id - 1 do
if not supportedTemperatureLevelsMap[ep] then
device.log.info(string.format("supportedTemperatureLevelsMap[%d] is nil", ep))
supportedTemperatureLevelsMap[ep] = {"Nothing"}
end
end
supportedTemperatureLevelsMap[ib.endpoint_id] = supportedTemperatureLevels
device:set_field(SUPPORTED_TEMPERATURE_LEVELS_MAP, supportedTemperatureLevelsMap, { persist = true })
local event = capabilities.temperatureLevel.supportedTemperatureLevels(supportedTemperatureLevels, {visibility = {displayed = false}})
device:emit_event_for_endpoint(ib.endpoint_id, event)
end
Expand Down Expand Up @@ -224,9 +255,7 @@ end

-- Capability Handlers --
local function handle_refrigerator_tcc_mode(driver, device, cmd)
device.log.info_with({ hub_logs = true },
string.format("handle_refrigerator_tcc_mode mode: %s", cmd.args.mode))

device.log.info(string.format("handle_refrigerator_tcc_mode mode: %s", cmd.args.mode))
local ep = component_to_endpoint(device, cmd.component)
local supportedRefrigeratorTccModesMap = device:get_field(SUPPORTED_REFRIGERATOR_TCC_MODES_MAP)
local supportedRefrigeratorTccModes = supportedRefrigeratorTccModesMap[ep] or {}
Expand All @@ -239,21 +268,18 @@ local function handle_refrigerator_tcc_mode(driver, device, cmd)
end

local function handle_temperature_setpoint(driver, device, cmd)
local tn_eps = embedded_cluster_utils.get_endpoints(device,clusters.TemperatureControl.ID, {feature_bitmap = clusters.TemperatureControl.types.Feature.TEMPERATURE_NUMBER})
if #tn_eps == 0 then
device.log.warn_with({ hub_logs = true }, string.format("Device does not support TEMPERATURE_NUMBER feature"))
local ep = component_to_endpoint(device, cmd.component)
if not supports_temperature_number_endpoint(device, ep) then
return
end
device.log.info_with({ hub_logs = true },
string.format("handle_temperature_setpoint: %s", cmd.args.setpoint))
device.log.info(string.format("handle_temperature_setpoint: %s", cmd.args.setpoint))

local value = cmd.args.setpoint
local _, temp_setpoint = device:get_latest_state(
cmd.component, capabilities.temperatureSetpoint.ID,
capabilities.temperatureSetpoint.temperatureSetpoint.NAME,
0, { value = 0, unit = "C" }
)
local ep = component_to_endpoint(device, cmd.component)
local min_field = string.format("%s-%d", setpoint_limit_device_field.MIN_TEMP, ep)
local max_field = string.format("%s-%d", setpoint_limit_device_field.MAX_TEMP, ep)
local min = device:get_field(min_field) or 0
Expand All @@ -273,10 +299,15 @@ end

local function handle_temperature_level(driver, device, cmd)
local ep = component_to_endpoint(device, cmd.component)
device.log.info_with({ hub_logs = true },
string.format("handle_temperature_level: %s(%d)", cmd.args.temperatureLevel, ep))

local supportedTemperatureLevels = device:get_field(SUPPORTED_TEMPERATURE_LEVEL)
device.log.info(string.format("handle_temperature_level: %s(%d)", cmd.args.temperatureLevel, ep))
if not supports_temperature_level_endpoint(device, ep) then
return
end
local supportedTemperatureLevelsMap = device:get_field(SUPPORTED_TEMPERATURE_LEVELS_MAP)
if not supportedTemperatureLevelsMap then
return
end
local supportedTemperatureLevels = supportedTemperatureLevelsMap[ep]
for i, tempLevel in ipairs(supportedTemperatureLevels) do
if cmd.args.temperatureLevel == tempLevel then
device:send(clusters.TemperatureControl.commands.SetTemperature(device, ep, nil, i - 1))
Expand Down
3 changes: 3 additions & 0 deletions drivers/SmartThings/matter-rvc/profiles/rvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ components:
version: 1
categories:
- name: RobotCleaner
metadata:
mnmn: SmartThingsEdge
vid: generic-rvc
11 changes: 8 additions & 3 deletions drivers/SmartThings/matter-rvc/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,16 @@ local function rvc_run_mode_supported_mode_attr_handler(driver, device, ib, resp
break
end
end
local labels_of_supported_modes = get_labels_of_supported_modes_filter_by_current_mode(device,
local labels_of_supported_arguments = get_labels_of_supported_modes_filter_by_current_mode(device,
RVC_RUN_MODE_SUPPORTED_MODES,
clusters.RvcRunMode.types.ModeTag.IDLE,
current_mode
)
local labels_of_supported_modes = get_field_labels_of_supported_modes(device, RVC_RUN_MODE_SUPPORTED_MODES)
local component = device.profile.components["runMode"]
local event = capabilities.mode.supportedModes(labels_of_supported_modes, {visibility = {displayed = false}})
local event = capabilities.mode.supportedArguments(labels_of_supported_arguments, {visibility = {displayed = false}})
device:emit_component_event(component, event)
event = capabilities.mode.supportedModes(labels_of_supported_modes, {visibility = {displayed = false}})
device:emit_component_event(component, event)
end

Expand Down Expand Up @@ -214,7 +217,9 @@ local function rvc_clean_mode_supported_mode_attr_handler(driver, device, ib, re
local labels_of_supported_modes = get_field_labels_of_supported_modes(device, RVC_CLEAN_MODE_SUPPORTED_MODES)

local component = device.profile.components["cleanMode"]
local event = capabilities.mode.supportedModes(labels_of_supported_modes, {visibility = {displayed = false}})
local event = capabilities.mode.supportedArguments(labels_of_supported_modes, {visibility = {displayed = false}})
device:emit_component_event(component, event)
event = capabilities.mode.supportedModes(labels_of_supported_modes, {visibility = {displayed = false}})
device:emit_component_event(component, event)
end

Expand Down
Loading

0 comments on commit 588583b

Please sign in to comment.