Skip to content

Commit cf6b05f

Browse files
authored
Merge pull request #1 from SmartThingsCommunity/feature/initial_drivers
Add initial set of drivers
2 parents bae1f25 + a667054 commit cf6b05f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3387
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: 'Zigbee Carbon Monoxide Detector'
2+
packageKey: 'zigbee-carborn-monoxide-detector'
3+
permissions:
4+
zigbee: {}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
zigbeeManufacturer:
2+
- id: "ClimaxTechnology/CO_00.00.00.22TC"
3+
deviceLabel: Ozom Carbon Monoxide Sensor
4+
manufacturer: ClimaxTechnology
5+
model: CO_00.00.00.22TC
6+
deviceProfileName: carbonMonoxide-battery
7+
- id: "ClimaxTechnology/CO_00.00.00.15TC"
8+
deviceLabel: Ozom Carbon Monoxide Sensor
9+
manufacturer: ClimaxTechnology
10+
model: CO_00.00.00.15TC
11+
deviceProfileName: carbonMonoxide-battery
12+
- id: "HEIMAN/COSensor-EM"
13+
deviceLabel: HEIMAN Carbon Monoxide Sensor
14+
manufacturer: HEIMAN
15+
model: COSensor-EM
16+
deviceProfileName: carbonMonoxide-battery
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: carbonMonoxide-battery
2+
components:
3+
- id: main
4+
capabilities:
5+
- id: carbonMonoxideDetector
6+
version: 1
7+
- id: battery
8+
version: 1
9+
- id: refresh
10+
version: 1
11+
categories:
12+
- name: SmokeDetector
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
-- Copyright 2021 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.
14+
15+
local capabilities = require "st.capabilities"
16+
17+
local CLIMAX_TECHNOLOGY_CARBON_MONOXIDE_FINGERPRINTS = {
18+
{ mfr = "ClimaxTechnology", model = "CO_00.00.00.22TC" },
19+
{ mfr = "ClimaxTechnology", model = "CO_00.00.00.15TC" }
20+
}
21+
22+
local is_climax_technology_carbon_monoxide = function(opts, driver, device)
23+
for _, fingerprint in ipairs(CLIMAX_TECHNOLOGY_CARBON_MONOXIDE_FINGERPRINTS) do
24+
if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then
25+
return true
26+
end
27+
end
28+
29+
return false
30+
end
31+
32+
local device_added = function(self, device)
33+
device:emit_event(capabilities.battery.battery(100))
34+
end
35+
36+
local climax_technology_carbon_monoxide = {
37+
NAME = "ClimaxTechnology Carbon Monoxide",
38+
lifecycle_handlers = {
39+
added = device_added
40+
},
41+
can_handle = is_climax_technology_carbon_monoxide
42+
}
43+
44+
return climax_technology_carbon_monoxide
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
-- Copyright 2021 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.
14+
15+
local ZigbeeDriver = require "st.zigbee"
16+
local capabilities = require "st.capabilities"
17+
local defaults = require "st.zigbee.defaults"
18+
local constants = require "st.zigbee.constants"
19+
20+
--Temperature Measurement
21+
local zigbee_carbon_monoxide_driver_template = {
22+
supported_capabilities = {
23+
capabilities.carbonMonoxideDetector,
24+
capabilities.battery,
25+
},
26+
ias_zone_configuration_method = constants.IAS_ZONE_CONFIGURE_TYPE.AUTO_ENROLL_RESPONSE,
27+
sub_drivers = { require("ClimaxTechnology") }
28+
}
29+
30+
defaults.register_for_default_handlers(zigbee_carbon_monoxide_driver_template, zigbee_carbon_monoxide_driver_template.supported_capabilities)
31+
local zigbee_carbon_monoxide_driver = ZigbeeDriver("zigbee-carbon-monoxide-detector", zigbee_carbon_monoxide_driver_template)
32+
zigbee_carbon_monoxide_driver:run()
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
-- Copyright 2021 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.
14+
15+
-- Mock out globals
16+
local test = require "integration_test"
17+
local capabilities = require "st.capabilities"
18+
local zigbee_test_utils = require "integration_test.zigbee_test_utils"
19+
local t_utils = require "integration_test.utils"
20+
21+
local mock_device = test.mock_device.build_test_zigbee_device(
22+
{
23+
profile = t_utils.get_profile_definition("carbonMonoxide-battery.yml"),
24+
zigbee_endpoints = {
25+
[1] = {
26+
id = 1,
27+
manufacturer = "ClimaxTechnology",
28+
model = "CO_00.00.00.22TC",
29+
server_clusters = {0x0000}
30+
}
31+
}
32+
}
33+
)
34+
35+
zigbee_test_utils.prepare_zigbee_env_info()
36+
local function test_init()
37+
test.mock_device.add_test_device(mock_device)
38+
zigbee_test_utils.init_noop_health_check_timer()
39+
end
40+
test.set_test_init_function(test_init)
41+
42+
test.register_message_test(
43+
"added lifecycle event should get initial state for device",
44+
{
45+
{
46+
channel = "device_lifecycle",
47+
direction = "receive",
48+
message = { mock_device.id, "added"}
49+
},
50+
{
51+
channel = "capability",
52+
direction = "send",
53+
message = mock_device:generate_test_message("main", capabilities.battery.battery(100))
54+
}
55+
},
56+
{
57+
inner_block_ordering = "relaxed"
58+
}
59+
)
60+
61+
62+
test.run_registered_tests()
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
-- Copyright 2021 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.
14+
15+
-- Mock out globals
16+
local test = require "integration_test"
17+
local clusters = require "st.zigbee.zcl.clusters"
18+
local IASZone = clusters.IASZone
19+
local PowerConfiguration = clusters.PowerConfiguration
20+
local capabilities = require "st.capabilities"
21+
local zigbee_test_utils = require "integration_test.zigbee_test_utils"
22+
local IasEnrollResponseCode = require "st.zigbee.generated.zcl_clusters.IASZone.types.EnrollResponseCode"
23+
local base64 = require "st.base64"
24+
local t_utils = require "integration_test.utils"
25+
26+
27+
local mock_device = test.mock_device.build_test_zigbee_device(
28+
{ profile = t_utils.get_profile_definition("carbonMonoxide-battery.yml") }
29+
)
30+
31+
zigbee_test_utils.prepare_zigbee_env_info()
32+
local function test_init()
33+
test.mock_device.add_test_device(mock_device)
34+
zigbee_test_utils.init_noop_health_check_timer()
35+
end
36+
test.set_test_init_function(test_init)
37+
38+
test.register_message_test(
39+
"Reported carbonMonoxideDetector status should be handled: detected",
40+
{
41+
{
42+
channel = "zigbee",
43+
direction = "receive",
44+
message = { mock_device.id, IASZone.attributes.ZoneStatus:build_test_attr_report(mock_device, 0x0001) }
45+
},
46+
{
47+
channel = "capability",
48+
direction = "send",
49+
message = mock_device:generate_test_message("main", capabilities.carbonMonoxideDetector.carbonMonoxide.detected())
50+
}
51+
}
52+
)
53+
54+
test.register_message_test(
55+
"Reported carbonMonoxideDetector should be handled: clear",
56+
{
57+
{
58+
channel = "zigbee",
59+
direction = "receive",
60+
message = { mock_device.id, IASZone.attributes.ZoneStatus:build_test_attr_report(mock_device, 0x0000) }
61+
},
62+
{
63+
channel = "capability",
64+
direction = "send",
65+
message = mock_device:generate_test_message("main", capabilities.carbonMonoxideDetector.carbonMonoxide.clear())
66+
}
67+
}
68+
)
69+
70+
test.register_message_test(
71+
"ZoneStatusChangeNotification should be handled: detected",
72+
{
73+
{
74+
channel = "zigbee",
75+
direction = "receive",
76+
message = { mock_device.id, IASZone.client.commands.ZoneStatusChangeNotification.build_test_rx(mock_device, 0x0001, 0x00) }
77+
},
78+
{
79+
channel = "capability",
80+
direction = "send",
81+
message = mock_device:generate_test_message("main", capabilities.carbonMonoxideDetector.carbonMonoxide.detected())
82+
}
83+
}
84+
)
85+
86+
test.register_message_test(
87+
"ZoneStatusChangeNotification should be handled: clear",
88+
{
89+
{
90+
channel = "zigbee",
91+
direction = "receive",
92+
message = { mock_device.id, IASZone.client.commands.ZoneStatusChangeNotification.build_test_rx(mock_device, 0x0000, 0x00) }
93+
},
94+
{
95+
channel = "capability",
96+
direction = "send",
97+
message = mock_device:generate_test_message("main", capabilities.carbonMonoxideDetector.carbonMonoxide.clear())
98+
}
99+
}
100+
)
101+
102+
test.register_message_test(
103+
"Battery percentage report should be handled",
104+
{
105+
{
106+
channel = "zigbee",
107+
direction = "receive",
108+
message = { mock_device.id, PowerConfiguration.attributes.BatteryPercentageRemaining:build_test_attr_report(mock_device, 55) }
109+
},
110+
{
111+
channel = "capability",
112+
direction = "send",
113+
message = mock_device:generate_test_message("main", capabilities.battery.battery(28))
114+
}
115+
}
116+
)
117+
118+
test.register_coroutine_test(
119+
"Configure should configure all necessary attributes",
120+
function ()
121+
test.socket.zigbee:__set_channel_ordering("relaxed")
122+
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "added"})
123+
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "doConfigure"})
124+
test.socket.zigbee:__expect_send({
125+
mock_device.id,
126+
PowerConfiguration.attributes.BatteryPercentageRemaining:read(mock_device)
127+
})
128+
test.socket.zigbee:__expect_send({
129+
mock_device.id,
130+
IASZone.attributes.ZoneStatus:read(mock_device)
131+
})
132+
test.socket.zigbee:__expect_send({
133+
mock_device.id,
134+
PowerConfiguration.attributes.BatteryPercentageRemaining:configure_reporting(
135+
mock_device,
136+
30,
137+
21600,
138+
1
139+
)
140+
})
141+
test.socket.zigbee:__expect_send({
142+
mock_device.id,
143+
zigbee_test_utils.build_bind_request(
144+
mock_device,
145+
zigbee_test_utils.mock_hub_eui,
146+
PowerConfiguration.ID
147+
)
148+
})
149+
test.socket.zigbee:__expect_send({
150+
mock_device.id,
151+
IASZone.attributes.IASCIEAddress:write(
152+
mock_device,
153+
zigbee_test_utils.mock_hub_eui
154+
)
155+
})
156+
test.socket.zigbee:__expect_send({
157+
mock_device.id,
158+
IASZone.server.commands.ZoneEnrollResponse(
159+
mock_device,
160+
IasEnrollResponseCode.SUCCESS,
161+
0x00
162+
)
163+
})
164+
test.socket.zigbee:__expect_send({
165+
mock_device.id,
166+
IASZone.attributes.ZoneStatus:configure_reporting(
167+
mock_device,
168+
0,
169+
180,
170+
0
171+
)
172+
})
173+
test.socket.zigbee:__expect_send({
174+
mock_device.id,
175+
zigbee_test_utils.build_bind_request(
176+
mock_device,
177+
zigbee_test_utils.mock_hub_eui,
178+
IASZone.ID
179+
)
180+
})
181+
182+
mock_device:expect_metadata_update({ provisioning_state = "PROVISIONED" })
183+
end
184+
)
185+
186+
187+
188+
test.run_registered_tests()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: 'Zigbee Illuminance Sensor'
2+
packageKey: 'zigbee-illuminance-sensor'
3+
permissions:
4+
zigbee: {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
zigbeeGeneric:
2+
- id: "generic-illuminance-sensor"
3+
deviceLabel: Illuminance Sensor
4+
deviceIdentifiers:
5+
- 0x0106
6+
clusters:
7+
server:
8+
- 0x0400 # Illuminance Measurement Cluster
9+
deviceProfileName: base-illuminance
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: base-illuminance
2+
components:
3+
- id: main
4+
capabilities:
5+
- id: illuminanceMeasurement
6+
version: 1
7+
categories:
8+
- name: LightSensor

0 commit comments

Comments
 (0)