Skip to content

Commit

Permalink
fix valve entities row (#19278)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored Jan 4, 2024
1 parent e5d31d8 commit ecadc06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/common/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ export const DOMAINS_INPUT_ROW = [
"text",
"time",
"vacuum",
"valve",
];

/** States that we consider "off". */
Expand Down
10 changes: 8 additions & 2 deletions src/data/valve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit ecadc06

Please sign in to comment.