Skip to content

Commit 07b6e65

Browse files
Adding log when subdriver is used
1 parent dc3eb0c commit 07b6e65

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -706,8 +706,8 @@ local function device_init(driver, device)
706706
end
707707
for _, attr in pairs(device_type_attribute_map[id] or {}) do
708708
if id == GENERIC_SWITCH_ID and
709-
attr ~= clusters.PowerSource.attributes.BatPercentRemaining and
710-
attr ~= clusters.PowerSource.attributes.BatChargeLevel then
709+
attr ~= clusters.PowerSource.attributes.BatPercentRemaining and
710+
attr ~= clusters.PowerSource.attributes.BatChargeLevel then
711711
device:add_subscribed_event(attr)
712712
else
713713
device:add_subscribed_attribute(attr)

drivers/SmartThings/matter-switch/src/third-reality-mk1/init.lua

+8-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ local capabilities = require "st.capabilities"
1616
local clusters = require "st.matter.clusters"
1717
local device_lib = require "st.device"
1818
local im = require "st.matter.interaction_model"
19+
local log = require "log"
1920

2021
local COMPONENT_TO_ENDPOINT_MAP = "__component_to_endpoint_map"
2122
local INITIAL_PRESS_ONLY = "__initial_press_only"
@@ -24,13 +25,13 @@ local INITIAL_PRESS_ONLY = "__initial_press_only"
2425
-- Third Reality MK1 specifics
2526
-------------------------------------------------------------------------------------
2627

27-
local THIRD_REALITY_MANUFACTURER_ID = 0x1407
28-
local THIRD_REALITY_MK1_PRODUCT_ID = 0x1388
28+
local THIRD_REALITY_MK1_FINGERPRINT = { vendor_id = 0x1407, product_id = 0x1388 }
2929

3030
local function is_third_reality_mk1(opts, driver, device)
3131
if device.network_type == device_lib.NETWORK_TYPE_MATTER and
32-
device.manufacturer_info.vendor_id == THIRD_REALITY_MANUFACTURER_ID and
33-
device.manufacturer_info.product_id == THIRD_REALITY_MK1_PRODUCT_ID then
32+
device.manufacturer_info.vendor_id == THIRD_REALITY_MK1_FINGERPRINT.vendor_id and
33+
device.manufacturer_info.product_id == THIRD_REALITY_MK1_FINGERPRINT.product_id then
34+
log.info("Using Third Reality MK1 sub driver")
3435
return true
3536
end
3637
return false
@@ -86,7 +87,8 @@ end
8687

8788
local function device_init(driver, device)
8889
device:set_endpoint_to_component_fn(endpoint_to_component)
89-
subscribe(device)
90+
device:extend_device("subscribe", subscribe)
91+
device:subscribe()
9092
end
9193

9294
local function device_added(driver, device)
@@ -96,7 +98,7 @@ end
9698
local function info_changed(driver, device, event, args)
9799
if device.profile.id ~= args.old_st_store.profile.id then
98100
configure_buttons(device)
99-
subscribe(device)
101+
device:subscribe()
100102
end
101103
end
102104

0 commit comments

Comments
 (0)