Uhm maybe with icon conditions. Leave one condition an empty string? Don’t know if that would work but you can try it
That did it!
icon:
template:
icon: >
if (entity.state = 1) return 'mdi:sleep';
else return ' ';
the blank space is still clickable, but that’s just minor quibble at this point. Thanks!
And if you pass tap_action none?
Even then, the whole title from the left where the icon is / would be to the first info_entity remains clickable.
Is templating supported for tap_action? I was thinking something like:
tap_action:
template:
tap_action: |
if (entity.state = 1) return 'more-info'; else return 'none';
edit: or did I misunderstand what you meant?, I thought you mean pass none instead of ’ ’ for the icon.
O yeah wait. Never mind haha. It was late.
No templating isn’t supported in actions
Hi, sorry it’s me again
I made this to change icon color for the vacuum according to what it’s doing and it’s working great, i.e. immediately changes when state of the entity changes:
- entity: vacuum.robovac
name: Vacuum
show_icon: true
state_color: true
tap_action:
action: more-info
show_state: false
icon:
conditions:
- condition: equals
entity: vacuum.robovac
attribute: status
value: docked
styles:
color: orange
- condition: equals
entity: vacuum.robovac
attribute: status
value: cleaning
styles:
color: green
- condition: equals
entity: vacuum.robovac
attribute: status
value: returning
styles:
color: purple
Trying to apply the same concept on my kodi button based on state of media_player entity only works after dashboard reload:
- entity: script.turboviglen_kodi
name: Kodi
tap_action:
action: toggle
show_icon: true
icon:
conditions:
- condition: equals
entity: media_player.kodi
value: idle
styles:
color: darkgrey
- condition: equals
entity: media_player.kodi
value: playing
styles:
color: green
- condition: equals
entity: media_player.kodi
value: paused
styles:
color: orange
- condition: equals
entity: media_player.kodi
value: buffering
styles:
color: purple
At this point I’m not sure if I’m just missing something obvious again or just plain inept.
for reference:
full working card: PrivateBin
full not working card: PrivateBin
Hmm could be that it doesn’t work with script entities. Let me check tomorrow. But sometimes single quotes around the values help. So ‘paused’ in stead of paused
I had the quotes there originally but they get stripped when saving so I presume teh HA’s parser knows what it’s doing.
True, I will try to reproduce tomorrow
I think it’s related to the script entities as you mentioned, although it seems not in the info_entities: block, in the following the volume buttons hide correctly, the media buttons after reload.
rows:
- entities:
- entity: script.turbojeba_play_pause
name: Play/Pause
show_name: false
tap_action:
action: toggle
- entity: script.turbojeba_next
name: Next
show_name: false
tap_action:
action: toggle
content_alignment: center
hide_if:
conditions:
- condition: equals
entity: input_boolean.helper_turbojeba_media_room_card
value: 'off'
info_entities:
- entity: script.turbojeba_vol_down
name: Vol-
icon: mdi:volume-minus
show_icon: true
tap_action:
action: toggle
hide_if:
conditions:
- condition: equals
entity: switch.turbojeba_power
value: 'off'
- entity: script.turbojeba_vol_up
name: Vol+
icon: mdi:volume-plus
show_icon: true
tap_action:
action: toggle
hide_if:
conditions:
- condition: equals
entity: switch.turbojeba_power
value: 'off'
Seems like it yeah. One other thing, my mediaplayer doesn’t have a state ‘paused’ or ‘buffering’ so I cant test that states for you.
Ontopic: The card uses the states that hass gives it. So maybe the scripts entities work in another way? But are you trying to control a mediaplayer? If so, why not use the mini-mediaplayer card?
I already have mini-media-players for 3 pcs in there that show/hide depending on which one I play something, but the button I try to color just launches Kodi. Since many other entities I have on dashboard turn yellow when on, I was working on those that don’t like the vacuum or the Kodi button.
I could probably make a input_boolean helper that would copy the state of kodi (on unrelated note I have several entities like this and they drive my imagined ocd up the wall as yellow
ain’t the same as the yellow in default ha theme and I can’t find the value for that one), but I really liked the vacuum icon turning different colors on different states so wanted to copy that.
The script entities work differently, they’re always on and get triggered (sort of as automations I think?). The reason I use so many scripts where I could use button
or input_boolean
is when I change device or switch integrations, the old device goes poof from all and every automation and dashboard yaml, and god help you if you forgot what was where. So I use scripts, that “press” the buttons on the devices, and if the device goes poof, I just replace it in the script and my dashboard remains intact. Hope that makes sense.
Oh you are right. The scripts are always on. Thats why it doesnt trigger a change in the color. But this is sort of a bug in the room card than.
@C.G.B.Spender
I understand your ocd, suffer myself as well.
Try the active state for the color;
icon:
template:
styles: >
if (entity.state > 35) return
'color:var(--paper-item-icon-active-color)';
Check out version 1.07.01 this will fix the icon color updating
@marcokreeft87 Will do when I get home work, cheers!
@GH2user I recently found the gold
color is the yellow that the ha theme uses, but your suggestion has the added benefit of working with every theme I believe, I’ll be implementing that, thanks!
1.07.01 works great, the media player icon now changes colors consistently with the player state. Many thanks once again!
question about marigin - how to make it smaller ?
I would like to make margin smaller on top…
I figured out that for header I can do it something like this - and is`t working
style: |
.card-header {font-size: 130%; padding-top: 0px;}
but how to make it the same for entity-info ?
thanks in advance !
The entity row has its own CSS domain. Here’s an example of some changes I made to mine:
.entities-info-row {
padding: 0px;
right: -10px;
top: 0px;
}