Skip to content

Commit

Permalink
IKEA STARKVIND should honer FanModeSequence (#3277)
Browse files Browse the repository at this point in the history
* Update fan_mode range based on FanModeSequence for IKEA STARKVIND

I noticed that FanModeSequence returns 0x02 for the STARKVIND, according to ZCL:
0x02 Low/Med/High/Auto

* Introduce `fanStateOn` meta for when hvacFanCtrl does not support a mode of "on"
  • Loading branch information
sjorge authored Nov 4, 2021
1 parent ef75453 commit 67d503a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ If any of those commands finish with an error your PR won't pass the tests and w
- `battery`:
- `{dontDividePercentage: true}`: prevents batteryPercentageRemainig from being divided (ZCL 200=100%, but some report 100=100%) (default: false)
- `{voltageToPercentage: '3V_2100'}`: convert voltage to percentage using specified option. See utils.batteryVoltageToPercentage() (default: null, no voltage to percentage conversion)
- `fanStateOn`: value used for fan_mode when using fan_state="ON", the default is "on"
3 changes: 3 additions & 0 deletions converters/toZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,9 @@ const converters = {
fan_mode: {
key: ['fan_mode', 'fan_state'],
convertSet: async (entity, key, value, meta) => {
if (key == 'fan_state' && value.toLowerCase() == 'on') {
value = utils.getMetaValue(entity, meta.mapped, 'fanStateOn', 'allEqual', 'on');
}
const fanMode = constants.fanMode[value.toLowerCase()];
await entity.write('hvacFanCtrl', {fanMode});
return {state: {fan_mode: value.toLowerCase(), fan_state: value.toLowerCase() === 'off' ? 'OFF' : 'ON'}};
Expand Down
3 changes: 2 additions & 1 deletion devices/ikea.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,8 @@ module.exports = [
model: 'E2007',
vendor: 'IKEA',
description: 'STARKVIND air purifier',
exposes: [e.fan().withModes(['off', 'low', 'medium', 'high', 'on', 'auto'])],
exposes: [e.fan().withModes(['off', 'low', 'medium', 'high', 'auto'])],
meta: {fanStateOn: 'auto'},
fromZigbee: [fz.fan],
toZigbee: [tz.fan_mode],
configure: async (device, coordinatorEndpoint, logger) => {
Expand Down
2 changes: 1 addition & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ describe('index.js', () => {
}

if (device.meta) {
containsOnly(['disableActionGroup', 'multiEndpoint', 'applyRedFix', 'disableDefaultResponse', 'enhancedHue', 'timeout', 'supportsHueAndSaturation', 'battery', 'coverInverted', 'turnsOffAtBrightness1', 'pinCodeCount', 'tuyaThermostatSystemMode', 'tuyaThermostatPreset', 'tuyaThermostatPresetToSystemMode', 'thermostat'], Object.keys(device.meta));
containsOnly(['disableActionGroup', 'multiEndpoint', 'applyRedFix', 'disableDefaultResponse', 'enhancedHue', 'timeout', 'supportsHueAndSaturation', 'battery', 'coverInverted', 'turnsOffAtBrightness1', 'pinCodeCount', 'tuyaThermostatSystemMode', 'tuyaThermostatPreset', 'tuyaThermostatPresetToSystemMode', 'thermostat', 'fanStateOn'], Object.keys(device.meta));
}

if (device.zigbeeModel) {
Expand Down

0 comments on commit 67d503a

Please sign in to comment.