Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary sensor alert card state #980

Conversation

csuich2
Copy link
Contributor

@csuich2 csuich2 commented Sep 7, 2022

This introduces a variable that specifies which state icon_alert and icon_info_alert should alert on. This is useful when you want to alert on a state other than "on". For example, I use this to alert when my automation is "off".

Need to setup a test environment, but this is a handy change that I've had in a local custom card. I figured it made more sense to put into the base cards than a custom card.

If you're open to this change then I can setup the dev environment for a full test.

@basbruss
Copy link
Collaborator

basbruss commented Sep 8, 2022

Hi @csuich2

Thank you for improving this card.

Binary Sensors can only have three states: on; off; unavailable. Therefore to make it more user-friendly and less error-prone you can consider changing the added variable to a boolean variable that can revert checking for the on state to the off state by setting true as the value for the variable.

Example:

value: > 
  [[[ 
    var check_state = 'on'
    if(variables.ulm_icon_alert_revert_state){
     check_state = 'off';
    }
    if (entity.state == 'unavailable' || entity.state == check_state){ return true; } 
  ]]]

@csuich2 csuich2 force-pushed the binary_sensor_alert_card_state branch from 9abad54 to 262d4de Compare September 9, 2022 11:40
@csuich2
Copy link
Contributor Author

csuich2 commented Sep 9, 2022

@basbruss Great point! I've updated with a boolean flag and verified the behavior with a devcontainer.

@basbruss
Copy link
Collaborator

basbruss commented Sep 9, 2022

@csuich2 Works perfect!

It will be available with the next release!

@basbruss basbruss changed the base branch from main to release September 9, 2022 11:49
@basbruss basbruss merged commit eb7437e into UI-Lovelace-Minimalist:release Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants