Skip to content

Commit d48ac2e

Browse files
KorriKoenkk
andauthored
fix: Invert direction for Smartwings shades (#8681)
Co-authored-by: Koen Kanters <[email protected]>
1 parent d8ade3e commit d48ac2e

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/devices/smartwings.ts

+15-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,20 @@ import fz from '../converters/fromZigbee';
22
import tz from '../converters/toZigbee';
33
import * as exposes from '../lib/exposes';
44
import * as reporting from '../lib/reporting';
5-
import {DefinitionWithExtend} from '../lib/types';
5+
import {DefinitionWithExtend, Tz, Zh} from '../lib/types';
6+
import {assertString, getFromLookup, getOptions} from '../lib/utils';
7+
8+
const tzLocal = {
9+
backwards_cover_state: {
10+
key: ['state'],
11+
convertSet: async (entity: Zh.Endpoint, key: string, value: number | string, meta: Tz.Meta) => {
12+
const lookup = {open: 'downClose', close: 'upOpen', stop: 'stop', on: 'downClose', off: 'upOpen'};
13+
assertString(value, key);
14+
value = value.toLowerCase();
15+
await entity.command('closuresWindowCovering', getFromLookup(value, lookup), {}, getOptions(meta.mapped, entity));
16+
},
17+
},
18+
};
619

720
const e = exposes.presets;
821

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

0 commit comments

Comments
 (0)