The round buttons, - can you please share the code?
see post above
Templating feature is very cool! Iāve combined a battery state sensor and battery level sensor into one card within the first few minutes of trying it. Also made a āNow Playingā for Spotify (media_title and media_artist attributes):
label_template: >
return (' "' + states['media_player.spotify'].attributes.media_title + '" by ' + states['media_player.spotify'].attributes.media_artist + ' ');
show_label: true
It would be perfect if you could style the label too though. Like in this example Iād like the label with now playing text to be a smaller font size and different color. Maybe something that could be considered?
Thanks again for making this card so amazing!
Looks like this is the code for your square buttons. I have been trying to get my buttons round. And to stay round
Whats your settings?
border-radius: 50%
instead of px
and specify a fixed height and width.
I heard you
Also fixed with the same PR.
Breaking Changes
- for now
style
andentity_picture_style
are still supported, but please make sure you update your configuration so thatstyle
becomescard
andentity_picture_style
becomesentity_picture
, both under thestyles
option (note the S at the end ofstyles
). Next releases will drop the support forstyle
andentity_picture_style
.
Basically, this:
Becomes:- type: custom:button-card style: - border-radius: 10% entity_picture_style: - filter: grayscale(100%)
- type: custom:button-card styles: card: - border-radius: 10% entity_picture: - filter: grayscale(100%)
- The styles defined in each state are now additive with the styles defined in the main part of the configuration. It means you donāt have to define all the CSS entries in each state, only define the ones which change. Define the common ones in the main
styles
config part and define specific ones in eachstate
styles
entries.
New Features
-
Styling per element supported by using the new
styles
object available in the main config and in eachstate
entry.
You can configure the style for:-
card
: Styles that are defined here will be applied to the whole card and itās content, unless redefined in elements below. entity_picture
icon
name
state
label
- type: "custom:button-card" color_type: icon entity: light.test_light label_template: > var bri = states['light.test_light'].attributes.brightness; return 'Brightness: ' + (bri ? bri : '0') + '%'; show_label: true show_state: true size: 10% styles: card: - height: 100px label: - color: gray - font-size: 9px - justify-self: start - padding: 0px 5px name: - text-transform: uppercase - letter-spacing: 0.5em - font-familly: cursive - justify-self: start - padding: 0px 5px state: - justify-self: start - font-size: 10px - padding: 0px 5px state: - value: 'on' styles: state: - color: green - value: 'off' styles: state: - color: red card: - filter: brightness(40%) - type: "custom:button-card" color_type: icon entity: light.test_light layout: icon_label label_template: > return 'Other State: ' + states['switch.skylight'].state; show_label: true show_name: false size: 100% styles: card: - height: 200px label: - font-weight: bold - writing-mode: vertical-rl - text-orientation: mixed state: - value: 'on' styles: label: - color: red - value: 'off' styles: label: - color: green
-
Fixes
- Brightness calculation for lights was different than the default from Home Assistant. This is fixed.
- Own longpress was not used in some cases
Great work, I like what you have done with styles as it will save a lot of code. However do I need to change something to get the right RGB brightness colors? It says it is fixed in the last PR, however I still get a difference in brightness.
Screenshots below, show brightness at around 20%, they are the same entity (different icon srry). The button screenshot shows the color with this card, the screenshot with the lightbulb shows the original HA color (brightness is at 20%)
Did you empty your browser cache? Try in a private instance of your browser please to make sure it has nothing to do with caching.
If itās still not working copy the content of your light state when itās at 20% like in the picture (using the http://HASS_IP/dev-state
)
I donāt have the issue anymore (brightness ~= 25%):
And thatās my state:
brightness: 62
hs_color: 0,100
rgb_color: 255,0,0
xy_color: 0.701,0.299
value_index: 0
value_instance: 1
power_consumption: 1.4
supported_features: 17
hidden: false
icon: mdi:led-strip
Hm yeah in my browser it has the right color, canāt seem to clear cache in the ios app (usually a refresh would suffice, but seems to do nothing). Will try some more refreshes haha. Thanks anyways.
Edit: Couldnāt get it to clear, reinstalling the ios app solved it for me.
This is truly amazing! I was literally trying to figure out whether I could style an individual button based on an entity state last night. So glad I decided to sleep on it and not forge ahead. Thank you so much @RomRider!
Quick question for the brain trust - Does anyone know how I might go about tweaking the gap between these cards? I tried using -padding: 0px
but that didnāt have my desired effect.
Ultimately, my goal is to make these buttons look and function more like a tabbed sub-menu system whereby each button triggers a conditional card based on the state of several input_booleans within the same view.
Itās not possible with padding. A card has no control over the width between cards.
However thanks to
- type: custom:button-card
color_type: blank-card
style:
card:
- width: 50px #change the value to suit your needs
put in between each card on the line and youāll be able to cheat and add space between buttons
And if you want to increase the gap vertically @daphatty you can use gap-card:
EDIT: Though I guess a single line with just one blank card would work equally well.
And if all that fails you could use a vertical-in-stack card. It will remove the gap entirely. Not the best solution I reckon.
Ahh, just looked back at @daphattyās post and I think @RomRider and I both actually missed that the goal was to remove the gaps, not increase them.
Correct, my goal was to remove the gap. In hindsight, I wasnāt as clear about that detail.
You probably need this:
Is there a way for a button to monitor two sources? Basically like an automation with two triggers.
Hi there, Iām trying to repliace the ālast_updatedā function the new label feature, so far I have this
return ((as_timestamp(now()) - as_timestamp(states['light.outside_front_door'].last_updated) | int));
But itās not working. Am I on the right track here?
I donāt quite understand, what do you want to achieve? Is it modifying the button based on the state of 2 entities? If yes operator: template
will be useful.
Templates in this card needs to be written in javascript. This is not javascript, this is a mix between home-assistantās template engine with a javascript return
in front
You can try something like : return Date.now() - Date(states['light.outside_front_door'].last_updated)
Let me know how it goes.