Skip to content

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
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions drivers/SmartThings/zigbee-contact/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ zigbeeManufacturer:
model: SS-B100-ZB
deviceProfileName: contact-battery-temperature
- id: "frient A/S/WISZB-120"
deviceLabel: frient Open/Closed Sensor
deviceLabel: frient Entry Sensor Pro
manufacturer: frient A/S
model: WISZB-120
deviceProfileName: contact-battery-temperature
deviceProfileName: contact-battery-temperature-tamper
- id: "frient A/S/WISZB-121"
deviceLabel: frient Open/Closed Sensor
deviceLabel: frient Entry Sensor
manufacturer: frient A/S
model: WISZB-121
deviceProfileName: contact-battery-temperature
deviceProfileName: contact-battery-profile
- id: "Compacta/ZBWDS"
deviceLabel: Smartenit Open/Closed Sensor
manufacturer: Compacta
Expand Down
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 (°)"
Copy link
Contributor

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

name: temperatureSensitivity
description: "Minimum change in temperature to report"
required: false
preferenceType: number
definition:
minimum: 0.1
maximum: 2.0
default: 1.0
18 changes: 16 additions & 2 deletions drivers/SmartThings/zigbee-contact/src/configurations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ local devices = {
{ mfr = "Sercomm Corp.", model = "SZ-DWS04" },
{ mfr = "DAWON_DNS", model = "SS-B100-ZB" },
{ mfr = "frient A/S", model = "WISZB-120" },
{ mfr = "frient A/S", model = "WISZB-121" },
{ mfr = "Compacta", model = "ZBWDS" }
},
CONFIGURATION = {
Expand All @@ -113,7 +112,22 @@ local devices = {
reportable_change = 100
}
}
}
},
FRIENT_CONTACT_SENSOR_WISZB_121 = {
FINGERPRINTS = {
{ mfr = "frient A/S", model = "WISZB-121" }
},
CONFIGURATION = {
{
cluster = IASZone.ID,
attribute = IASZone.attributes.ZoneStatus.ID,
minimum_interval = 30,
maximum_interval = 300,
data_type = IASZone.attributes.ZoneStatus.base_type,
reportable_change = 1
}
}
},
}

local configurations = {}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ local CONTACT_TEMPERATURE_SENSOR_FINGERPRINTS = {
{ mfr = "ADUROLIGHT", model = "CSW_ADUROLIGHT" },
{ mfr = "Sercomm Corp.", model = "SZ-DWS04" },
{ mfr = "DAWON_DNS", model = "SS-B100-ZB" },
{ mfr = "frient A/S", model = "WISZB-120" },
{ mfr = "frient A/S", model = "WISZB-121" },
{ mfr = "Compacta", model = "ZBWDS" }
}

Expand Down Expand Up @@ -65,8 +63,7 @@ local contact_temperature_sensor = {
init = device_init
},
sub_drivers = {
require("contact-temperature-sensor/ecolink-contact"),
require("contact-temperature-sensor/frient-sensor")
require("contact-temperature-sensor/ecolink-contact")
},
can_handle = can_handle_contact_temperature_sensor
}
Expand Down
119 changes: 119 additions & 0 deletions drivers/SmartThings/zigbee-contact/src/frient/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
-- Copyright 2022 SmartThings
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

standard practice here is:

device:supports_capability_by_id([Capability.ID])

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
3 changes: 2 additions & 1 deletion drivers/SmartThings/zigbee-contact/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ local zigbee_contact_driver_template = {
require("contact-temperature-sensor"),
require("multi-sensor"),
require("smartsense-multi"),
require("sengled")
require("sengled"),
require("frient")
},
ias_zone_configuration_method = constants.IAS_ZONE_CONFIGURE_TYPE.AUTO_ENROLL_RESPONSE
}
Expand Down
Loading
Loading