From e0813d87313addc02db50f98f8ccc616a7e9d82b Mon Sep 17 00:00:00 2001 From: Ruslan Bakirov Date: Tue, 19 Sep 2023 01:00:22 +0300 Subject: [PATCH 1/2] Use overrides for ValveAccessory --- src/accessory/ValveAccessory.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/accessory/ValveAccessory.ts b/src/accessory/ValveAccessory.ts index 50d79e37..2352958a 100644 --- a/src/accessory/ValveAccessory.ts +++ b/src/accessory/ValveAccessory.ts @@ -20,7 +20,9 @@ export default class ValveAccessory extends BaseAccessory { this.accessory.removeService(oldService); } - const schema = this.device.schema.filter((schema) => schema.code.startsWith('switch') && schema.type === TuyaDeviceSchemaType.Boolean); + const schema = SCHEMA_CODE.ON.map(code => this.getSchema(code)) + .filter((s: TuyaDeviceSchema | undefined): s is TuyaDeviceSchema => !!s && s.type === TuyaDeviceSchemaType.Boolean); + for (const _schema of schema) { const name = (schema.length === 1) ? this.device.name : _schema.code; this.configureValve(_schema, name); From 845649a834e2ddfc9b36ce870dabe2dd6d46eeab Mon Sep 17 00:00:00 2001 From: Ruslan Bakirov Date: Tue, 19 Sep 2023 01:04:21 +0300 Subject: [PATCH 2/2] Fix code style --- src/accessory/ValveAccessory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/accessory/ValveAccessory.ts b/src/accessory/ValveAccessory.ts index 2352958a..57132be1 100644 --- a/src/accessory/ValveAccessory.ts +++ b/src/accessory/ValveAccessory.ts @@ -21,7 +21,7 @@ export default class ValveAccessory extends BaseAccessory { } const schema = SCHEMA_CODE.ON.map(code => this.getSchema(code)) - .filter((s: TuyaDeviceSchema | undefined): s is TuyaDeviceSchema => !!s && s.type === TuyaDeviceSchemaType.Boolean); + .filter((s: TuyaDeviceSchema | undefined): s is TuyaDeviceSchema => !!s && s.type === TuyaDeviceSchemaType.Boolean); for (const _schema of schema) { const name = (schema.length === 1) ? this.device.name : _schema.code;