Skip to content

Commit

Permalink
Merge pull request #1204 from SmartThingsCommunity/main
Browse files Browse the repository at this point in the history
rolling up main to beta
  • Loading branch information
ctowns authored Feb 6, 2024
2 parents df506bd + fcc57bd commit c80a17b
Show file tree
Hide file tree
Showing 31 changed files with 463 additions and 226 deletions.
2 changes: 1 addition & 1 deletion drivers/SmartThings/matter-button/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ local function device_added(driver, device)

local battery_support = false
if device.manufacturer_info.vendor_id ~= HUE_MANUFACTURER_ID and
#device:get_endpoints(clusters.PowerSource.ID) > 0 then
#device:get_endpoints(clusters.PowerSource.ID, {feature_bitmap = clusters.PowerSource.types.PowerSourceFeature.BATTERY}) > 0 then
battery_support = true
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ local mock_device = test.mock_device.build_test_matter_device(
feature_map = clusters.Switch.types.SwitchFeature.MOMENTARY_SWITCH,
cluster_type = "SERVER"
},
{cluster_id = clusters.PowerSource.ID, cluster_type = "SERVER"}
{cluster_id = clusters.PowerSource.ID, cluster_type = "SERVER", feature_map = clusters.PowerSource.types.PowerSourceFeature.BATTERY}
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ local mock_device = test.mock_device.build_test_matter_device(
feature_map = clusters.Switch.types.SwitchFeature.MOMENTARY_SWITCH,
cluster_type = "SERVER"
},
{cluster_id = clusters.PowerSource.ID, cluster_type = "SERVER"}
{cluster_id = clusters.PowerSource.ID, cluster_type = "SERVER", feature_map = clusters.PowerSource.types.PowerSourceFeature.BATTERY}
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ local mock_device = test.mock_device.build_test_matter_device(
feature_map = clusters.Switch.types.SwitchFeature.MOMENTARY_SWITCH,
cluster_type = "SERVER"
},
{cluster_id = clusters.PowerSource.ID, cluster_type = "SERVER"}
{cluster_id = clusters.PowerSource.ID, cluster_type = "SERVER", feature_map = clusters.PowerSource.types.PowerSourceFeature.BATTERY}
},
},
{
Expand Down
20 changes: 18 additions & 2 deletions drivers/SmartThings/matter-switch/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,33 @@ matterManufacturer:
vendorId: 0x115a
productId: 0x44
deviceProfileName: light-color-level-2700K-6500K
- id: "4442/1809"
- id: "Nanoleaf NL71K1"
deviceLabel: Smart Holiday String Lights
vendorId: 0x115A
productId: 0x771
productId: 0x711
deviceProfileName: light-color-level-2700K-6500K
#SONOFF
- id: "SONOFF MINIR4M"
deviceLabel: Smart Plug-in Unit
vendorId: 0x1321
productId: 0x0002
deviceProfileName: plug-binary
- id: "SONOFF M5-1C"
deviceLabel: SONOFF SwitchMan Smart Wall Switch
vendorId: 0x1321
productId: 0x000B
deviceProfileName: switch-binary
- id: "SONOFF M5-2C"
deviceLabel: SONOFF SwitchMan Smart Wall Switch
vendorId: 0x1321
productId: 0x000C
deviceProfileName: switch-binary
- id: "SONOFF M5-3C"
deviceLabel: SONOFF SwitchMan Smart Wall Switch
vendorId: 0x1321
productId: 0x000D
deviceProfileName: switch-binary

#Yeelight
- id: "Yeelight Smart Lamp"
deviceLabel: Yeelight Smart Lamp
Expand Down
2 changes: 1 addition & 1 deletion drivers/SmartThings/matter-thermostat/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ local function do_configure(driver, device)
local thermo_eps = device:get_endpoints(clusters.Thermostat.ID)
local fan_eps = device:get_endpoints(clusters.FanControl.ID)
local humidity_eps = device:get_endpoints(clusters.RelativeHumidityMeasurement.ID)
local battery_eps = device:get_endpoints(clusters.PowerSource.ID)
local battery_eps = device:get_endpoints(clusters.PowerSource.ID, {feature_bitmap = clusters.PowerSource.types.PowerSourceFeature.BATTERY})
local profile_name = "thermostat"
--Note: we have not encountered thermostats with multiple endpoints that support the Thermostat cluster
if #thermo_eps == 1 then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ local mock_device = test.mock_device.build_test_matter_device({
endpoint_id = 1,
clusters = {
{cluster_id = clusters.FanControl.ID, cluster_type = "SERVER"},
{cluster_id = clusters.PowerSource.ID, cluster_type = "SERVER"},
{cluster_id = clusters.PowerSource.ID, cluster_type = "SERVER", feature_map = clusters.PowerSource.types.PowerSourceFeature.BATTERY},
{
cluster_id = clusters.Thermostat.ID,
cluster_revision=5,
Expand Down Expand Up @@ -70,7 +70,7 @@ local mock_device_simple = test.mock_device.build_test_matter_device({
{
endpoint_id = 1,
clusters = {
{cluster_id = clusters.PowerSource.ID, cluster_type = "SERVER"},
{cluster_id = clusters.PowerSource.ID, cluster_type = "SERVER", feature_map = clusters.PowerSource.types.PowerSourceFeature.BATTERY},
{
cluster_id = clusters.Thermostat.ID,
cluster_revision=5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ local mock_device = test.mock_device.build_test_matter_device({
cluster_type="SERVER",
feature_map=35, -- Heat, Cool, and Auto features.
},
{cluster_id = clusters.PowerSource.ID, cluster_type = "SERVER"},
{cluster_id = clusters.PowerSource.ID, cluster_type = "SERVER", feature_map = clusters.PowerSource.types.PowerSourceFeature.BATTERY},
}
}
}
Expand Down
27 changes: 0 additions & 27 deletions drivers/SmartThings/zigbee-contact/src/battery-overrides/init.lua

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ local CONTACT_TEMPERATURE_SENSOR_FINGERPRINTS = {
{ mfr = "CentraLite", model = "3323-G" },
{ mfr = "CentraLite", model = "Contact Sensor-A" },
{ mfr = "Visonic", model = "MCT-340 E" },
{ mfr = "Visonic", model = "MCT-340 SMA" },
{ mfr = "Ecolink", model = "4655BC0-R" },
{ mfr = "Ecolink", model = "DWZB1-ECO" },
{ mfr = "iMagic by GreatStar", model = "1116-S" },
Expand Down
1 change: 0 additions & 1 deletion drivers/SmartThings/zigbee-contact/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ local zigbee_contact_driver_template = {
},
sub_drivers = {
require("aqara"),
require("battery-overrides"),
require("aurora-contact-sensor"),
require("contact-temperature-sensor"),
require("multi-sensor"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local battery_defaults = require "st.zigbee.defaults.battery_defaults"
local multi_utils = require "multi-sensor/multi_utils"
local capabilities = require "st.capabilities"
local data_types = require "st.zigbee.data_types"
local zcl_clusters = require "st.zigbee.zcl.clusters"

local TARGET_DEV_MAJOR = 1
local TARGET_DEV_MINOR = 15
Expand All @@ -24,6 +25,8 @@ local TARGET_DEV_BUILD = 7
local CENTRALITE_MFG = 0x104E

local init_handler = function(self, device)
device:remove_configured_attribute(zcl_clusters.IASZone.ID, zcl_clusters.IASZone.attributes.ZoneStatus.ID)
device:remove_monitored_attribute(zcl_clusters.IASZone.ID, zcl_clusters.IASZone.attributes.ZoneStatus.ID)
local firmware_full_version = device.data.firmwareFullVersion or "0000"
local dev_major = tonumber(firmware_full_version:sub(1,1), 16)
local dev_minor = tonumber(firmware_full_version:sub(2,2), 16)
Expand Down
8 changes: 7 additions & 1 deletion drivers/SmartThings/zigbee-contact/src/multi-sensor/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ local function zone_status_handler(driver, device, zone_status, zb_rx)
end
end

local function do_init(driver, device)
device:remove_configured_attribute(zcl_clusters.IASZone.ID, zcl_clusters.IASZone.attributes.ZoneStatus.ID)
device:remove_monitored_attribute(zcl_clusters.IASZone.ID, zcl_clusters.IASZone.attributes.ZoneStatus.ID)
end

local function added_handler(self, device)
device:emit_event(capabilities.accelerationSensor.acceleration.inactive())
device:refresh()
Expand All @@ -72,7 +77,8 @@ end
local multi_sensor = {
NAME = "Zigbee Multi Sensor",
lifecycle_handlers = {
added = added_handler
added = added_handler,
init = do_init
},
zigbee_handlers = {
global = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local zcl_commands = require "st.zigbee.zcl.global_commands"
local multi_utils = require "multi-sensor/multi_utils"
local capabilities = require "st.capabilities"
local data_types = require "st.zigbee.data_types"
local zcl_clusters = require "st.zigbee.zcl.clusters"

local SMARTTHINGS_MFG = 0x110A

Expand Down Expand Up @@ -55,6 +56,8 @@ end

local function init_handler(driver, device)
battery_defaults.enable_battery_voltage_table(device, battery_table)
device:remove_configured_attribute(zcl_clusters.IASZone.ID, zcl_clusters.IASZone.attributes.ZoneStatus.ID)
device:remove_monitored_attribute(zcl_clusters.IASZone.ID, zcl_clusters.IASZone.attributes.ZoneStatus.ID)
end

local function do_configure(self, device)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,6 @@ test.register_coroutine_test(
mock_device.id,
TemperatureMeasurement.attributes.MeasuredValue:configure_reporting(mock_device, 30, 300, 16)
})
test.socket.zigbee:__expect_send({
mock_device.id,
zigbee_test_utils.build_bind_request(mock_device, zigbee_test_utils.mock_hub_eui, IASZone.ID)
})
test.socket.zigbee:__expect_send({
mock_device.id,
IASZone.attributes.ZoneStatus:configure_reporting(mock_device, 30, 300, 1)
})
test.socket.zigbee:__expect_send({
mock_device.id,
IASCIEAddress:write(mock_device, zigbee_test_utils.mock_hub_eui)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,6 @@ test.register_coroutine_test(
mock_device.id,
TemperatureMeasurement.attributes.MeasuredValue:configure_reporting(mock_device, 30, 300, 16)
})
test.socket.zigbee:__expect_send({
mock_device.id,
zigbee_test_utils.build_bind_request(mock_device, zigbee_test_utils.mock_hub_eui, IASZone.ID)
})
test.socket.zigbee:__expect_send({
mock_device.id,
IASZone.attributes.ZoneStatus:configure_reporting(mock_device, 30, 300, 1)
})
test.socket.zigbee:__expect_send({
mock_device.id,
IASCIEAddress:write(mock_device, zigbee_test_utils.mock_hub_eui)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,6 @@ test.register_coroutine_test(
mock_device.id,
TemperatureMeasurement.attributes.MeasuredValue:configure_reporting(mock_device, 30, 300, 16)
})
test.socket.zigbee:__expect_send({
mock_device.id,
zigbee_test_utils.build_bind_request(mock_device, zigbee_test_utils.mock_hub_eui, IASZone.ID)
})
test.socket.zigbee:__expect_send({
mock_device.id,
IASZone.attributes.ZoneStatus:configure_reporting(mock_device, 30, 300, 1)
})
test.socket.zigbee:__expect_send({
mock_device.id,
IASCIEAddress:write(mock_device, zigbee_test_utils.mock_hub_eui)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@
-- limitations under the License.

local battery_defaults = require "st.zigbee.defaults.battery_defaults"
local zcl_clusters = require "st.zigbee.zcl.clusters"

local TARGET_DEV_MAJOR = 1
local TARGET_DEV_MINOR = 15
local TARGET_DEV_BUILD = 7

local init_handler = function(self, device)
-- TODO: the IAS Zone changes should be replaced after supporting functions are included in the lua libs
device:remove_monitored_attribute(zcl_clusters.IASZone.ID, zcl_clusters.IASZone.attributes.ZoneStatus.ID)
device:remove_configured_attribute(zcl_clusters.IASZone.ID, zcl_clusters.IASZone.attributes.ZoneStatus.ID)

local firmware_full_version = device.data.firmwareFullVersion or "0000"
local dev_major = tonumber(firmware_full_version:sub(1,1), 16)
local dev_minor = tonumber(firmware_full_version:sub(2,2), 16)
Expand Down
26 changes: 26 additions & 0 deletions drivers/SmartThings/zigbee-motion-sensor/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@ local capabilities = require "st.capabilities"
local ZigbeeDriver = require "st.zigbee"
local defaults = require "st.zigbee.defaults"
local constants = require "st.zigbee.constants"
local zcl_clusters = require "st.zigbee.zcl.clusters"

local HAS_RECONFIGURED = "_has_reconfigured"

-- TODO: Remove when available in lua libs
-- This is a temporary method to lower battery consumption in several devices.
-- Disparities were noted between DTH implementations and driver defaults. -sg
local do_refresh = function(driver, device, command)
device:refresh()

if device:get_field(HAS_RECONFIGURED) == nil then
if device:supports_capability_by_id(capabilities.temperatureMeasurement.ID) and device:supports_server_cluster(zcl_clusters.TemperatureMeasurement.ID) then
device:send(zcl_clusters.TemperatureMeasurement.attributes.MeasuredValue:configure_reporting(device, 30, 600, 100))
end

if device:supports_capability_by_id(capabilities.motionSensor.ID) and device:supports_server_cluster(zcl_clusters.IASZone.ID) then
device:send(zcl_clusters.IASZone.attributes.ZoneStatus:configure_reporting(device, 0xFFFF, 0x0000, 0)) -- reset to default
end
device:set_field(HAS_RECONFIGURED, true)
end
end

local zigbee_motion_driver = {
supported_capabilities = {
Expand All @@ -26,6 +47,11 @@ local zigbee_motion_driver = {
capabilities.presenceSensor,
capabilities.contactSensor
},
capability_handlers = {
[capabilities.refresh.ID] = {
[capabilities.refresh.commands.refresh.NAME] = do_refresh,
}
},
sub_drivers = {
require("aqara"),
require("aurora"),
Expand Down
10 changes: 9 additions & 1 deletion drivers/SmartThings/zigbee-motion-sensor/src/iris/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.

local zcl_clusters = require "st.zigbee.zcl.clusters"
local battery_defaults = require "st.zigbee.defaults.battery_defaults"

local ZIGBEE_IRIS_MOTION_SENSOR_FINGERPRINTS = {
{ mfr = "iMagic by GreatStar", model = "1117-S" }
}

-- TODO: the IAS Zone changes should be replaced after supporting functions are included in the lua libs
local do_init = function(driver, device)
battery_defaults.build_linear_voltage_init(2.4, 2.7)(driver, device)
device:remove_monitored_attribute(zcl_clusters.IASZone.ID, zcl_clusters.IASZone.attributes.ZoneStatus.ID)
device:remove_configured_attribute(zcl_clusters.IASZone.ID, zcl_clusters.IASZone.attributes.ZoneStatus.ID)
end

local is_zigbee_iris_motion_sensor = function(opts, driver, device)
for _, fingerprint in ipairs(ZIGBEE_IRIS_MOTION_SENSOR_FINGERPRINTS) do
if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then
Expand All @@ -30,7 +38,7 @@ end
local iris_motion_handler = {
NAME = "Iris Motion Handler",
lifecycle_handlers = {
init = battery_defaults.build_linear_voltage_init(2.4, 2.7)
init = do_init
},
can_handle = is_zigbee_iris_motion_sensor
}
Expand Down
9 changes: 9 additions & 0 deletions drivers/SmartThings/zigbee-motion-sensor/src/samjin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ local capabilities = require "st.capabilities"

local utils = require "st.utils"

-- TODO: the IAS Zone changes should be replaced after supporting functions are included in the lua libs
local do_init = function(driver, device)
device:remove_monitored_attribute(zcl_clusters.IASZone.ID, zcl_clusters.IASZone.attributes.ZoneStatus.ID)
device:remove_configured_attribute(zcl_clusters.IASZone.ID, zcl_clusters.IASZone.attributes.ZoneStatus.ID)
end

local function samjin_battery_percentage_handler(driver, device, raw_value, zb_rx)
local raw_percentage = raw_value.value - (200 - raw_value.value) / 2
local percentage = utils.clamp_value(utils.round(raw_percentage / 2), 0, 100)
Expand All @@ -28,6 +34,9 @@ end

local samjin_driver = {
NAME = "Samjin Sensor",
lifecycle_handlers = {
init = do_init
},
zigbee_handlers = {
attr = {
[PowerConfiguration.ID] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.

local zcl_clusters = require "st.zigbee.zcl.clusters"
local battery_defaults = require "st.zigbee.defaults.battery_defaults"

local battery_table = {
Expand All @@ -33,6 +34,9 @@ local battery_table = {

local function init_handler(driver, device)
battery_defaults.enable_battery_voltage_table(device, battery_table)
-- TODO: the IAS Zone changes should be replaced after supporting functions are included in the lua libs
device:remove_monitored_attribute(zcl_clusters.IASZone.ID, zcl_clusters.IASZone.attributes.ZoneStatus.ID)
device:remove_configured_attribute(zcl_clusters.IASZone.ID, zcl_clusters.IASZone.attributes.ZoneStatus.ID)
end

local smartthings_motion = {
Expand Down
Loading

0 comments on commit c80a17b

Please sign in to comment.