Skip to content

Commit

Permalink
fix: Invert direction for Smartwings shades (#8681)
Browse files Browse the repository at this point in the history
Co-authored-by: Koen Kanters <[email protected]>
  • Loading branch information
Korri and Koenkk authored Jan 27, 2025
1 parent d8ade3e commit d48ac2e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/devices/smartwings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@ import fz from '../converters/fromZigbee';
import tz from '../converters/toZigbee';
import * as exposes from '../lib/exposes';
import * as reporting from '../lib/reporting';
import {DefinitionWithExtend} from '../lib/types';
import {DefinitionWithExtend, Tz, Zh} from '../lib/types';
import {assertString, getFromLookup, getOptions} from '../lib/utils';

const tzLocal = {
backwards_cover_state: {
key: ['state'],
convertSet: async (entity: Zh.Endpoint, key: string, value: number | string, meta: Tz.Meta) => {
const lookup = {open: 'downClose', close: 'upOpen', stop: 'stop', on: 'downClose', off: 'upOpen'};
assertString(value, key);
value = value.toLowerCase();
await entity.command('closuresWindowCovering', getFromLookup(value, lookup), {}, getOptions(meta.mapped, entity));
},
},
};

const e = exposes.presets;

Expand All @@ -13,7 +26,7 @@ const definitions: DefinitionWithExtend[] = [
vendor: 'Smartwings',
description: 'Roller shade',
fromZigbee: [fz.cover_position_tilt, fz.battery],
toZigbee: [tz.cover_state, tz.cover_position_tilt],
toZigbee: [tzLocal.backwards_cover_state, tz.cover_position_tilt],
meta: {battery: {dontDividePercentage: true}, coverInverted: true},
configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
Expand Down

0 comments on commit d48ac2e

Please sign in to comment.