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

State switch not working template #65

Closed
Ruud-Mens opened this issue Oct 30, 2021 · 5 comments
Closed

State switch not working template #65

Ruud-Mens opened this issue Oct 30, 2021 · 5 comments

Comments

@Ruud-Mens
Copy link

The state switch is working when using an On - Off entity. But when I use a template, the matching state isn't triggered (class no-match).

Tested the template in the developer tools, and it returns the correct string.

      - type: custom:state-switch
          entity: "{% if state_attr('light.ks_6', 'brightness') > 40 %} cooking {% else %} dimmed {% endif %}"
          view_layout:
            grid-column: 2
            grid-row: 2
          states:
            cooking:
                  type: 'custom:button-card'
                  entity: switch.kitchen_cooking
                  name: Kitchen
                  state_display: "Dim kitchen lights"
                 etc
            dimmed:
                  type: 'custom:button-card'
                  entity: switch.kitchen
                  state_display: "Turn on cooking mode"
                 etc
@mag1024
Copy link

mag1024 commented Oct 31, 2021

My template-driven card selector has also completely stopped working with 1.9.1 -- the resulting dashboard is empty, with none of the states shown. This is despite there being a default, the template working fine, and everything working well with state-switch from June.
One interesting thing I observed is that it seems to be racy/non-deterministic -- if I repeatedly reload the page about 1/10th of the the card corresponding to the current state is actually displayed.

@jflefebvre06
Copy link

Same problem for me

@TBEMSESG
Copy link

Same behavior here; any update on this case?
thankyou

@wimb0
Copy link

wimb0 commented Dec 17, 2021

Same problem here.
Template works fine in Developer tools, but not in the custom:state-switch card.

@bmastevens
Copy link

bmastevens commented Dec 20, 2021

I had the same problem with this, and looking through some of the changes in 1.9+ noticed that the syntax for templating had been changed. As a test i changed it back to what was in the previous version, and it seems to work:
instead of

entity: >
  {% if is_state('input_boolean.test_one', 'on') %}
  yes
  {% else %}
  no
  {% endif %}`

i've used

entity: template
template: >
  {% if is_state('input_boolean.test_one', 'on') %}
  yes
  {% else %}
  no
  {% endif %}`

And that seems to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants