And state_not: 'unavailabe" ?
Iāve got a sensor with this template working fine to show or hide a conditional card:
{{ state_attr('sensor.trakt_next_to_watch_all', 'data')
| map(attribute='title')| map('lower') | select('eq', 'parks and recreation')
| list | count > 0 }}
I was hoping that I could put this template directly in a state-switch card so I wouldnāt have to make all the extra sensors.
This doesnāt seem to be working. Am I doing something wrong?
type: custom:state-switch
entity: template
template: |
{{ state_attr('sensor.trakt_next_to_watch_all', 'data')
| map(attribute='title')| map('lower') | select('eq', 'parks and recreation')
| list | count > 0 }}
states:
'True':
type: custom:button-card
template: serie2
name: Fallout
tap_action:
action: call-service
service: script.fallout
entity_picture: >-
https://walter.trakt.tv/images/shows/000/163/965/posters/thumb/048a739d1e.jpg.webp
EDIT:
My bad! Switching states to ātrueā instead of āTrueā did the trick
I tried the following ways but none of them work:
state_not: "unavailable"
state_not: unavailable
state_not: "Non disponibile"
state_not: Non disponibile
The card is ALWAYS displayed:
It doesnāt work like this either:
in this way, however, I can hide the contents of the card:
But I would like to hide the card completely if the sensor is āunavailableā
Did you actually check it outside of the editing mode? Conditional card editor does not update the preview based on whether the condition is currently true or not. You can try either clicking 3 dots and selecting test, or just save it and go out of dashboard editing mode. For whatever reason it works different with the entities conditional row, where the preview immediately changes depending on condition. It does make sense if you think about it.
Also by the way, the conditional card accepts lists in the state or state_not variables, so you can specify multiple states too.
I think Iāve found a bug, but itās my first use of state switch so not certain.
Essentially state-switch itself is working perfectly. But any button I put inside it (standard or custom:button-card) fails to do anything.
My use case is below. These buttons work outside of state-switch with no code change.
*** updateā¦ user error ***
I try to make a test with state-switch and custom:button-card with transition, but not working as I expected.
When I press button test1 button 2 slide-down and I can see button only until transition finishes, after that button dissapears.
When I press button test2 button 1 slide-down and I can see button only until transition finishes, after that button dissapears.
What I am doing wrong?
Here is my test code:
type: vertical-stack
cards:
- type: custom:state-switch
entity: hash
default: none
states:
p1:
type: custom:button-card
name: button 1
p2:
type: custom:button-card
name: button 2
none:
type: custom:button-card
name: test
- type: custom:state-switch
entity: hash
default: p2
states:
p1:
type: custom:button-card
name: button 1
p2:
type: custom:button-card
name: button 2
none:
type: custom:button-card
name: test
transition: slide-down
- type: horizontal-stack
cards:
- type: custom:button-card
name: test1
tap_action:
action: navigate
navigation_path: '#p1'
- type: custom:button-card
name: test2
tap_action:
action: navigate
navigation_path: '#p2'
The latest HA build seem to have broken the user/group functionality. I had it set to group admin and it is no longer visible for admins.
OK, I did some more debugging and it appears that the first request does not have the correct status for user and/or group sent. Once i hit refresh the correct card populates. Unfortunately you canāt hit refresh on the mobile app so the correct cards never load on the mobile app because of this.
Iām using the state-switch card to show different entities to different users, but I want to show the same thing in case of 2 users without having to repeat the whole card definition as well. Is this possible?
Google about yaml-anchors. Work only in yaml-mode-dashboards. If you use a storage-mode-dashboard - you cannot use yaml-anchors. In general, most of ways of reusing code only work in yaml-mode-dashboards.
Hmm this is the second time today that comes up when Iām searching for solutions for my dashboard, guess thatās a sign. People say it makes editing harder, Iām guessing because you lose the live visual preview? Canāt one just have a dev dashboard for working on stuff before moving it over? ā¦Iāll read up, thanks.
Storage mode is mainly for beginners or people who cannot program / do not want to learn programming.
Many people use storage mode for testing and yaml mode for a final code.
Thatās a pretty good solution to help you transition. Admittedly the UI Dashboard editor does create a fair chunk of non-essential (default settings) YAML from time to time, but it can help you understand how everything fits together and can help you to prototype something before moving it over to
pure YAML
Yes thatās exactly what Iām doing now, Iāve transitioned our main dashboard to YAML mode, and still using storage mode for quick prototyping. I donāt see myself getting rid of the storage mode for that reason alone.
i seem to be getting the same. the card is all over the place.
The post youāre replying to is an example of what does not work, and I expect it is because the OP has used the same state hash in more than one state switch card on the same page
He uses p1 and p2 on two cards
This alters the navigation url anchor to #p1 or #p2
both cards toggle when this changes
They toggle on, then straight off again
The OP should have used unique values for the state keys on each card, for instance
- card-1-p1
- card-1-p2
- card-2-p1
- card-2-p2