fix: Assume conditions are state conditions unless otherwise specified (#1552)

This commit is contained in:
Dermot Duffy
2024-09-21 13:41:13 -07:00
committed by GitHub
parent 15d33f63fb
commit e5cbfa9976
3 changed files with 66 additions and 26 deletions
+4 -1
View File
@@ -518,7 +518,10 @@ const imageSchema = elementsBaseSchema.extend({
// https://www.home-assistant.io/dashboards/conditional/#state
const stateConditionSchema = z.object({
condition: z.literal('state'),
// If the condition is not specified, a state condition is assumed. This
// allows the syntax to match a picture elements conditional:
// https://www.home-assistant.io/dashboards/picture-elements/#conditional-element
condition: z.literal('state').optional(),
entity: z.string(),
state: z.string().or(z.string().array()).optional(),
state_not: z.string().or(z.string().array()).optional(),