From 301aa34084ac39a46514b358bed94a1f78d5aa53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Meireles?= Date: Fri, 21 Jan 2022 23:10:52 +0000 Subject: [PATCH] handle properly older sets power status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - while digging #90 and with the awesome help from @tjm7844 who provided live access to an affected set it was found that on some older sets the TV was returning X_ScreenState with a state ('none') when online not yet accounted by the plugin. this is now fixed and those TVs are now propperly recognized as ON when they actually are on. Signed-off-by: António Meireles --- src/viera.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/viera.ts b/src/viera.ts index 5628caa..570d3cf 100644 --- a/src/viera.ts +++ b/src/viera.ts @@ -177,8 +177,10 @@ class VieraTV implements VieraTV { if (properties.X_ScreenState) { resolve(properties.X_ScreenState === 'on') } else if (Array.isArray(properties)) { - const match = properties.find((prop) => ['on', 'off'].includes(prop.X_ScreenState)) - match ? resolve(match.X_ScreenState === 'on') : resolve(false) + const match = properties.find((prop) => + ['on', 'off', 'none'].includes(prop.X_ScreenState) + ) + match ? resolve(match.X_ScreenState !== 'off') : resolve(false) } else resolve(false) }) .on('error', () => resolve(false))