jarrah
(jarrah)
October 5, 2020, 1:54pm
4626
Yep, tried either group entity in the single template and they both worked ok. I’m just baffled as to why it’s not working.
Just tried with individual entities in case groups was the problem, but still no luck.
- box-shadow: |
[[[
return ( states['light.study_desk_lamp'].state == 'off' ||
states['binary_sensor.window_study_main_contact'].state == 'off' )
? '0px 0px 5px grey' : '0px 0px 5px red';
]]]
Hmm, even trying on another style doesn’t work either:
- type: custom:button-card
entity: binary_sensor.window_study_main_contact
show_state: true
show_icon: false
name: Test
styles:
card:
- border-radius: 15px
- border: 'solid 1.5px rgb(0,0,0)'
- font-size: 17px
- width: 200px
- padding: 4%
- box-shadow: |
[[[
return ( states['light.study_desk_lamp'].state == 'off' ||
states['binary_sensor.window_study_main_contact'].state == 'off' )
? '0px 0px 5px grey' : '0px 0px 5px red';
]]]
name:
- color: |
[[[
return ( states['light.study_desk_lamp'].state == 'off' ||
states['binary_sensor.window_study_main_contact'].state == 'off' )
? 'grey' : 'red';
]]]
It just defaults to the first option (grey in the example above). If I swap grey and red text around, text becomes red:
oddly enough I found another template, (also working ) which has the closing ‘)’ completely at the end:
var phrase = (temp <= 6 || day == 'off' ? 'Vijverpompen mogen: ' : 'Vijverpompen moeten: ');
though this is a var declaration, you could try that… but it’s a guess, (because the template also works in the corrected version with the closing ‘)’ after ‘off’
var phrase = (temp <= 6 || day == 'off' )? 'Vijverpompen mogen: ' : 'Vijverpompen moeten: ';
and I don’t like that really… we should just understand why the above template doesnt work.
jarrah
(jarrah)
October 5, 2020, 2:18pm
4628
Thanks, I’ll try those out.
Just to double check the issue is with my config somewhere, would you mind trying my test button code above with two of your entities to see if it works please?
sure:
- type: custom:button-card
entity: light.couch_library
show_state: true
show_icon: false
name: Test
styles:
card:
- border-radius: 15px
- border: 'solid 1.5px rgb(0,0,0)'
- font-size: 17px
- width: 200px
- padding: 4%
- box-shadow: |
[[[
return ( states['light.bureau_right'].state == 'off' ||
states['light.bureau_left'].state == 'off' )
? '0px 0px 5px grey' : '0px 0px 5px red';
]]]
name:
- color: |
[[[
return ( states['light.bureau_right'].state == 'off' ||
states['light.bureau_left'].state == 'off' )
? 'grey' : 'red';
]]]
working perfectly …
both lights on:
and either (or both) ‘off’
jarrah
(jarrah)
October 5, 2020, 2:57pm
4630
I really appreciate you testing that, thank you!!
I’m very puzzled now - time for more testing…
There’s nothing wrong with your code. Are you sure your groups have the appropriate state in the dev panel of HA?
Also sometimes a HA restart helps
VMCosco
October 7, 2020, 3:41pm
4632
Is there any way to wrap text? I want to keep the font size the same but when locked this card it too cramped for my liking.
KTibow
(Kendell R)
October 7, 2020, 3:53pm
4633
Just use styles, style the name/label/state with a smaller width, and a bigger height. Don’t forget to change text wrap.
You can do:
name: Living<br/>Room
1 Like
VMCosco
October 7, 2020, 4:14pm
4635
This just changed it to Living Ro…
This worked
VMCosco
October 7, 2020, 4:17pm
4636
I have this lock code working as is, I want to add another state, “Watch Live TV”, to the template so the card locks with either. How would I do that?
lock:
enabled: >
[[[ return states['sensor.harmony_activity_living_room'].state === 'Watch Fire TV' ]]]
exemptions: []
KTibow
(Kendell R)
October 7, 2020, 4:20pm
4637
Try
return states['sensor.harmony_activity_living_room'].state === 'Watch Fire TV' || states['sensor.harmony_activity_living_room'].state === 'Watch Live TV'
VMCosco
October 7, 2020, 4:23pm
4638
Worked perfectly, thanks!
VMCosco
October 7, 2020, 6:46pm
4639
I’m full of questions today. I have the below template and card entry. The button is not displaying the “primary color” when the binary sensor on. Functionality is ok. Is this a template issue or do I have something wrong?
button_card_templates:
sonos_master:
variables:
var_entity:
var_name:
var:option:
entity: '[[[ return variables.var_entity ]]]'
name: '[[[ return variables.var_name ]]]'
tap_action:
action: call-service
service: input_select.select_option
service_data:
entity_id: input_select.sonos_master
option: '[[[ return variables.var_option ]]]'
color: var(--paper-card-background-color)
color_type: card
show_icon: false
show_name: true
state:
- color: var(--primary-color)
value: 'on'
styles:
name:
- color: var(--secondary-background-color)
styles:
card:
- transform: scale(0.95)
- background-size: 100% 100%
- border-style: solid
- border-width: 2px
- border-color: var(--primary-color)
- height: 60px
name:
- font-size: 20px
- font-variant: small-caps
type: custom:button-card
template: sonos_master
variables:
var_entity: binary_sensor.sonos_master_office
var_option: media_player.sonos_office
var_name: Office
KTibow
(Kendell R)
October 7, 2020, 6:47pm
4640
Just a guess, try replacing state: 'on'
. Also sometimes edit mode stops button-card from getting updates for me.
VMCosco
October 7, 2020, 7:47pm
4641
Replace what? Sorry, not following
KTibow
(Kendell R)
October 7, 2020, 7:49pm
4642
value: on
with state: on
, actually that’s not real, sorry. I think you mean
styles:
name:
- color: var(--primary-color)
not background color.
VMCosco
October 7, 2020, 8:06pm
4643
Thats not it, I change the font color to a dark color when the button lights up
KTibow
(Kendell R)
October 7, 2020, 8:07pm
4644
What if you put the state filter before the standard color?
You can’t use javascript templates for the entity field, that’s why it’s not working.