From 0af4d45eb96474dc6df8435443c51ae41fcd7a52 Mon Sep 17 00:00:00 2001 From: nVuln Date: Wed, 24 Jul 2024 20:42:59 +0700 Subject: [PATCH] fix: fridge water filter --- src/devices/Refrigerator.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/devices/Refrigerator.ts b/src/devices/Refrigerator.ts index 5e19b24..a36bd9a 100644 --- a/src/devices/Refrigerator.ts +++ b/src/devices/Refrigerator.ts @@ -364,6 +364,19 @@ export class RefrigeratorStatus { } public get waterFilterRemain() { + if ('waterFilter1RemainP' in this.data) { + return this.data?.waterFilter1RemainP || 0; + } + + if ('waterFilter' in this.data) { + const usedInMonth = parseInt(this.data?.waterFilter.match(/(\d)_/)[1]); + if (isNaN(usedInMonth)) { + return 0; + } + + return (12 - usedInMonth) / 12 * 100; + } + return this.data?.waterFilter1RemainP || 0; }