-
Notifications
You must be signed in to change notification settings - Fork 517
WWSTCERT-8745 Add shelly wave door-window driver #2460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8a0dec5
8b6be5d
8e69815
addb536
2fed046
85f2acf
4541c11
be963bc
d9d911c
f3cf073
d88b74a
0314b46
440ac6f
aa9df33
cdcc09d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: shelly-wave-door-window-sensor | ||
| components: | ||
| - id: main | ||
| capabilities: | ||
| - id: contactSensor | ||
| version: 1 | ||
| - id: illuminanceMeasurement | ||
| version: 1 | ||
| config: | ||
| values: | ||
| - key: "illuminance.value" | ||
| range: [0, 10000] | ||
| - id: battery | ||
| version: 1 | ||
| - id: refresh | ||
| version: 1 | ||
| categories: | ||
| - name: ContactSensor | ||
| preferences: | ||
| - name: "ledOpnClsChangeStat" | ||
| title: "P157: open/close change status" | ||
| description: "This parameter enables open/close status change by LED indicator." | ||
| required: false | ||
| preferenceType: enumeration | ||
| definition: | ||
| options: | ||
| 0 : "LED ind.disabled" | ||
| 1 : "LED ind.enabled" | ||
| default: 0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| -- Copyright 2025 SmartThings | ||
| -- | ||
| -- Licensed under the Apache License, Version 2.0 (the "License"); | ||
| -- you may not use this file except in compliance with the License. | ||
| -- You may obtain a copy of the License at | ||
| -- | ||
| -- http://www.apache.org/licenses/LICENSE-2.0 | ||
| -- | ||
| -- Unless required by applicable law or agreed to in writing, software | ||
| -- distributed under the License is distributed on an "AS IS" BASIS, | ||
| -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| -- See the License for the specific language governing permissions and | ||
| -- limitations under the License. | ||
|
|
||
| local capabilities = require "st.capabilities" | ||
| --- @type st.zwave.CommandClass | ||
| local cc = require "st.zwave.CommandClass" | ||
| --- @type st.zwave.CommandClass.Notification | ||
| local Notification = (require "st.zwave.CommandClass.Notification")({ version = 3 }) | ||
| --- @type st.zwave.CommandClass.SensorMultilevel | ||
| local SensorMultilevel = (require "st.zwave.CommandClass.SensorMultilevel")({ version = 5 }) | ||
|
|
||
| local WAVE_DOOR_WINDOW_SENSOR_FINGERPRINTS = { | ||
| { manufacturerId = 0x0460, prod = 0x0100, productId = 0x0081 } -- Wave Door/Window sensor | ||
| } | ||
|
|
||
| --- Determine whether the passed device is Wave Door/Window sensor | ||
| --- | ||
| --- @param driver Driver driver instance | ||
| --- @param device Device device isntance | ||
| --- @return boolean true if the device proper, else false | ||
| local function can_handle_wave_door_window_sensor(opts, driver, device, ...) | ||
| for _, fingerprint in ipairs(WAVE_DOOR_WINDOW_SENSOR_FINGERPRINTS) do | ||
| if device:id_match(fingerprint.manufacturerId, fingerprint.productType, fingerprint.productId) then | ||
| return true | ||
| end | ||
| end | ||
| return false | ||
| end | ||
|
Comment on lines
+32
to
+39
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For our drivers that use For an example: https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/blob/main/drivers/SmartThings/zwave-sensor/src/sensative-strip/init.lua#L29 |
||
|
|
||
| --- Handler for notification report command class | ||
| --- | ||
| --- @param self st.zwave.Driver | ||
| --- @param device st.zwave.Device | ||
| --- @param cmd st.zwave.CommandClass.Notification.Report | ||
| local function notification_report_handler(self, device, cmd) | ||
| local notificationType = cmd.args.notification_type | ||
| local event = cmd.args.event | ||
| if cmd.args.notification_type == Notification.notification_type.ACCESS_CONTROL then | ||
| if cmd.args.event == Notification.event.home_security.ACCESS_CONTROL then | ||
| event = cmd.args.notification_status == 0 and capabilities.contactSensor.contact.closed() or capabilities.contactSensor.contact.open() | ||
| elseif notificationType == Notification.notification_type.ACCESS_CONTROL then | ||
| if event == Notification.event.access_control.WINDOW_DOOR_IS_OPEN then | ||
| device:emit_event(capabilities.contactSensor.contact.open()) | ||
| elseif event == Notification.event.access_control.WINDOW_DOOR_IS_CLOSED then | ||
| device:emit_event(capabilities.contactSensor.contact.closed()) | ||
| end | ||
| end | ||
| end | ||
| if (event ~= nil) then | ||
| device:emit_event(event) | ||
| end | ||
| end | ||
|
|
||
| --- Handler for multilevel sensor report command class | ||
| --- @param self st.zwave.Driver | ||
| --- @param device st.zwave.Device | ||
| --- @param cmd st.zwave.CommandClass.SensorMultilevel.Report | ||
| local function sensor_multilevel_report_handler(self, device, cmd) | ||
| if cmd.args.sensor_type == SensorMultilevel.sensor_type.LUMINANCE then | ||
| device:emit_event(capabilities.illuminanceMeasurement.illuminance({value = cmd.args.sensor_value, unit = "lux"})) | ||
| elseif cmd.args.sensor_type == SensorMultilevel.sensor_type.DIRECTION then | ||
| device:emit_event(capabilities.relativeHumidityMeasurement.humidity({value = cmd.args.sensor_value, unit = "%"})) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: spacing
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The profile you've specified doesn't include |
||
| end | ||
| end | ||
|
|
||
| local wave_door_window_sensor = { | ||
| zwave_handlers = { | ||
| [cc.NOTIFICATION] = { | ||
| [Notification.REPORT] = notification_report_handler | ||
| }, | ||
| [cc.SENSOR_MULTILEVEL] = { | ||
| [SensorMultilevel.REPORT] = sensor_multilevel_report_handler | ||
| } | ||
| }, | ||
| NAME = "shelly wave door window sensor", | ||
| can_handle = can_handle_wave_door_window_sensor | ||
| } | ||
|
|
||
| return wave_door_window_sensor | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.