fixed zones

This commit is contained in:
ari committed 2022-07-19 20:59:11 -04:00
1 parent e7110dc97b
commit 649ee0f31e
3 files changed
+18 -15

No files matched your search

@@ -313,12 +313,12 @@ export const ZoneEditor: Editor<ZoneCondition> = ({ onChange, condition }) => {
<>
<InputEntity
label="Zone"
value={condition.zone}
multiple={false}
value={condition.zone ?? []}
multiple
onChange={(zone) =>
onChange({
...condition,
zone: zone ?? "",
zone: zone ?? [],
})
}
restrictToDomain={["zone"]}
@@ -335,16 +335,6 @@ export const ZoneEditor: Editor<ZoneCondition> = ({ onChange, condition }) => {
}
restrictToDomain={["person", "device_tracker"]}
/>
<InputText
label="State"
value={String(condition.state)}
onChange={(state) =>
onChange({
...condition,
state,
})
}
/>
</>
);
};
+1 -2
View File
@@ -71,8 +71,7 @@ export const ZoneCondition = st.assign(
AutomationConditionNodeBase,
st.type({
condition: st.literal("zone"),
zone: st.string(),
entity_id: EntityId,
state: st.union([st.array(st.string()), st.string()]),
zone: st.union([st.array(st.string()), st.string()]),
})
);
+14
View File
@@ -128,6 +128,20 @@ export const getDescriptionFromAutomationNode = <
? `on ${getDescriptionForWeekDay(node.weekday, "or")}`
: "";
return [before, after, weekday].filter((x) => x).join(", ");
case "zone":
let out = "if ";
if (Array.isArray(node.entity_id) && node.entity_id.length > 2) {
out += "multiple people";
} else {
out += namer.getEntityName(node.entity_id, 2);
}
out += " enter ";
if (Array.isArray(node.zone) && node.zone.length > 2) {
out += "multiple people";
} else {
out += namer.getEntityName(node.zone, 2);
}
return out;
default:
return JSON.stringify(node);
}