Skip to content

Matter Sensor: Fix Global defintion and adjust unit tests#3125

Open
ctowns wants to merge 1 commit into
mainfrom
bugfix/soil-moisture-unit-tests
Open

Matter Sensor: Fix Global defintion and adjust unit tests#3125
ctowns wants to merge 1 commit into
mainfrom
bugfix/soil-moisture-unit-tests

Conversation

@ctowns

@ctowns ctowns commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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

Updates the embedded cluster definition to be using the same type that is expected from the lua libs.

Since the lua libs themselves did not have the SOIL_MOISTURE enum variant until the API 21 release (FW62), this updates the API checks to make sure that drivers use the embedded cluster definition on hubs without those updated lua libs.

Summary of Completed Tests

@github-actions

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

Test Results

   73 files  ±0    538 suites  ±0   0s ⏱️ ±0s
3 192 tests ±0  3 192 ✅ ±0  0 💤 ±0  0 ❌ ±0 
5 193 runs  ±0  5 193 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 0255dd3. ± Comparison against base commit 4a06ba8.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

File Coverage
All files 87%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/lazy_load_subdriver.lua 57%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/init.lua 93%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/sub_drivers/bosch_button_contact/init.lua 83%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/sensor_utils/embedded_cluster_utils.lua 71%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/sensor_utils/utils.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/sensor_utils/device_configuration.lua 90%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/embedded_clusters/SoilMeasurement/server/attributes/SoilMoistureMeasurementLimits.lua 85%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/embedded_clusters/SoilMeasurement/server/attributes/SoilMoistureMeasuredValue.lua 86%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/embedded_clusters/Global/types/MeasurementAccuracyStruct.lua 79%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/embedded_clusters/Global/types/MeasurementAccuracyRangeStruct.lua 80%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/sub_drivers/air_quality_sensor/air_quality_sensor_utils/fields.lua 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/sub_drivers/air_quality_sensor/air_quality_sensor_utils/device_configuration.lua 86%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/sub_drivers/air_quality_sensor/air_quality_sensor_utils/utils.lua 74%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/sub_drivers/air_quality_sensor/air_quality_sensor_utils/legacy_device_configuration.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/embedded_clusters/SoilMeasurement/init.lua 93%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/sub_drivers/smoke_co_alarm/init.lua 82%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/sub_drivers/air_quality_sensor/init.lua 87%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/sensor_handlers/attribute_handlers.lua 87%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-sensor/src/sub_drivers/air_quality_sensor/air_quality_sensor_handlers/attribute_handlers.lua 78%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 0255dd3

@ctowns
ctowns force-pushed the bugfix/soil-moisture-unit-tests branch 3 times, most recently from 7b39d29 to de74548 Compare July 16, 2026 18:15
-- The SOIL_MOISTURE MeasurementTypeEnum variant was added to the Global MeasurementTypeEnum
-- def in lua libs in api version 21 as a part of the fix for Shared and Global types.
if version.api < 21 then
clusters.SoilMeasurement = require "embedded_clusters.SoilMeasurement"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we be removing the soil version check?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Whoops, must've deleted this while I was moving things around, added back

Comment on lines +14 to +15
-- The SOIL_MOISTURE MeasurementTypeEnum variant was added to the Global MeasurementTypeEnum
-- def in lua libs in api version 21 as a part of the fix for Shared and Global types.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
-- The SOIL_MOISTURE MeasurementTypeEnum variant was added to the Global MeasurementTypeEnum
-- def in lua libs in api version 21 as a part of the fix for Shared and Global types.
-- The SOIL_MOISTURE MeasurementTypeEnum variant was added to the Global MeasurementTypeEnum
-- def in lua libs in api version 21

nit: I feel like this last part of the comment overcomplicates things

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah I agree, removed.

@ctowns
ctowns force-pushed the bugfix/soil-moisture-unit-tests branch from de74548 to 0255dd3 Compare July 16, 2026 19:19
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.

2 participants