Skip to content

Commit

Permalink
Remove percent_control from curtain
Browse files Browse the repository at this point in the history
  • Loading branch information
JELoohuis committed Sep 11, 2024
1 parent 25a0a02 commit d3ec497
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 35 deletions.
12 changes: 0 additions & 12 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2324,18 +2324,6 @@
"en": "CAUTION: Some settings are not supported by every device."
},
"children": [
{
"id": "percent_control",
"type": "number",
"label": {
"en": "Motor torque"
},
"value": 0,
"min": 0,
"max": 100,
"step": 1,
"units": "%"
},
{
"id": "inverse",
"type": "checkbox",
Expand Down
3 changes: 0 additions & 3 deletions drivers/curtain/TuyaCurtainConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@ export const CURTAIN_CAPABILITIES = {

export type HomeyCurtainSettings = {
inverse: boolean;
percent_control: number;
};

export type TuyaCurtainSettings = {
percent_control: number;
opposite: boolean; // inverse
control_back: boolean; // inverse
control_back_mode: 'forward' | 'back'; // inverse
};

export const CURTAIN_SETTING_LABELS = {
percent_control: 'Motor torque',
opposite: 'Inverse direction',
control_back: 'Inverse direction',
control_back_mode: 'Inverse direction',
Expand Down
14 changes: 6 additions & 8 deletions drivers/curtain/device.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import TuyaOAuth2Device from '../../lib/TuyaOAuth2Device';
import { filterTuyaSettings, getFromMap } from '../../lib/TuyaOAuth2Util';
import { getFromMap } from '../../lib/TuyaOAuth2Util';
import * as TuyaOAuth2Util from '../../lib/TuyaOAuth2Util';
import { SettingsEvent, TuyaStatus } from '../../types/TuyaTypes';
import {
Expand Down Expand Up @@ -67,10 +67,6 @@ module.exports = class TuyaOAuth2DeviceCurtain extends TuyaOAuth2Device {
await this.safeSetCapabilityValue(homeyCapability, (value as number) / 100);
}

if (tuyaCapability === 'percent_control') {
await this.setSettings({ [tuyaCapability]: value }).catch(this.error);
}

if (['opposite', 'control_back'].includes(tuyaCapability)) {
await this.setSettings({ inverse: value }).catch(this.error);
}
Expand All @@ -82,9 +78,11 @@ module.exports = class TuyaOAuth2DeviceCurtain extends TuyaOAuth2Device {
}

async onSettings(event: SettingsEvent<HomeyCurtainSettings>): Promise<string | void> {
const tuyaSettings = filterTuyaSettings(event, [
'percent_control',
]) as unknown as SettingsEvent<TuyaCurtainSettings>;
const tuyaSettings: SettingsEvent<Partial<TuyaCurtainSettings>> = {
newSettings: {},
oldSettings: {},
changedKeys: [],
};

if (event.changedKeys.includes('inverse')) {
if (this.hasTuyaCapability('control_back')) {
Expand Down
12 changes: 0 additions & 12 deletions drivers/curtain/driver.settings.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@
"en": "CAUTION: Some settings are not supported by every device."
},
"children": [
{
"id": "percent_control",
"type": "number",
"label": {
"en": "Motor torque"
},
"value": 0,
"min": 0,
"max": 100,
"step": 1,
"units": "%"
},
{
"id": "inverse",
"type": "checkbox",
Expand Down

0 comments on commit d3ec497

Please sign in to comment.