#Custom automation condition dynamic naming.
1 messages · Page 1 of 1 (latest)
By custom condition, do you mean one of the new labs integration-specific conditions? Are you a developer?
I created two custom conditions to more easily check last_changed and last_triggered attributes so I don't have to use templates. I just read thru the code and implemented it, i couldn't find any documentation. I'm having a hard time trying to track down how the UI dynamically updates based on the configured details.
the strings are in the frontend
https://github.com/home-assistant/frontend/blob/7552e91f24564d4ab6d2ef09d8beaf2b2b5baef8/src/translations/en.json#L4912-L4927
I want to generate this
oh hmm
ok i completely mis-interpreted what that was doing then
i'll give it a shot
Yea i'm not having much luck
my en,json is
{
"config": { ... },
"options": { ... },
"conditions": {
"last_triggered": {
"name": "Clockwork Last Triggered",
"description": {
"picker": "Check how long it's been since an automation was last triggered",
"above": "If {attribute, select, \n undefined {} \n other {{attribute} from }\n }{entity} {numberOfEntities, plural,\n one {is}\n other {are}\n} above {above}",
"below": "If {attribute, select, \n undefined {} \n other {{attribute} from }\n }{entity} {numberOfEntities, plural,\n one {is}\n other {are}\n} below {below}",
"equal_to": "If {attribute, select, \n undefined {} \n other {{attribute} from }\n }{entity} {numberOfEntities, plural,\n one {is}\n other {are}\n} equal to {equal_to}"
},
"fields": {
"entity_id": {
"name": "Automation Entity",
"description": "The automation entity to monitor for last trigger time"
},
"above": {
"name": "Above (seconds)",
"description": "Return true if time since last trigger is greater than this value"
},
"below": {
"name": "Below (seconds)",
"description": "Return true if time since last trigger is less than this value"
},
"equal_to": {
"name": "Equal to (seconds)",
"description": "Return true if time since last trigger equals this value"
}
}
}
}
}
So can you start from the beginning and explain what your goal is here?
Users typically don't implement custom conditions.
Are you going to PR this into core?
Is this a custom component?
yes it's a custom component
I don't plan to PR into core unless i get feedback others want it
for now i just want to make it behave similar to core functions in any way i can and this is the last little bit of functionality
I think the numeric state example might have led you in the wrong direction. Numeric state isn't tied to an integration, it's just a generic condition, for which descriptions are hardcoded in the frotnend.
Integration specific conditions have their descriptions in strings.json in core, the global conditions have their strings hardcoded where I showed in the frontend.
Like is this condition one you've added to conditions.yaml in your integration?
I would have to poke around to see if any placeholders are supported in those name strings.
Not sure if I've seen that used yet in the core conditions.
Hmm I wonder if this got removed.
https://github.com/home-assistant/core/pull/157620
ok, so the way they're implemented in the core en.json doesn't follow the same path as my component code? I couldn't figure out how the description keys were even accessed by the ui to display in that summary view
Yeah I think it's just not possible for you to customize it.