From the reading I’ve been doing I’m not sure if what I want to do is possible but thought I’d ask anyway.
I am currently using a Shelly Plus 1 Wifi switch that triggers the input to my front gate opener. I have just recently wired up a limit switch that changes state depending on whether the gate is open or closed. This is wired into the sw input of the shelly device (Detached Switch Mode) and causes the icon of my custom button to change colour based on status (red for closed and green for open)
This all works perfectly fine.
Code for button as per below;
type: custom:button-card
name: Front Gate
entity: binary_sensor.shellyplus1_08b61fd945f4_switch_0_input
icon: mdi:gate
aspect_ratio: 1/1
state:
- value: 'on'
color: rgb(39, 199, 28)
- value: 'off'
color: rgb(255, 0, 0)
tap_action:
action: toggle
entity: switch.shellyplus1_08b61fd945f4_switch_0
I also have an action setup via carplay that allows me to open & close the gate by operating the same shelly device. When you set the action up from within the ios app, the options are very limited.
I know that you can also set the actions up via the configurations.yaml file which does show a field to select icon colour but I’m not sure if there is a way and if so, how to format it to choose the 2 different colours based on the state of the sw input to the shelly.
Example from HA Documentation
Code for my automation from the carplay action
alias: Front Gate Open Or Close
description: Carplay Shortcut
trigger:
- platform: event
event_type: ios.action_fired
event_data:
actionID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
condition: []
action:
- service: switch.toggle
data: {}
target:
entity_id: switch.shellyplus1_08b61fd945f4_switch_0
mode: single