I have an energy monitoring smart plug that I use to monitor a device, but not to turn that device on and off (currently, at least). To tell whether the device is actually on (it has it’s own switch), I monitor the power usage using the smart plug, and have added a sensor in config.xaml as follows:
sensor:
- platform: template
sensors:
guest_room_bedside_light_on:
value_template: >
{% if ((states('sensor.guest_room_bedside_light_power') | float) > 0.0) %}
on
{% else %}
off
{% endif %}
When used on a dashboard using the following definition, I see the on and off status, but the state_color is not having any effect. What more do I need to do to get state_color to react to the on/off status?
type: vertical-stack
cards:
- type: entity
name: Guest room bedside lamp
icon: mdi:desk-lamp
state_color: true
entity: sensor.guest_room_bedside_light_on
- show_name: true
show_icon: true
type: button
tap_action:
action: call-service
service: script.toggle_guest_room_bedside_lamp
target: {}
name: Toggle Guest room bedside lamp
icon: mdi:desk-lamp
entity: sensor.guest_room_bedside_light_on