Skip to content

Commit b2eb3f0

Browse files
changes according to pr comments
1 parent 32bc178 commit b2eb3f0

File tree

4 files changed

+90
-139
lines changed

4 files changed

+90
-139
lines changed

drivers/SmartThings/zigbee-switch/src/configurations/devices.lua

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -114,63 +114,63 @@ local devices = {
114114
}
115115
},
116116
FRIENT_IO_MODULE = {
117-
FINGERPRINTS = {
118-
{ mfr = "frient A/S", model = "IOMZB-110" }
119-
},
120-
CONFIGURATION = {
121-
{
122-
cluster = OnOff.ID,
123-
attribute = OnOff.attributes.OnTime.ID,
124-
minimum_interval = 10,
125-
maximum_interval = 600,
126-
reportable_change = 1,
127-
data_type = OnOff.attributes.OnOff.base_type,
128-
configurable = true,
129-
monitored = true
130-
},
131-
{
132-
cluster = OnOff.ID,
133-
attribute = OnOff.attributes.OffWaitTime.ID,
134-
minimum_interval = 10,
135-
maximum_interval = 600,
136-
reportable_change = 1,
137-
data_type = OnOff.attributes.OffWaitTime.base_type,
138-
configurable = true,
139-
monitored = true
140-
},
141-
{
142-
cluster = BasicInput.ID,
143-
attribute = BasicInput.attributes.PresentValue.ID,
144-
minimum_interval = 10,
145-
maximum_interval = 600,
146-
reportable_change = 0,
147-
data_type = BasicInput.attributes.PresentValue.base_type,
148-
configurable = true,
149-
monitored = true
150-
},
151-
{
152-
cluster = BasicInput.ID,
153-
attribute = BasicInput.attributes.Polarity.ID,
154-
minimum_interval = 10,
155-
maximum_interval = 600,
156-
reportable_change = 0,
157-
data_type = BasicInput.attributes.Polarity.base_type,
158-
configurable = true,
159-
monitored = true
160-
},
161-
{
162-
cluster = BasicInput.ID,
163-
attribute = 0x8000, -- IASActivation
164-
minimum_interval = 10,
165-
maximum_interval = 600,
166-
reportable_change = 0,
167-
data_type = data_types.Uint16,
168-
mfg_code = 0x1015,
169-
configurable = true,
170-
monitored = true
171-
}
172-
}
117+
FINGERPRINTS = {
118+
{ mfr = "frient A/S", model = "IOMZB-110" }
119+
},
120+
CONFIGURATION = {
121+
{
122+
cluster = OnOff.ID,
123+
attribute = OnOff.attributes.OnTime.ID,
124+
minimum_interval = 10,
125+
maximum_interval = 600,
126+
reportable_change = 1,
127+
data_type = OnOff.attributes.OnOff.base_type,
128+
configurable = true,
129+
monitored = true
130+
},
131+
{
132+
cluster = OnOff.ID,
133+
attribute = OnOff.attributes.OffWaitTime.ID,
134+
minimum_interval = 10,
135+
maximum_interval = 600,
136+
reportable_change = 1,
137+
data_type = OnOff.attributes.OffWaitTime.base_type,
138+
configurable = true,
139+
monitored = true
140+
},
141+
{
142+
cluster = BasicInput.ID,
143+
attribute = BasicInput.attributes.PresentValue.ID,
144+
minimum_interval = 10,
145+
maximum_interval = 600,
146+
reportable_change = 0,
147+
data_type = BasicInput.attributes.PresentValue.base_type,
148+
configurable = true,
149+
monitored = true
150+
},
151+
{
152+
cluster = BasicInput.ID,
153+
attribute = BasicInput.attributes.Polarity.ID,
154+
minimum_interval = 10,
155+
maximum_interval = 600,
156+
reportable_change = 0,
157+
data_type = BasicInput.attributes.Polarity.base_type,
158+
configurable = true,
159+
monitored = true
160+
},
161+
{
162+
cluster = BasicInput.ID,
163+
attribute = 0x8000, -- IASActivation
164+
minimum_interval = 10,
165+
maximum_interval = 600,
166+
reportable_change = 0,
167+
data_type = data_types.Uint16,
168+
mfg_code = 0x1015,
169+
configurable = true,
170+
monitored = true
171+
}
173172
}
173+
}
174174
}
175175

