-
Notifications
You must be signed in to change notification settings - Fork 553
Feature: Adds Z-Wave Safety Shutoff class of devices & FireAvert shutoff models #2908
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
Draft
bstewart-cae
wants to merge
12
commits into
SmartThingsCommunity:main
Choose a base branch
from
bstewart-cae:feature/add-safety-shutoff
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+528
−0
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5140022
Initial commit - added safety shutoff
bstewart-cae 1ef7df8
wip: fixed issues with bootup and missing handlers. removed reference…
bstewart-cae 96c1d6d
Added missing sound reference to config files
bstewart-cae 6436bb2
WIP: Tested Electric and Gas units. Added Application Rejection handl…
bstewart-cae 0e3f8e8
continued work on device capabilities and UI mapping.
bstewart-cae c0d4143
WIP: replaced powermeter with appliance utilization.
bstewart-cae 290ca2d
Moved capabilities for consistency across device types
bstewart-cae bba2705
Fixed issues with detail view on electric units. Added switch handler…
bstewart-cae 4462028
Merge branch 'main' into feature/add-safety-shutoff
bstewart-cae 8dcc524
bug: removed extraneous undefined variable reference
bstewart-cae f3fda9f
feat: removed unused capabilities, added refresh, fixed issues with n…
bstewart-cae e458f92
commented out automation section
bstewart-cae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| name: 'Z-Wave Appliance Safety' | ||
| packageKey: 'zwave-appliance-safety' | ||
| permissions: | ||
| zwave: {} | ||
| description: "SmartThings driver for Z-Wave appliance safety devices." | ||
| vendorSupportInformation: "https://support.smartthings.com" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| zwaveManufacturer: | ||
| - id: "FireAvert/Shutoff/Gas" | ||
| deviceLabel: FireAvert Shutoff for Gas Appliances | ||
| manufacturerId: 0x045D | ||
| productType: 0x0004 | ||
| productId: 0x1601 | ||
| deviceProfileName: fireavert-appliance-shutoff-gas | ||
| - id: "FireAvert/Shutoff/120v" | ||
| deviceLabel: FireAvert Shutoff for Electric Appliances | ||
| manufacturerId: 0x045D | ||
| productType: 0x0004 | ||
| productId: 0x0601 | ||
| deviceProfileName: fireavert-appliance-shutoff-electric | ||
| - id: "FireAvert/Shutoff/240v3" | ||
| deviceLabel: FireAvert Shutoff for Electric Appliances | ||
| manufacturerId: 0x045D | ||
| productType: 0x0004 | ||
| productId: 0x0602 | ||
| deviceProfileName: fireavert-appliance-shutoff-electric | ||
| - id: "FireAvert/Shutoff/240v4" | ||
| deviceLabel: FireAvert Shutoff for Electric Appliances | ||
| manufacturerId: 0x045D | ||
| productType: 0x0004 | ||
| productId: 0x0603 | ||
| deviceProfileName: fireavert-appliance-shutoff-electric | ||
|
|
61 changes: 61 additions & 0 deletions
61
drivers/SmartThings/zwave-safety-shutoff/profiles/fireavert-appliance-shutoff-electric.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| name: fireavert-appliance-shutoff-electric | ||
| components: | ||
| - id: main | ||
| label: "Appliance Information" | ||
| capabilities: | ||
| - id: refresh | ||
| version: 1 | ||
| - id: soundDetection | ||
| version: 1 | ||
| config: | ||
| values: | ||
| - key: supportedSoundTypes.value | ||
| enabledValues: | ||
| - noSound | ||
| - fireAlarm | ||
| - id: switch | ||
| version: 1 | ||
| - id: applianceUtilization | ||
| version: 1 | ||
| categories: | ||
| - name: SmokeDetector | ||
| deviceConfig: | ||
| dashboard: | ||
| states: | ||
| - component: main | ||
| capability: soundDetection | ||
| version: 1 | ||
| detailView: | ||
| - component: main | ||
| capability: soundDetection | ||
| version: 1 | ||
| - component: main | ||
| capability: switch | ||
| version: 1 | ||
| - component: main | ||
| capability: applianceUtilization | ||
| version: 1 | ||
| label: "Appliance Power" | ||
| values: | ||
| - key: status.value | ||
| alternatives: | ||
| - key: inUse | ||
| value: "Appliance Powered On" | ||
| type: active | ||
| - key: notInUse | ||
| value: "Appliance Powered Off" | ||
| type: inactive | ||
| # automation: | ||
| # conditions: | ||
| # - label: "Smoke Detection Status" | ||
| # displayType: list | ||
| # list: | ||
| # alternatives: | ||
| # - key: fireAlarm | ||
| # value: Smoke Alarm Detected | ||
| # type: active | ||
| # - key: noSound | ||
| # value: No Smoke Alarm Detected | ||
| # type: inactive | ||
| # value: soundDetection.value | ||
| # valueType: string | ||
33 changes: 33 additions & 0 deletions
33
drivers/SmartThings/zwave-safety-shutoff/profiles/fireavert-appliance-shutoff-gas.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: fireavert-appliance-shutoff-gas | ||
| components: | ||
| - id: main | ||
| label: "Appliance Control" | ||
| capabilities: | ||
| - id: refresh | ||
| version: 1 | ||
| - id: soundDetection | ||
| version: 1 | ||
| config: | ||
| values: | ||
| - key: supportedSoundTypes.value | ||
|
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. Please check with: |
||
| enabledValues: | ||
| - noSound | ||
| - fireAlarm | ||
| - id: switch | ||
| version: 1 | ||
| categories: | ||
| - name: SmokeDetector | ||
| # automation: | ||
| # conditions: | ||
| # - label: "Smoke Detection Status" | ||
| # displayType: list | ||
| # list: | ||
| # alternatives: | ||
| # - key: fireAlarm | ||
| # value: Smoke Alarm Detected | ||
| # type: active | ||
| # - key: noSound | ||
| # value: No Smoke Alarm Detected | ||
| # type: inactive | ||
| # value: soundDetection.value | ||
| # valueType: string | ||
97 changes: 97 additions & 0 deletions
97
drivers/SmartThings/zwave-safety-shutoff/src/fireavert-appliance-shutoff-electric/init.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| -- Copyright 2022 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 }) | ||
|
|
||
| local FIREAVERT_APPLIANCE_SHUTOFF_FINGERPRINTS = { | ||
| { manufacturerId = 0x045D, productType = 0x0004, productId = 0x0601 }, -- FireAvert Appliance Shutoff - 120V | ||
| { manufacturerId = 0x045D, productType = 0x0004, productId = 0x0602 }, -- FireAvert Appliance Shutoff - 240V 3 Prong | ||
| { manufacturerId = 0x045D, productType = 0x0004, productId = 0x0603 }, -- FireAvert Appliance Shutoff - 240V 4 Prong | ||
| } | ||
| --- Determine whether the passed device is a FireAvert shutoff device. All devices use the same driver. | ||
| local function can_handle_fireavert_appliance_shutoff_e(opts, driver, device, ...) | ||
| local isDevice = false | ||
| for _, fingerprint in ipairs(FIREAVERT_APPLIANCE_SHUTOFF_FINGERPRINTS) do | ||
| if device:id_match(fingerprint.manufacturerId, fingerprint.productType, fingerprint.productId) then | ||
| isDevice = true | ||
| break | ||
| end | ||
| end | ||
| if true == isDevice then | ||
| local subdriver = require("fireavert-appliance-shutoff-electric") | ||
| return true, subdriver | ||
| else return false end | ||
| end | ||
|
|
||
| --- Handler for notification report command class from sensor | ||
| --- | ||
| --- @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 event = nil | ||
| if cmd.args.notification_type == Notification.notification_type.SMOKE then | ||
| -- First, ensure that control is still valid | ||
| if cmd.args.event == Notification.event.smoke.DETECTED then | ||
| event = capabilities.soundDetection.soundDetected.fireAlarm() | ||
| elseif cmd.args.event == Notification.event.smoke.STATE_IDLE then | ||
| event = capabilities.soundDetection.soundDetected.noSound() | ||
| end | ||
| elseif cmd.args.notification_type == Notification.notification_type.POWER_MANAGEMENT then | ||
| if (cmd.args.event == Notification.event.power_management.POWER_HAS_BEEN_APPLIED) then | ||
| event = capabilities.applianceUtilization.status.inUse() | ||
| elseif (cmd.args.event == Notification.event.power_management.STATE_IDLE) then | ||
| event = capabilities.applianceUtilization.status.notInUse() | ||
| end | ||
| end | ||
| -- While the device supports other notifications, they are out of scope for WWST certification. | ||
| if event ~= nil then | ||
| print("Notification event: %s", event) | ||
| device:emit_event(event) | ||
| end | ||
| if status ~= nil then | ||
| print("Notification status %s set", status) | ||
| device:emit_event(status) | ||
| end | ||
| end | ||
|
|
||
| --- Configuration lifecycle event handler. | ||
| --- | ||
| --- Send refresh GETs and manufacturer-specific configuration for | ||
| --- the FireAvert Appliance Shutoff device | ||
| --- | ||
| --- @param self st.zwave.Driver | ||
| --- @param device st.zwave.Device | ||
| local function do_configure(self, device) | ||
| device:refresh() | ||
| end | ||
|
|
||
| local fireavert_appliance_shutoff_e = { | ||
| zwave_handlers = { | ||
| [cc.NOTIFICATION] = { | ||
| [Notification.REPORT] = notification_report_handler | ||
| }, | ||
| }, | ||
| lifecycle_handlers = { | ||
| doConfigure = do_configure, | ||
| }, | ||
| NAME = "FireAvert Appliance Shutoff - Electric", | ||
| can_handle = can_handle_fireavert_appliance_shutoff_e | ||
| } | ||
|
|
||
| return fireavert_appliance_shutoff_e |
82 changes: 82 additions & 0 deletions
82
drivers/SmartThings/zwave-safety-shutoff/src/fireavert-appliance-shutoff-gas/init.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| -- Copyright 2022 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 }) | ||
|
|
||
| local FIREAVERT_APPLIANCE_SHUTOFF_FINGERPRINTS = { | ||
| { manufacturerId = 0x045D, productType = 0x0004, productId = 0x1601 } -- FireAvert Appliance Shutoff - Gas | ||
| } | ||
| --- Determine whether the passed device is a FireAvert shutoff device. All devices use the same driver. | ||
| local function can_handle_fireavert_appliance_shutoff_gas(opts, driver, device, ...) | ||
| local isDevice = false | ||
| for _, fingerprint in ipairs(FIREAVERT_APPLIANCE_SHUTOFF_FINGERPRINTS) do | ||
| if device:id_match(fingerprint.manufacturerId, fingerprint.productType, fingerprint.productId) then | ||
| isDevice = true | ||
| break | ||
| end | ||
| end | ||
| if true == isDevice then | ||
| local subdriver = require("fireavert-appliance-shutoff-gas") | ||
| return true, subdriver | ||
| else return false end | ||
| end | ||
|
|
||
| --- Handler for notification report command class from sensor | ||
| --- | ||
| --- @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 event = nil | ||
| --- Z-Wave's closest match is a smoke detection notification, but this more | ||
| --- cleanly maps to Sound Detection in SmartThings. | ||
| if cmd.args.notification_type == Notification.notification_type.SMOKE then | ||
| if cmd.args.event == Notification.event.smoke.DETECTED then | ||
| event = capabilities.soundDetection.soundDetected.fireAlarm() | ||
| elseif cmd.args.event == Notification.event.smoke.STATE_IDLE then | ||
| event = capabilities.soundDetection.soundDetected.noSound() | ||
| end | ||
| end | ||
| if event ~= nil then device:emit_event(event) end | ||
| end | ||
|
|
||
| --- Configuration lifecycle event handler. | ||
| --- | ||
| --- Send refresh GETs and manufacturer-specific configuration for | ||
| --- the FireAvert Appliance Shutoff device | ||
| --- | ||
| --- @param self st.zwave.Driver | ||
| --- @param device st.zwave.Device | ||
| local function do_configure(self, device) | ||
| device:refresh() | ||
| end | ||
|
|
||
| local fireavert_appliance_shutoff_g = { | ||
| zwave_handlers = { | ||
| [cc.NOTIFICATION] = { | ||
| [Notification.REPORT] = notification_report_handler | ||
| }, | ||
| }, | ||
| lifecycle_handlers = { | ||
| doConfigure = do_configure, | ||
| }, | ||
| NAME = "FireAvert Appliance Shutoff - Gas", | ||
| can_handle = can_handle_fireavert_appliance_shutoff_gas | ||
| } | ||
|
|
||
| return fireavert_appliance_shutoff_g |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please check with:
soundDetected.value