Skip to content

Commit

Permalink
Zigbee2mqtt: check illuminance feature (#1983)
Browse files Browse the repository at this point in the history
  • Loading branch information
atrovato authored Dec 18, 2023
1 parent e2888c5 commit 5d2ae1f
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 2 deletions.
1 change: 0 additions & 1 deletion server/services/zigbee2mqtt/exposes/numericType.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ module.exports = {
feature: {
category: DEVICE_FEATURE_CATEGORIES.LIGHT_SENSOR,
type: DEVICE_FEATURE_TYPES.SENSOR.DECIMAL,
unit: DEVICE_FEATURE_UNITS.LUX,
min: 0,
max: 100000,
},
Expand Down
269 changes: 269 additions & 0 deletions server/test/services/zigbee2mqtt/utils/payloads/ZSS-ZK-THL.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
{
"name": "ZSS-ZK-THL",
"mqttDevice": {
"date_code": "",
"definition": {
"description": "Smart temperature and humidity meter with display",
"exposes": [
{
"access": 1,
"description": "Remaining battery in %, can take up to 24 hours before reported.",
"label": "Battery",
"name": "battery",
"property": "battery",
"type": "numeric",
"unit": "%",
"value_max": 100,
"value_min": 0
},
{
"access": 1,
"description": "Raw measured illuminance",
"label": "Illuminance",
"name": "illuminance",
"property": "illuminance",
"type": "numeric"
},
{
"access": 1,
"description": "Measured illuminance in lux",
"label": "Illuminance (lux)",
"name": "illuminance_lux",
"property": "illuminance_lux",
"type": "numeric",
"unit": "lx"
},
{
"access": 1,
"description": "Measured relative humidity",
"label": "Humidity",
"name": "humidity",
"property": "humidity",
"type": "numeric",
"unit": "%"
},
{
"access": 1,
"description": "Measured temperature value",
"label": "Temperature",
"name": "temperature",
"property": "temperature",
"type": "numeric",
"unit": "°C"
},
{
"access": 1,
"description": "Link quality (signal strength)",
"label": "Linkquality",
"name": "linkquality",
"property": "linkquality",
"type": "numeric",
"unit": "lqi",
"value_max": 255,
"value_min": 0
}
],
"model": "ZSS-ZK-THL",
"options": [
{
"access": 2,
"description": "Calibrates the illuminance value (percentual offset), takes into effect on next report of device.",
"label": "Illuminance calibration",
"name": "illuminance_calibration",
"property": "illuminance_calibration",
"type": "numeric"
},
{
"access": 2,
"description": "Calibrates the illuminance_lux value (percentual offset), takes into effect on next report of device.",
"label": "Illuminance lux calibration",
"name": "illuminance_lux_calibration",
"property": "illuminance_lux_calibration",
"type": "numeric"
},
{
"access": 2,
"description": "Number of digits after decimal point for humidity, takes into effect on next report of device.",
"label": "Humidity precision",
"name": "humidity_precision",
"property": "humidity_precision",
"type": "numeric",
"value_max": 3,
"value_min": 0
},
{
"access": 2,
"description": "Calibrates the humidity value (absolute offset), takes into effect on next report of device.",
"label": "Humidity calibration",
"name": "humidity_calibration",
"property": "humidity_calibration",
"type": "numeric"
},
{
"access": 2,
"description": "Number of digits after decimal point for temperature, takes into effect on next report of device.",
"label": "Temperature precision",
"name": "temperature_precision",
"property": "temperature_precision",
"type": "numeric",
"value_max": 3,
"value_min": 0
},
{
"access": 2,
"description": "Calibrates the temperature value (absolute offset), takes into effect on next report of device.",
"label": "Temperature calibration",
"name": "temperature_calibration",
"property": "temperature_calibration",
"type": "numeric"
}
],
"supports_ota": false,
"vendor": "Moes"
},
"disabled": false,
"endpoints": {
"1": {
"bindings": [],
"clusters": {
"input": ["genBasic", "genPowerCfg", "msIlluminanceMeasurement"],
"output": ["genOta", "genTime"]
},
"configured_reportings": [],
"scenes": []
},
"2": {
"bindings": [],
"clusters": {
"input": ["msTemperatureMeasurement", "msRelativeHumidity"],
"output": []
},
"configured_reportings": [],
"scenes": []
}
},
"friendly_name": "0xe0798dfffedeae2b",
"ieee_address": "0xe0798dfffedeae2b",
"interview_completed": true,
"interviewing": false,
"manufacturer": "_TYZB01_ftdkanlj",
"model_id": "TS0222",
"network_address": 32231,
"power_source": "Battery",
"supported": true,
"type": "EndDevice"
},
"gladysDevice": {
"name": "0xe0798dfffedeae2b",
"model": "ZSS-ZK-THL",
"external_id": "zigbee2mqtt:0xe0798dfffedeae2b",
"features": [
{
"name": "Battery",
"read_only": true,
"has_feedback": false,
"min": 0,
"max": 100,
"category": "battery",
"type": "integer",
"unit": "percent",
"external_id": "zigbee2mqtt:0xe0798dfffedeae2b:battery:integer:battery",
"selector": "zigbee2mqtt-0xe0798dfffedeae2b-battery-integer-battery"
},
{
"name": "Illuminance",
"read_only": true,
"has_feedback": false,
"min": 0,
"max": 100000,
"category": "light-sensor",
"type": "decimal",
"unit": null,
"external_id": "zigbee2mqtt:0xe0798dfffedeae2b:light-sensor:decimal:illuminance",
"selector": "zigbee2mqtt-0xe0798dfffedeae2b-light-sensor-decimal-illuminance"
},
{
"name": "Illuminance lux",
"read_only": true,
"has_feedback": false,
"min": 0,
"max": 100000,
"category": "light-sensor",
"type": "decimal",
"unit": "lux",
"external_id": "zigbee2mqtt:0xe0798dfffedeae2b:light-sensor:decimal:illuminance_lux",
"selector": "zigbee2mqtt-0xe0798dfffedeae2b-light-sensor-decimal-illuminance-lux"
},
{
"name": "Humidity",
"read_only": true,
"has_feedback": false,
"min": 0,
"max": 100,
"category": "humidity-sensor",
"type": "decimal",
"unit": "percent",
"external_id": "zigbee2mqtt:0xe0798dfffedeae2b:humidity-sensor:decimal:humidity",
"selector": "zigbee2mqtt-0xe0798dfffedeae2b-humidity-sensor-decimal-humidity"
},
{
"name": "Temperature",
"read_only": true,
"has_feedback": false,
"min": -100,
"max": 150,
"category": "temperature-sensor",
"type": "decimal",
"unit": "celsius",
"external_id": "zigbee2mqtt:0xe0798dfffedeae2b:temperature-sensor:decimal:temperature",
"selector": "zigbee2mqtt-0xe0798dfffedeae2b-temperature-sensor-decimal-temperature"
},
{
"name": "Linkquality",
"read_only": true,
"has_feedback": false,
"min": 0,
"max": 5,
"category": "signal",
"type": "integer",
"unit": null,
"external_id": "zigbee2mqtt:0xe0798dfffedeae2b:signal:integer:linkquality",
"selector": "zigbee2mqtt-0xe0798dfffedeae2b-signal-integer-linkquality"
}
],
"should_poll": false,
"service_id": "a4c859f0-32d2-46b7-8f5a-3285960f498a"
},
"values": [
{
"internal": 97,
"external": 97,
"property": "battery"
},
{
"internal": 45622.1,
"external": 45622.1,
"property": "illuminance"
},
{
"internal": 456.6,
"external": 456.6,
"property": "illuminance_lux"
},
{
"internal": 56.6,
"external": 56.6,
"property": "humidity"
},
{
"internal": 45.1,
"external": 45.1,
"property": "temperature"
},
{
"internal": 2,
"external": 102,
"property": "linkquality"
}
]
}
3 changes: 2 additions & 1 deletion server/test/services/zigbee2mqtt/utils/payloads/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const CCT5015 = require('./CCT5015.json');
const ZSSZKTHL = require('./ZSS-ZK-THL.json');

module.exports = [CCT5015];
module.exports = [CCT5015, ZSSZKTHL];
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const Zigbee2mqttManager = require('../../../../services/zigbee2mqtt/lib');

const { convertDevice } = require('../../../../services/zigbee2mqtt/utils/convertDevice');
const payloads = require('./payloads');
const logger = require('../../../../utils/logger');

const gladys = {
job: {
Expand All @@ -29,8 +30,14 @@ describe('Decoding real devices', () => {

it(`[${name}] check Gladys device`, async () => {
const device = await convertDevice(mqttDevice, serviceId);
logger.debug('%j', device);

expect(device).to.deep.eq(gladysDevice);

// Extract features and check all selectors are unique
const featureSelectors = device.features.map((feature) => feature.selector);
const uniqueSelectors = Array.from(new Set(featureSelectors));
expect(featureSelectors).deep.eq(uniqueSelectors);
});

values.forEach(({ internal, external, property }) => {
Expand Down

0 comments on commit 5d2ae1f

Please sign in to comment.