Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: STARKVIND child_lock was broken after refactor #7602

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/lib/ikea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Fz, Tz, OnEvent, Configure, KeyValue, Range, ModernExtend, Expose, KeyVa
import {presets, access, options} from '../lib/exposes';
import {
postfixWithEndpointName, precisionRound, isObject, replaceInArray, isLegacyEnabled, hasAlreadyProcessedMessage,
getFromLookup, mapNumberRange, getEndpointName,
assertString, getFromLookup, mapNumberRange, getEndpointName,
} from '../lib/utils';
import {
LightArgs, light as lightDontUse, ota, ReportingConfigWithoutAttribute,
Expand Down Expand Up @@ -184,7 +184,7 @@ export function ikeaAirPurifier(): ModernExtend {
'unknown',
]).withDescription('Calculated air quality'),
presets.binary('led_enable', access.ALL, true, false).withDescription('Controls the LED').withCategory('config'),
presets.binary('child_lock', access.ALL, true, false).withDescription('Controls physical input on the device').withCategory('config'),
presets.binary('child_lock', access.ALL, 'LOCK', 'UNLOCK').withDescription('Controls physical input on the device').withCategory('config'),
presets.binary('replace_filter', access.STATE_GET, true, false)
.withDescription('Indicates if the filter is older than 6 months and needs replacing')
.withCategory('diagnostic'),
Expand Down Expand Up @@ -242,7 +242,7 @@ export function ikeaAirPurifier(): ModernExtend {
}

if (msg.data.hasOwnProperty('childLock')) {
state['child_lock'] = (msg.data['childLock'] == 0);
state['child_lock'] = ((msg.data['childLock'] == 0) ? 'UNLOCK' : 'LOCK');
}

if (msg.data.hasOwnProperty('fanSpeed')) {
Expand Down Expand Up @@ -325,8 +325,9 @@ export function ikeaAirPurifier(): ModernExtend {
{
key: ['child_lock'],
convertSet: async (entity, key, value, meta) => {
await entity.write('manuSpecificIkeaAirPurifier', {'childLock': ((value) ? 0 : 1)}, manufacturerOptions);
return {state: {child_lock: ((value) ? true : false)}};
assertString(value);
await entity.write('manuSpecificIkeaAirPurifier', {'childLock': ((value.toLowerCase() === 'unlock') ? 0 : 1)}, manufacturerOptions);
return {state: {child_lock: ((value.toLowerCase() === 'lock') ? 'LOCK' : 'UNLOCK')}};
},
convertGet: async (entity, key, meta) => {
await entity.read('manuSpecificIkeaAirPurifier', ['childLock']);
Expand Down
Loading