Savjee/button-text-card

Handling of undefined entities

Closed this issue · 1 comments

There was a issue/ thread about depressed state earlier in the issues. In general pressed/depressed buttons works nicely inside lovelace vertical stack card, you just define 2 buttons of same size with different colors/ texts and use the visibilty controlling entity in opposite states, the other button is activated whille off and the other while on. Lovelace will draw the button on exactly the same location, because only one can be active at the time.

It works OK with sensors etc. However, I am using a persistent notification to control button visibilty. The problem with persistent notifications is that they exist only when they are active; when deactivated the ebtity does not have any state, because it does not exist. Thus, I cannot use it to control the button visibility in depressed state.

I do not know javascript well (button-text-card does not use jinja, but javascript in templating), so is there a nice way the check inside button-text-card, that does the entity exist and how could i use that to control the visibility?

(Although this question is handling the button depressed state, technically this is a separate issue, so I made a new thread for this)

Something like this will hide the card when an entity is not available:

hide_condition: |
   [[[
       return states["YOUR_ENTITY_NAME"] === undefined;
   ]]]

Closing the issue, but feel free to report back ;)