Skip to content

WWSTCERT-8745 Add support to frient vibration sensor wiszb 137#2454

Merged
greens merged 21 commits intoSmartThingsCommunity:mainfrom
marcintyminski:Add-support-to-frient-vibration-sensor-WISZB-137
Feb 5, 2026
Merged

WWSTCERT-8745 Add support to frient vibration sensor wiszb 137#2454
greens merged 21 commits intoSmartThingsCommunity:mainfrom
marcintyminski:Add-support-to-frient-vibration-sensor-WISZB-137

Conversation

@marcintyminski
Copy link
Contributor

Check all that apply

Type of Change

  • WWST Certification Request
    • If this is your first time contributing code:
      • I have reviewed the README.md file
      • I have reviewed the CODE_OF_CONDUCT.md file
      • I have signed the CLA
    • I plan on entering a WWST Certification Request or have entered a request through the WWST Certification console at developer.smartthings.com
  • Bug fix
  • New feature
  • Refactor

Checklist

  • I have performed a self-review of my code
  • I have commented my code in hard-to-understand areas
  • I have verified my changes by testing with a device or have communicated a plan for testing
  • I am adding new behavior, such as adding a sub-driver, and have added and run new unit tests to cover the new behavior

Description of Change

Summary of Completed Tests

@github-actions
Copy link

github-actions bot commented Oct 7, 2025

Duplicate profile check: Passed - no duplicate profiles detected.

@github-actions
Copy link

github-actions bot commented Oct 7, 2025

Channel deleted.

@github-actions
Copy link

github-actions bot commented Oct 7, 2025

Test Results

   71 files    485 suites   0s ⏱️
2 518 tests 2 518 ✅ 0 💤 0 ❌
4 332 runs  4 332 ✅ 0 💤 0 ❌

Results for commit 9ff61c4.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Oct 7, 2025

File Coverage
All files 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-contact/src/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-contact/src/multi-sensor/init.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-contact/src/frient/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-contact/src/smartsense-multi/init.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-contact/src/frient/frient-vibration/init.lua 88%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 9ff61c4

@greens greens changed the title Add support to frient vibration sensor wiszb 137 WWSTCERT-8745 Add support to frient vibration sensor wiszb 137 Nov 4, 2025
Copy link
Contributor

@wkhenon wkhenon left a comment

Choose a reason for hiding this comment

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

LGTM

if attribute_id == 0x0000 then
measured_x = axis_value
device:set_field("measured_x", measured_x)
log.trace("Updated X value: " .. axis_value)
Copy link
Contributor

Choose a reason for hiding this comment

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

if you're satisfied with the behavior, please remove the logging

ID = 0xFC04,
ManufacturerSpecificCode = 0x1015,
attributes = {
MeasuredValueX = { ID = 0x0000, data_type = data_types.name_to_id_map["Int16"] },
Copy link
Contributor

Choose a reason for hiding this comment

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

you can just use data_types.Int16

Comment on lines 164 to 169
log.trace "Initializing sensor"
battery_defaults.build_linear_voltage_init(2.3, 3.0)(driver, device)
--Add the manufacturer-specific attributes to generate their configure reporting and bind requests
for _, config in pairs(get_cluster_configurations()) do
device:add_configured_attribute(config)
end
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we use 2 spaces

@KKlimczukS KKlimczukS requested a review from greens November 17, 2025 09:06
Comment on lines 80 to 103
if device.preferences.garageSensor == "Yes" then
if device.preferences.contactSensorAxis == "X" then
local initial_position = device.preferences.sensorInitialPosition or 0
if math.abs(initial_position - measured_x) >= device.preferences.contactSensorValue - device.preferences.contactSensorValue * (device.preferences.tolerance / 100) then
device:emit_event(capabilities.contactSensor.contact.open())
else
device:emit_event(capabilities.contactSensor.contact.closed())
end
elseif device.preferences.contactSensorAxis == "Y" then
local initial_position = device.preferences.sensorInitialPosition or 0
if math.abs(initial_position - measured_y) >= device.preferences.contactSensorValue - device.preferences.contactSensorValue * (device.preferences.tolerance / 100) then
device:emit_event(capabilities.contactSensor.contact.open())
else
device:emit_event(capabilities.contactSensor.contact.closed())
end
elseif device.preferences.contactSensorAxis == "Z" then
local initial_position = device.preferences.sensorInitialPosition or 0
if math.abs(initial_position - measured_z) >= device.preferences.contactSensorValue - device.preferences.contactSensorValue * (device.preferences.tolerance / 100) then
device:emit_event(capabilities.contactSensor.contact.open())
else
device:emit_event(capabilities.contactSensor.contact.closed())
end
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if device.preferences.garageSensor == "Yes" then
if device.preferences.contactSensorAxis == "X" then
local initial_position = device.preferences.sensorInitialPosition or 0
if math.abs(initial_position - measured_x) >= device.preferences.contactSensorValue - device.preferences.contactSensorValue * (device.preferences.tolerance / 100) then
device:emit_event(capabilities.contactSensor.contact.open())
else
device:emit_event(capabilities.contactSensor.contact.closed())
end
elseif device.preferences.contactSensorAxis == "Y" then
local initial_position = device.preferences.sensorInitialPosition or 0
if math.abs(initial_position - measured_y) >= device.preferences.contactSensorValue - device.preferences.contactSensorValue * (device.preferences.tolerance / 100) then
device:emit_event(capabilities.contactSensor.contact.open())
else
device:emit_event(capabilities.contactSensor.contact.closed())
end
elseif device.preferences.contactSensorAxis == "Z" then
local initial_position = device.preferences.sensorInitialPosition or 0
if math.abs(initial_position - measured_z) >= device.preferences.contactSensorValue - device.preferences.contactSensorValue * (device.preferences.tolerance / 100) then
device:emit_event(capabilities.contactSensor.contact.open())
else
device:emit_event(capabilities.contactSensor.contact.closed())
end
end
end
if device.preferences.garageSensor == "Yes" then
local garageAxis = measured_x
if device.preferences.contactSensorAxis == "Y" then
garageAxis = measured_y
elseif device.preferences.contactSensorAxis == "Z" then
garageAxis = measured_z
end
local initial_position = device.preferences.sensorInitialPosition or 0
if math.abs(initial_position - garageAxis) >= device.preferences.contactSensorValue - device.preferences.contactSensorValue * (device.preferences.tolerance / 100) then
device:emit_event(capabilities.contactSensor.contact.open())
else
device:emit_event(capabilities.contactSensor.contact.closed())
end
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have made a change and pushed the change to pr


-- Ensure all values are non-nil before emitting
if measured_x and measured_y and measured_z then
device:emit_event(threeAxis.threeAxis({measured_x, measured_y, measured_z}))
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't the measured_{} fields need to be reset after an event is sent so that a new event is only sent when you get three new measurements?

Copy link
Contributor

Choose a reason for hiding this comment

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

would be good to have a test case of this.

Copy link
Contributor

Choose a reason for hiding this comment

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

@greens Each value shall update whenever any of them changes; therefore, not only when 3 of them change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to clarify on it, the body will always contains of three values, as these values are never nill or empty. Also, each of values shall update whenever there is a change on them.

Copy link
Contributor

Choose a reason for hiding this comment

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

would be good to have a test case of this.

I can see that we have some test cases for X, Y, Z axes cases - can you clarify on which additional test cases you're thinking about? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The device would send bundled report with the changed value, and last cached values for remaining axes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, so your driver would send three events. 2 of those are likely to get bounced for being duplicates, but it's not an ideal situation to have to rely on that.

Since you can always rely on the device sending all 3 attributes every time, it should be easy to update the driver to only send one event after it's received a report for all three attributes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can now omit the usage of device:set_field and get_field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@KKlimczukS KKlimczukS requested a review from greens January 16, 2026 10:49
if measured_x and measured_y and measured_z then
device:emit_event(threeAxis.threeAxis({measured_x, measured_y, measured_z}))

if device.preferences.garageSensor == "Yes" then
Copy link
Contributor

Choose a reason for hiding this comment

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

a better check is probably to see if the device supports the contactSensor capability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed

- id: refresh
version: 1
categories:
- name: VibrationsSensor
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not certain this category is defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. Changed it to ContactSensor

@greens greens merged commit 6f4e5d2 into SmartThingsCommunity:main Feb 5, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants