#Button colour

1 messages · Page 1 of 1 (latest)

lusty lantern
#

Is there an easy way to change the colour of a button in an 'alarm' state?

I have a water sensor connected to my dogs water dish so that when water isnt detected I get a notification but i've added it to my dashboard also and when it detects water it goes red, can i make that blue?

brisk ridge
#

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.

lusty lantern
#

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

gloomy kayak
#

That's not valid yaml in your screenshot

#

Everything lines 2-5 should be 2 spaces to the left, aligned with type

brisk ridge
#

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 be yaml
    type: custom:button-card
    entity: switch.skylight
    name: <3 Apple
    icon: mdi:fire
    show_state: true
    styles:
lusty lantern
#

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

brisk ridge
#

Just noticed your screenshot from earlier. Try using on/off states.