Compare commits

...

2 Commits

Author SHA1 Message Date
Bram Kragten
4740e60d07 fix valve 2024-01-04 10:15:21 +01:00
Bram Kragten
2ac4899a86 Fix turning valve on/off 2024-01-03 21:05:16 +01:00
3 changed files with 13 additions and 2 deletions

View File

@@ -254,6 +254,7 @@ export const DOMAINS_INPUT_ROW = [
"text",
"time",
"vacuum",
"valve",
];
/** States that we consider "off". */
@@ -272,6 +273,7 @@ export const DOMAINS_TOGGLE = new Set([
"group",
"automation",
"humidifier",
"valve",
]);
/** Domains that have a dynamic entity image / picture. */

View File

@@ -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";

View File

@@ -24,6 +24,9 @@ export const turnOnOffEntity = (
case "scene":
service = "turn_on";
break;
case "valve":
service = turnOn ? "open_valve" : "close_valve";
break;
default:
service = turnOn ? "turn_on" : "turn_off";
}