176176
return devices

drivers/SmartThings/zigbee-switch/src/frient-IO/init.lua

Lines changed: 30 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,12 @@ local function get_output_timing(device, suffix)
171171
local info = OUTPUT_INFO[suffix]
172172
if not info then return 0, 0 end
173173
local child = device:get_child_by_parent_assigned_key(info.key)
174-
if child then
175-
local on_time = math.floor((sanitize_timing(child.preferences.configOnTime)) * 10)
176-
local off_wait = math.floor((sanitize_timing(child.preferences.configOffWaitTime)) * 10)
177-
return on_time, off_wait
178-
end
179174
local on_time = math.floor((sanitize_timing(device.preferences["configOnTime" .. suffix]))*10)
180175
local off_wait = math.floor((sanitize_timing(device.preferences["configOffWaitTime" .. suffix]))*10)
176+
if child then
177+
on_time = math.floor((sanitize_timing(child.preferences.configOnTime)) * 10)
178+
off_wait = math.floor((sanitize_timing(child.preferences.configOffWaitTime)) * 10)
179+
end
181180
return on_time, off_wait
182181
end
183182

@@ -195,12 +194,7 @@ local function handle_output_command(device, suffix, command_name)
195194
data_types.Uint16(config_on_time), data_types.Uint16(config_off_wait_time)):to_endpoint(endpoint))
196195
end
197196
else
198-
if config_on_time == 0 then
199-
device:send(OnOff.server.commands.Off(device):to_endpoint(endpoint))
200-
else
201-
device:send(OnOff.server.commands.OnWithTimedOff(device, data_types.Uint8(0),
202-
data_types.Uint16(config_on_time), data_types.Uint16(config_off_wait_time)):to_endpoint(endpoint))
203-
end
197+
device:send(OnOff.server.commands.Off(device):to_endpoint(endpoint))
204198
end
205199
end
206200

@@ -437,60 +431,33 @@ local function on_off_default_response_handler(driver, device, zb_rx)
437431
end
438432
end
439433

440-
local function switch_on_handler(driver, device, command)
441-
local parent = device:get_parent_device()
442-
if parent then
443-
local info = OUTPUT_BY_KEY[device.parent_assigned_child_key]
444-
if info then
445-
handle_output_command(parent, info.suffix, "on")
446-
return
447-
end
448-
end
449-
450-
local num = command.component and command.component:match("output(%d)")
451-
if num then
452-
handle_output_command(device, num, "on")
453-
return
454-
end
455-
num = command.component:match("input(%d)")
456-
if num then
457-
local component = device.profile.components[command.component]
458-
local value = device:get_latest_state(command.component, Switch.ID, Switch.switch.NAME)
459-
if value == "on" then
460-
device:emit_component_event(component,
461-
Switch.switch.on({ state_change = true, visibility = { displayed = false } }))
462-
elseif value == "off" then
463-
device:emit_component_event(component,
464-
Switch.switch.off({ state_change = true, visibility = { displayed = false } }))
434+
local function make_switch_handler(command_name)
435+
return function(driver, device, command)
436+
local parent = device:get_parent_device()
437+
if parent then
438+
local info = OUTPUT_BY_KEY[device.parent_assigned_child_key]
439+
if info then
440+
handle_output_command(parent, info.suffix, command_name)
441+
return
442+
end
465443
end
466-
end
467-
end
468444

