Skip to content

Commit 9a1a5a9

Browse files
committed
Invert direction for Smartwings shades
Inspired by ZHA's approach, and feedback form SmartWings support, I confirmed that this converter works and am now proposing that we merge it to the main codebase. For shades to work well, you still need to invert their Zigbee state (press Up & Down together for 5s, then Press the P button under the battery cover once).
1 parent 46d86e8 commit 9a1a5a9

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/devices/smartwings.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@ 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 backwards_cover_state = {
9+
key: ['state'],
10+
convertSet: async (entity: Zh.Endpoint, key: string, value: number | string, meta: Tz.Meta) => {
11+
const lookup = {open: 'downClose', close: 'upOpen', stop: 'stop', on: 'downClose', off: 'upOpen'};
12+
assertString(value, key);
13+
value = value.toLowerCase();
14+
await entity.command('closuresWindowCovering', getFromLookup(value, lookup), {}, getOptions(meta.mapped, entity));
15+
},
16+
};
617

718
const e = exposes.presets;
819

@@ -13,7 +24,7 @@ const definitions: DefinitionWithExtend[] = [
1324
vendor: 'Smartwings',
1425
description: 'Roller shade',
1526
fromZigbee: [fz.cover_position_tilt, fz.battery],
16-
toZigbee: [tz.cover_state, tz.cover_position_tilt],
27+
toZigbee: [backwards_cover_state, tz.cover_position_tilt],
1728
meta: {battery: {dontDividePercentage: true}, coverInverted: true},
1829
configure: async (device, coordinatorEndpoint) => {
1930
const endpoint = device.getEndpoint(1);

0 commit comments

Comments
 (0)