Hi,
I was wondering how to reference and change an icon colour of a card on the main page when a state changes on another page. I use hacs - Card-mod - button-card etc. I can change an icon colour on a button click for example as shown below on page 2
buthow do I change an icon colour of a card on another page when i click a button on this page.
So I need to point to a button on another page to change its icon colour for example.
Many Thanks for your assistance.
Why not use template code on the custom button card that you want to change colour, such that the icon colour is moded on the state value (on/off) of the button you are clicking (on another view). There is a state moding option in custom button card,
Well there is on this one at least: https://github.com/custom-cards/button-card
Thanks for your suggestion.
In the end i used an input Boolean helper as the entity attached to the button card on the main page. Then I used several automations with OR condition to change the helper depending on the button card states on the second page. So the objective being that if any heating switches are activated on the second page the icon colour on the main page heating will change to a warm colour and if no heating is on it will remain an ice colour.
"
type: ‘custom:button-card’
layout: icon_label
icon: ‘mdi:radiator’
entity: input_boolean.heating_icon_colour_change_main_page
show_label: true
show_icon: true
show_state: false
show_name: false
label: Heating
size: 30px
styles:
card:
- box-shadow: 0px 0px 20px 8px
- border-radius: 15px
- margin: 0px 5px 0px 0px
label:
- padding: 5px
- font-size: 20px
- font-weight: bold
- font-family: Helvetica
state:
value: ‘off’
color: ‘rgb(142, 169, 250)’
icon: ‘mdi:radiator-off’
label: Bedroom Heat 1hr
" #above is a sample button second page
"
alias: Setting Heating Icon Colour Toggle
description: ‘’
trigger:
platform: state
entity_id: switch.heating_bedrooms
from: ‘off’
to: ‘on’
platform: state
entity_id: switch.heating_kitchen
from: ‘off’
to: ‘on’
platform: state
entity_id: switch.heating_sitting_room
from: ‘off’
to: ‘on’
condition:
condition: state
entity_id: input_boolean.heating_icon_colour_change_main_page
state: ‘off’
action:
service: input_boolean.turn_on
data: {}
entity_id: input_boolean.heating_icon_colour_change_main_page
mode: single
" #above is one of my automations
it took 4 in total to achieve.