diff --git a/drivers/SmartThings/matter-sensor/src/air-quality-sensor/init.lua b/drivers/SmartThings/matter-sensor/src/air-quality-sensor/init.lua index 2b4560fe0a..09dc5ad4d6 100644 --- a/drivers/SmartThings/matter-sensor/src/air-quality-sensor/init.lua +++ b/drivers/SmartThings/matter-sensor/src/air-quality-sensor/init.lua @@ -309,11 +309,11 @@ local unit_default = { [capabilities.fineDustSensor.NAME] = units.UGM3, [capabilities.dustSensor.NAME] = units.UGM3, [capabilities.radonMeasurement.NAME] = units.BQM3, - [capabilities.tvocMeasurement.NAME] = units.PPM + [capabilities.tvocMeasurement.NAME] = units.PPB -- TVOC is typically within the range of 0-5500 ppb, with good to moderate values being < 660 ppb } --- All ConcentrationMesurement clusters inherit from the same base cluster definitions, --- so CarbonMonoxideConcentratinMeasurement is used below but the same enum types exist +-- All ConcentrationMeasurement clusters inherit from the same base cluster definitions, +-- so CarbonMonoxideConcentrationMeasurement is used below but the same enum types exist -- in all ConcentrationMeasurement clusters local level_strings = { [clusters.CarbonMonoxideConcentrationMeasurement.types.LevelValueEnum.UNKNOWN] = "unknown", @@ -325,10 +325,12 @@ local level_strings = { local conversion_tables = { [units.PPM] = { - [units.PPM] = function(value) return utils.round(value) end + [units.PPM] = function(value) return utils.round(value) end, + [units.PPB] = function(value) return utils.round(value * (10^3)) end }, [units.PPB] = { - [units.PPM] = function(value) return utils.round(value/(10^3)) end + [units.PPM] = function(value) return utils.round(value/(10^3)) end, + [units.PPB] = function(value) return utils.round(value) end }, [units.PPT] = { [units.PPM] = function(value) return utils.round(value/(10^6)) end @@ -473,7 +475,7 @@ local matter_air_quality_sensor_handler = { [clusters.RadonConcentrationMeasurement.attributes.LevelValue.ID] = levelHandlerFactory(capabilities.radonHealthConcern.radonHealthConcern) }, [clusters.TotalVolatileOrganicCompoundsConcentrationMeasurement.ID] = { - [clusters.TotalVolatileOrganicCompoundsConcentrationMeasurement.attributes.MeasuredValue.ID] = measurementHandlerFactory(capabilities.tvocMeasurement.NAME, capabilities.tvocMeasurement.tvocLevel, units.PPM), + [clusters.TotalVolatileOrganicCompoundsConcentrationMeasurement.attributes.MeasuredValue.ID] = measurementHandlerFactory(capabilities.tvocMeasurement.NAME, capabilities.tvocMeasurement.tvocLevel, units.PPB), [clusters.TotalVolatileOrganicCompoundsConcentrationMeasurement.attributes.MeasurementUnit.ID] = store_unit_factory(capabilities.tvocMeasurement.NAME), [clusters.TotalVolatileOrganicCompoundsConcentrationMeasurement.attributes.LevelValue.ID] = levelHandlerFactory(capabilities.tvocHealthConcern.tvocHealthConcern) } diff --git a/drivers/SmartThings/matter-sensor/src/test/test_matter_air_quality_sensor.lua b/drivers/SmartThings/matter-sensor/src/test/test_matter_air_quality_sensor.lua index f2dd259d7d..1f735898e5 100644 --- a/drivers/SmartThings/matter-sensor/src/test/test_matter_air_quality_sensor.lua +++ b/drivers/SmartThings/matter-sensor/src/test/test_matter_air_quality_sensor.lua @@ -634,6 +634,21 @@ test.register_coroutine_test( test.socket.capability:__expect_send( mock_device:generate_test_message("main", capabilities.dustSensor.dustLevel({value = 18, unit = "μg/m^3"})) ) + test.socket.matter:__queue_receive({ + mock_device.id, + clusters.TotalVolatileOrganicCompoundsConcentrationMeasurement.attributes.MeasurementUnit:build_test_report_data( + mock_device, 1, clusters.TotalVolatileOrganicCompoundsConcentrationMeasurement.types.MeasurementUnitEnum.PPM + ) + }) + test.socket.matter:__queue_receive({ + mock_device.id, + clusters.TotalVolatileOrganicCompoundsConcentrationMeasurement.attributes.MeasuredValue:build_test_report_data( + mock_device, 1, SinglePrecisionFloat(0, -1, .5) -- 0.750 ppm + ) + }) + test.socket.capability:__expect_send( + mock_device:generate_test_message("main", capabilities.tvocMeasurement.tvocLevel({value = 750, unit = "ppb"})) + ) end ) diff --git a/drivers/SmartThings/matter-thermostat/src/init.lua b/drivers/SmartThings/matter-thermostat/src/init.lua index 20b6f2d64d..7799091b24 100644 --- a/drivers/SmartThings/matter-thermostat/src/init.lua +++ b/drivers/SmartThings/matter-thermostat/src/init.lua @@ -590,7 +590,7 @@ local unit_default = { [capabilities.fineDustSensor.NAME] = units.UGM3, [capabilities.dustSensor.NAME] = units.UGM3, [capabilities.radonMeasurement.NAME] = units.BQM3, - [capabilities.tvocMeasurement.NAME] = units.PPM + [capabilities.tvocMeasurement.NAME] = units.PPB -- TVOC is typically within the range of 0-5500 ppb, with good to moderate values being < 660 ppb } -- All ConcentrationMesurement clusters inherit from the same base cluster definitions, @@ -620,11 +620,13 @@ local molecular_weights = { local conversion_tables = { [units.PPM] = { [units.PPM] = function(value) return utils.round(value) end, + [units.PPB] = function(value) return utils.round(value * (10^3)) end, [units.UGM3] = function(value, molecular_weight) return utils.round((value * molecular_weight * 10^3) / MGM3_PPM_CONVERSION_FACTOR) end, [units.MGM3] = function(value, molecular_weight) return utils.round((value * molecular_weight) / MGM3_PPM_CONVERSION_FACTOR) end, }, [units.PPB] = { - [units.PPM] = function(value) return utils.round(value/(10^3)) end + [units.PPM] = function(value) return utils.round(value/(10^3)) end, + [units.PPB] = function(value) return utils.round(value) end, }, [units.PPT] = { [units.PPM] = function(value) return utils.round(value/(10^6)) end @@ -1429,7 +1431,7 @@ local matter_driver_template = { [clusters.RadonConcentrationMeasurement.attributes.LevelValue.ID] = levelHandlerFactory(capabilities.radonHealthConcern.radonHealthConcern) }, [clusters.TotalVolatileOrganicCompoundsConcentrationMeasurement.ID] = { - [clusters.TotalVolatileOrganicCompoundsConcentrationMeasurement.attributes.MeasuredValue.ID] = measurementHandlerFactory(capabilities.tvocMeasurement.NAME, capabilities.tvocMeasurement.tvocLevel, units.PPM), + [clusters.TotalVolatileOrganicCompoundsConcentrationMeasurement.attributes.MeasuredValue.ID] = measurementHandlerFactory(capabilities.tvocMeasurement.NAME, capabilities.tvocMeasurement.tvocLevel, units.PPB), [clusters.TotalVolatileOrganicCompoundsConcentrationMeasurement.attributes.MeasurementUnit.ID] = store_unit_factory(capabilities.tvocMeasurement.NAME), [clusters.TotalVolatileOrganicCompoundsConcentrationMeasurement.attributes.LevelValue.ID] = levelHandlerFactory(capabilities.tvocHealthConcern.tvocHealthConcern) }