-
Notifications
You must be signed in to change notification settings - Fork 484
Wiszb 120/121 add support #2092
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
Open
marcintyminski
wants to merge
3
commits into
SmartThingsCommunity:main
Choose a base branch
from
marcintyminski:WISZB-120/121_add_support
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.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
30 changes: 30 additions & 0 deletions
30
drivers/SmartThings/zigbee-contact/profiles/contact-battery-temperature-tamper.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,30 @@ | ||
name: contact-battery-temperature-tamper | ||
components: | ||
- id: main | ||
capabilities: | ||
- id: contactSensor | ||
version: 1 | ||
- id: battery | ||
version: 1 | ||
- id: temperatureMeasurement | ||
version: 1 | ||
- id: tamperAlert | ||
version: 1 | ||
- id: firmwareUpdate | ||
version: 1 | ||
- id: refresh | ||
version: 1 | ||
categories: | ||
- name: ContactSensor | ||
preferences: | ||
- preferenceId: tempOffset | ||
explicit: true | ||
- title: "Temperature Sensitivity (°)" | ||
name: temperatureSensitivity | ||
description: "Minimum change in temperature to report" | ||
required: false | ||
preferenceType: number | ||
definition: | ||
minimum: 0.1 | ||
maximum: 2.0 | ||
default: 1.0 |
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
63 changes: 0 additions & 63 deletions
63
drivers/SmartThings/zigbee-contact/src/contact-temperature-sensor/frient-sensor/init.lua
This file was deleted.
Oops, something went wrong.
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
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,119 @@ | ||
-- Copyright 2022 SmartThings | ||
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. date |
||
-- | ||
-- 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 clusters = require "st.zigbee.zcl.clusters" | ||
local battery_defaults = require "st.zigbee.defaults.battery_defaults" | ||
local configurationMap = require "configurations" | ||
local capabilities = require "st.capabilities" | ||
|
||
local IASZone = clusters.IASZone | ||
local TemperatureMeasurement = clusters.TemperatureMeasurement | ||
local TEMPERATURE_ENDPOINT = 0x26 | ||
local DEFAULT_TEMPERATURE_SENSITIVITY = 100 | ||
|
||
|
||
local FRIENT_CONTACT_TEMPERATURE_FINGERPRINTS = { | ||
{ mfr = "frient A/S", model = "WISZB-120", has_temperature = true, has_tamper = true }, | ||
{ mfr = "frient A/S", model = "WISZB-121", has_temperature = false, has_tamper = false } | ||
} | ||
|
||
local function get_device_capabilities(device) | ||
for _, fingerprint in ipairs(FRIENT_CONTACT_TEMPERATURE_FINGERPRINTS) do | ||
if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then | ||
return fingerprint | ||
end | ||
end | ||
return nil | ||
end | ||
|
||
local function generate_event_from_zone_status(driver, device, zone_status, zb_rx) | ||
device:emit_event(zone_status:is_alarm1_set() and capabilities.contactSensor.contact.open() or capabilities.contactSensor.contact.closed()) | ||
local device_capabilities = get_device_capabilities(device) | ||
if device_capabilities ~= nil and device_capabilities.has_tamper then | ||
device:emit_event(zone_status:is_tamper_set() and capabilities.tamperAlert.tamper.detected() or capabilities.tamperAlert.tamper.clear()) | ||
end | ||
end | ||
|
||
local function ias_zone_status_attr_handler(driver, device, attr_val, zb_rx) | ||
generate_event_from_zone_status(driver, device, attr_val, zb_rx) | ||
end | ||
|
||
local function ias_zone_status_change_handler(driver, device, zb_rx) | ||
generate_event_from_zone_status(driver, device, zb_rx.body.zcl_body.zone_status, zb_rx) | ||
end | ||
|
||
local function device_init(driver, device) | ||
local configuration = configurationMap.get_device_configuration(device) | ||
|
||
battery_defaults.build_linear_voltage_init(2.3, 3.0)(driver, device) | ||
|
||
if configuration ~= nil then | ||
for _, attribute in ipairs(configuration) do | ||
device:add_configured_attribute(attribute) | ||
device:add_monitored_attribute(attribute) | ||
end | ||
end | ||
end | ||
|
||
local function added_handler(driver, device) | ||
local device_capabilities = get_device_capabilities(device) | ||
if device_capabilities ~= nil and device_capabilities.has_temperature then | ||
Comment on lines
+70
to
+71
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. standard practice here is:
|
||
device:send(TemperatureMeasurement.attributes.MaxMeasuredValue:read(device)) | ||
device:send(TemperatureMeasurement.attributes.MinMeasuredValue:read(device)) | ||
end | ||
end | ||
|
||
local function do_configure(driver, device) | ||
device:configure() | ||
device:refresh() | ||
end | ||
|
||
local function info_changed(driver, device, event, args) | ||
for name, value in pairs(device.preferences) do | ||
if (device.preferences[name] ~= nil and args.old_st_store.preferences[name] ~= device.preferences[name]) then | ||
if (name == "temperatureSensitivity") then | ||
local input = device.preferences.temperatureSensitivity | ||
local temperatureSensitivity = math.floor(input * 100 + 0.5) | ||
device:send(TemperatureMeasurement.attributes.MeasuredValue:configure_reporting(device, 30, 1800, temperatureSensitivity):to_endpoint(TEMPERATURE_ENDPOINT)) | ||
end | ||
end | ||
end | ||
end | ||
|
||
local frient_sensor = { | ||
NAME = "Frient Contact Temperature Tamper", | ||
lifecycle_handlers = { | ||
init = device_init, | ||
added = added_handler, | ||
doConfigure = do_configure, | ||
infoChanged = info_changed | ||
}, | ||
zigbee_handlers = { | ||
cluster = { | ||
[IASZone.ID] = { | ||
[IASZone.client.commands.ZoneStatusChangeNotification.ID] = ias_zone_status_change_handler, | ||
} | ||
}, | ||
attr = { | ||
[IASZone.ID] = { | ||
[IASZone.attributes.ZoneStatus.ID] = ias_zone_status_attr_handler, | ||
} | ||
} | ||
}, | ||
can_handle = function(opts, driver, device, ...) | ||
return (device:get_manufacturer() == "frient A/S" and (device:get_model() == "WISZB-120" or device:get_model() == "WISZB-121")) | ||
end | ||
} | ||
|
||
return frient_sensor |
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
Oops, something went wrong.
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.
if this is Celsius, could you indicate that? Some users may have their systems set to Fahrenheit