From bf6f551cd5fb9da60a2f6dcedee20b4835512394 Mon Sep 17 00:00:00 2001 From: monkeycat Date: Sat, 30 Sep 2023 09:08:43 +0300 Subject: [PATCH] Use overrides for ValveAccessory (#376) * Use overrides for ValveAccessory * Fix code style --- 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..57132be1 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);