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

Invert direction for Smartwings shades #8681

Merged
merged 2 commits into from
Jan 27, 2025
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
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},
Copy link

@brettmiller brettmiller Feb 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this update depending on if the shade has the motor direction reversed or not the shade either has the state and open/close percentage reversed or the buttons are reversed (close opens the shade, open closes the shade). With the other inversions done in this change should coverInverted also be inverted from true to false to correct the state?

I opened and issue for this here(before finding this PR): Koenkk/zigbee2mqtt#26133

configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
Expand Down
Loading