Hi
I’m new to HS and hope someone can help me out with this issue. I have a lovelace card, with a custom senor I created for a device (TRV) and I want the sensors icon color to change depending on the state of the sensor.
I have a TRV which outputs a State > Attribute > hvac_action. The hvac_action attribute can be either:
“heating” (if the thermostat is calling for the heating to be turned on) or
“idle” (if the thermostat is satisfied wants the heating to be turned off)
These attributes are not exposed to home assistant as a sensor by default so I cannot show what the TRV is calling for in a lovelace dashboard.
What I did was create a senor by doing the following:
In configuration.yaml add the following code:
sensor: !include sensors.yaml
Make new file > sensors.yaml in HS config root
Created a new sensor “trv_hvac_action” to display if the TRV hvac_action attribute is “heating” or “idle” - added the code below to sensors.yaml:
- platform: template
sensors:
trv_hvac_action:
friendly_name: "TRV HVAC Action"
value_template: "{{ states.climate.tze200_ywdxldoj_ts0601_1c1e0dfe_thermostat.attributes.hvac_action }}"
Rebooted the system.
The new sensor “trv_hvac_action” works fine in that when the TVR is “heating” it displays “heating”, and when “idle” it displays “idle”. I would also like the icon to be shown as yellow when “heating” and blue when “idle”. I have attached pictures below showing this with a light switch which does change color (would just like the default blue for “off” and yellow for “on”).
The icon I’m using is: mdi:lightbulb-outline
Hope this makes sense and thanks in advance for any help!!