#Custom automation condition dynamic naming.

1 messages · Page 1 of 1 (latest)

copper berry
#

I created a custom condition for automations but I can't figure out how to dynamically change what the UI shows. Similar to how numeric_state will show "If Main-Drive Cat count is above 12" instead of just "Numeric State". Thinking this isn't possible maybe?

weary dirge
#

By custom condition, do you mean one of the new labs integration-specific conditions? Are you a developer?

copper berry
#

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.

copper berry
#

I want to generate this

#

oh hmm

#

ok i completely mis-interpreted what that was doing then

#

i'll give it a shot

copper berry
#

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"
        }
      }
    }
  }
}
weary dirge
#

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?

copper berry
#

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

weary dirge
#

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?

weary dirge
#

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.

copper berry
#

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

weary dirge
#

Yeah I think it's just not possible for you to customize it.