This method does not work. It show primary entity more-info
Well, that works on my test env. Are you using the latest version and did you clear your cache?
BUGFIXES
- Locked buttons will now lock properly again after the first unlock
- No more shadow clicks when using
action: navigate
- Reopens #200 as those 2 bugs where regressions introduced while trying to fix it.
Thnx so much @RomRider so far it looks like it has fixed all my problems. No more double clicking when turning off my input_booleans. And ofc the double click problem with lights and switches (which you have already fixed yesterday).
I will let you know if I find some other bugs. But so far so good! Thank you
Working all ok again, thanks for the great job and support
Give this section a read: https://github.com/custom-cards/button-card/blob/5ef600a6e0c5bde101c756bc6816388a338d2dc8/README.md
show_entity_picture: true
Why does my entities states wonāt show?
i want to make a notification bar:
type: vertical-stack
cards:
- type: 'custom:button-card'
color_type: label-card
color: 'rgb(44, 109, 214)'
name: Kitchen
- type: 'entity-filter'
entities:
- entity: binary_sensor.0x00158d000186ff02_contact
- entity: binary_sensor.0x00158d0001b780b3_contact
- entity: binary_sensor.0x00158d0002284d7b_contact
- entity: binary_sensor.0x00158d0001c0e501_contact
state_filter:
- on
card:
type: custom:button-card
Entity-filter only works with cards that support multiple entities. The button card supports one entity.
a very quick one:
using this now:
styles:
card:
- border-radius: 6px
- box-shadow: '0px 0px 2px 1px #F0C209'
but need a - shadow: 'elevation: 6dp'
also. How can I add that, please?
ok thanks, will have to do then
please allow one more observation, which might lead to a small changeā¦
using operator on state, and a template for the operator, we have to use the return
phrase
with the new card:
state:
- operator: template
value: >
[[[
return states['light.test_light'].attributes
&& (states['light.test_light'].attributes.brightness <= 100)
]]]
previously like:
- operator: template
value: >
return entity.state == 'not_home' && entity.attributes.country_code != 'nl'
what always has been awkward to me is the fact we need to use āreturnā while in fact this is the if-condition, the check. So not yet the āreturnā, the resulting value to return in the front-end.
Would you be willing to consider changing that to:
state:
- operator: template
value: >
[[[
states['light.test_light'].attributes
&& (states['light.test_light'].attributes.brightness <= 100)
]]]
it is a very small change, but more logical, much clearer to read and will possibly prevent mistakes. It would also make these templates be more like what we do in other places in HA, be it Jinja or JS.
take out the āreturnā in the conditional templates.
No, thatās not possible, sorry.
return
creates the resulting value used as the field value. If I remove the need of return, thereās not way to do more complex things like create variables, loops, etcā¦ inside the templates.
javascript is a complete language, you canāt just arbitrarily remove some thingsā¦
sure, wouldnāt want to have made the impression to have suggested that ā¦
its just that your card is the first in HA that uses that exact construction on templates. Custom-ui, custom Tiles card, and now the Lovelace Tiles cards, to name a few major ones, all use the if statements without return on the condition part, only in the return section. So it never dawned on me that was incorrect.
thanks for your reply!
In all the cards youāve mentioned, I can see return
everywhere
There is 2 examples I see in custom UI and it looks like a shorthand if statement with out the return.
"${attributes.power_consumption !== 0 ? (attributes.power_consumption + 'W') : ''}"
This one looks like its just the code without the return
${Math.round(attributes.brightness || 0) / 2.55}%
EDIT:
they call it āJavaScript templateā. Seems like a waste of time to meā¦ just to replace the word āreturnā with ${
and replace the termination with }%
sure. but not in the conditional (test) part of the template, only the exiting (result) part. Itās almost asif you use āreturnā instead of āifā.
but thats not a condition, its a return value.
I knowā¦ Thatās why I said
The difference in java script would be:
return Math.round(attributes.brightness || 0) / 2.55;
Not much change. And for the other oneā¦
return (attributes.power_consumption !== 0) ? (attributes.power_consumption + 'W') : '';
Letās move on, please