469-
local function switch_off_handler(driver, device, command)
470-
local parent = device:get_parent_device()
471-
if parent then
472-
local info = OUTPUT_BY_KEY[device.parent_assigned_child_key]
473-
if info then
474-
handle_output_command(parent, info.suffix, "off")
445+
local num = command.component and command.component:match("output(%d)")
446+
if num then
447+
handle_output_command(device, num, command_name)
475448
return
476449
end
477-
end
478-
479-
local num = command.component and command.component:match("output(%d)")
480-
if num then
481-
handle_output_command(device, num, "off")
482-
return
483-
end
484-
num = command.component:match("input(%d)")
485-
if num then
486-
local component = device.profile.components[command.component]
487-
local value = device:get_latest_state(command.component, Switch.ID, Switch.switch.NAME)
488-
if value == "on" then
489-
device:emit_component_event(component,
490-
Switch.switch.on({ state_change = true, visibility = { displayed = false } }))
491-
elseif value == "off" then
492-
device:emit_component_event(component,
493-
Switch.switch.off({ state_change = true, visibility = { displayed = false } }))
450+
num = command.component:match("input(%d)")
451+
if num then
452+
local component = device.profile.components[command.component]
453+
local value = device:get_latest_state(command.component, Switch.ID, Switch.switch.NAME)
454+
if value == "on" then
455+
device:emit_component_event(component,
456+
Switch.switch.on({ state_change = true, visibility = { displayed = false } }))
457+
elseif value == "off" then
458+
device:emit_component_event(component,
459+
Switch.switch.off({ state_change = true, visibility = { displayed = false } }))
460+
end
494461
end
495462
end
496463
end
@@ -516,8 +483,8 @@ local frient_bridge_handler = {
516483
},
517484
capability_handlers = {
518485
[Switch.ID] = {
519-
[Switch.commands.on.NAME] = switch_on_handler,
520-
[Switch.commands.off.NAME] = switch_off_handler
486+
[Switch.commands.on.NAME] = make_switch_handler("on"),
487+
[Switch.commands.off.NAME] = make_switch_handler("off")
521488
}
522489
},
523490
lifecycle_handlers = {

drivers/SmartThings/zigbee-switch/src/frient-IO/unbind_request.lua

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
1-
-- Copyright 2025 SmartThings
2-
--
3-
-- Licensed under the Apache License, Version 2.0 (the "License");
4-
-- you may not use this file except in compliance with the License.
5-
-- You may obtain a copy of the License at
6-
--
7-
-- http://www.apache.org/licenses/LICENSE-2.0
8-
--
9-
-- Unless required by applicable law or agreed to in writing, software
10-
-- distributed under the License is distributed on an "AS IS" BASIS,
11-
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
-- See the License for the specific language governing permissions and
13-
-- limitations under the License.
1+
-- Copyright 2025 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
143
local data_types = require "st.zigbee.data_types"
154
local utils = require "st.zigbee.utils"
165

drivers/SmartThings/zigbee-switch/src/test/test_frient_IO_module.lua

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -578,13 +578,8 @@ test.register_coroutine_test(
578578
mock_output_child_1.id,
579579
{ capability = "switch", component = "main", command = "off", args = {} },
580580
})
581-
local timed_off = OnOff.server.commands.OnWithTimedOff(
582-
mock_parent_device,
583-
data_types.Uint8(0),
584-
data_types.Uint16(on1),
585-
data_types.Uint16(off1)
586-
):to_endpoint(ZIGBEE_ENDPOINTS.OUTPUT_1)
587-
test.socket.zigbee:__expect_send({ mock_parent_device.id, timed_off })
581+
local direct_off_output1 = OnOff.server.commands.Off(mock_parent_device):to_endpoint(ZIGBEE_ENDPOINTS.OUTPUT_1)
582+
test.socket.zigbee:__expect_send({ mock_parent_device.id, direct_off_output1 })
588583

589584
test.socket.capability:__queue_receive({
590585
mock_output_child_2.id,

0 commit comments

Comments
 (0)