#Button colour
1 messages · Page 1 of 1 (latest)
If you're using the stock button card, I don't think there is an easy way to make it work. You could probably make some changes to your theme but then that would be more of a global change rather than just for this button.
You could use card_mod. I have an example of its use for something like what you want to do. Card modding a button card's icon and icon color (Take a look at the code for One State.)
The custom:button-card is a good all-purpose card that is very customizable. You could define how you want the card to appear when water is detected and another state definition for when it is not. (IMO, the custom:button-card is a bit easier to work with than card-mod.) There is a lot of information in the doc but there's also some useful examples at the bottom of the page.
i've been trying the button-card one but i cant seam to get it to work. I've taken one of the examples and changed it to my entity names but when i hit save it says sucessfull but it deletes all the code
That's not valid yaml in your screenshot
Everything lines 2-5 should be 2 spaces to the left, aligned with type
Some of the examples are a bit "wonky". The example that you tried is a good example (pun intended) of the wonkiness.
The example shows: ```yaml
- type: custom:button-card
entity: switch.skylight
name: <3 Apple
icon: mdi:fire
show_state: true
styles:when really it should beyaml
type: custom:button-card
entity: switch.skylight
name: <3 Apple
icon: mdi:fire
show_state: true
styles:
cool, thanks for the pointers, have managed to get the colour changed to blue but no mater what i try it cant get the colour to change depending if the sensor is wet or dry
Are you using a binary sensor? It's state will be either on or off? HA translates the on/off into wet/dry for you but the card will want the actual state.
Post your code for the card and we can look at it a bit closer.
Just noticed your screenshot from earlier. Try using on/off states.