Skip to content

Commit

Permalink
Add pm25/air quality support to IKEA STARKVIND E2007 (#3338)
Browse files Browse the repository at this point in the history
* Add STARKVIND pm25 converters

* Update STARKVIND device to add new convertors

Unfortunately it looks like we can't configure reporting for this attribute.
The value is not update when the device is not running. The user can manualy poll the value.

* Add options to for ikea_pm25 fromZigbee converter
  • Loading branch information
sjorge authored Nov 12, 2021
1 parent 3ff29cb commit 1ad7e28
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
27 changes: 27 additions & 0 deletions converters/fromZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -4295,6 +4295,33 @@ const converters = {
}
},
},
ikea_pm25: {
cluster: 'manuSpecificIkeaPM25Measurement',
type: ['attributeReport', 'readResponse'],
options: [exposes.options.precision('pm25'), exposes.options.calibration('pm25')],
convert: (model, msg, publish, options, meta) => {
if (msg.data['measuredValue']) {
const pm25 = parseFloat(msg.data['measuredValue']) / 100.0;
const pm25Property = postfixWithEndpointName('pm25', msg, model);

// Air Quality Scale (ikea app):
// 0-35=Good, 35-80=OK, 80+=Not Good
let airQuality;
const airQualityProperty = postfixWithEndpointName('air_quality', msg, model);
if (pm25 <= 35) {
airQuality = 'good';
} else if (pm25 <= 80) {
airQuality = 'ok';
} else if (pm25 < 65535) {
airQuality = 'not_good';
} else {
airQuality = 'unknown';
}

return {[pm25Property]: calibrateAndPrecisionRoundOptions(pm25, options, 'pm25'), [airQualityProperty]: airQuality};
}
},
},
E1524_E1810_levelctrl: {
cluster: 'genLevelCtrl',
type: [
Expand Down
6 changes: 6 additions & 0 deletions converters/toZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,12 @@ const converters = {
await entity.read('genBasic', [0x0033], manufacturerOptions.hue);
},
},
ikea_pm25: {
key: ['pm25', 'air_quality'],
convertGet: async (entity, key, meta) => {
await entity.read('manuSpecificIkeaPM25Measurement', ['measuredValue']);
},
},
RTCGQ13LM_motion_sensitivity: {
key: ['motion_sensitivity'],
convertSet: async (entity, key, value, meta) => {
Expand Down
12 changes: 9 additions & 3 deletions devices/ikea.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,16 @@ module.exports = [
model: 'E2007',
vendor: 'IKEA',
description: 'STARKVIND air purifier',
exposes: [e.fan().withModes(['off', 'low', 'medium', 'high', 'auto'])],
exposes: [
e.fan().withModes(['off', 'low', 'medium', 'high', 'auto']),
e.pm25().withAccess(ea.STATE_GET),
exposes.enum('air_quality', ea.STATE_GET, [
'good', 'ok', 'not_good', 'unknown',
]).withDescription('Measured air quality'),
],
meta: {fanStateOn: 'auto'},
fromZigbee: [fz.fan],
toZigbee: [tz.fan_mode],
fromZigbee: [fz.fan, fz.ikea_pm25],
toZigbee: [tz.fan_mode, tz.ikea_pm25],
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ['hvacFanCtrl']);
Expand Down

0 comments on commit 1ad7e28

Please sign in to comment.