From ecadc06b452c180d97c8fa9d8f776fb3a690712f Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 4 Jan 2024 11:52:38 +0100 Subject: [PATCH] fix valve entities row (#19278) --- src/common/const.ts | 1 + src/data/valve.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/common/const.ts b/src/common/const.ts index bc114f2f1703..2e7d2f7c77d7 100644 --- a/src/common/const.ts +++ b/src/common/const.ts @@ -254,6 +254,7 @@ export const DOMAINS_INPUT_ROW = [ "text", "time", "vacuum", + "valve", ]; /** States that we consider "off". */ diff --git a/src/data/valve.ts b/src/data/valve.ts index 73f5d428ae18..645ca82e4954 100644 --- a/src/data/valve.ts +++ b/src/data/valve.ts @@ -14,14 +14,20 @@ export const enum ValveEntityFeature { } export function isFullyOpen(stateObj: ValveEntity) { - if (stateObj.attributes.current_position !== undefined) { + if ( + stateObj.attributes.current_position !== undefined && + stateObj.attributes.current_position !== null + ) { return stateObj.attributes.current_position === 100; } return stateObj.state === "open"; } export function isFullyClosed(stateObj: ValveEntity) { - if (stateObj.attributes.current_position !== undefined) { + if ( + stateObj.attributes.current_position !== undefined && + stateObj.attributes.current_position !== null + ) { return stateObj.attributes.current_position === 0; } return stateObj.state === "closed";