diff --git a/webapp/src/components/ConditionEditor/editorRender.tsx b/webapp/src/components/ConditionEditor/editorRender.tsx index ed5ecd7..ff0ac38 100644 --- a/webapp/src/components/ConditionEditor/editorRender.tsx +++ b/webapp/src/components/ConditionEditor/editorRender.tsx @@ -313,12 +313,12 @@ export const ZoneEditor: Editor = ({ onChange, condition }) => { <> onChange({ ...condition, - zone: zone ?? "", + zone: zone ?? [], }) } restrictToDomain={["zone"]} @@ -335,16 +335,6 @@ export const ZoneEditor: Editor = ({ onChange, condition }) => { } restrictToDomain={["person", "device_tracker"]} /> - - onChange({ - ...condition, - state, - }) - } - /> ); }; diff --git a/webapp/src/types/validators/conditions.ts b/webapp/src/types/validators/conditions.ts index 6c3dd09..6606dc9 100644 --- a/webapp/src/types/validators/conditions.ts +++ b/webapp/src/types/validators/conditions.ts @@ -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()]), }) ); diff --git a/webapp/src/utils/formatting.tsx b/webapp/src/utils/formatting.tsx index 1525466..466e1f0 100644 --- a/webapp/src/utils/formatting.tsx +++ b/webapp/src/utils/formatting.tsx @@ -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); }