Change colour of light based on energy consumption

In order to teach my children about power consumption and how flipping a switch affects that I want to install a RGB lightbulb in my house that changes colour based on the energy consumption of the whole house. I already managed to monitor power consumption, but am now struggling a little bit on how to use that data to change the colour of the light.

Did anyone on the forums ever tried to achieve something similar?

You can use a data_template in the ‘action’ section of an automation, something like:

action:
  service: light.turn_on
  data_template:
    entity_id: light.rgb_lightbulb
    color_name: >
      {%- if states.sensor.power_consumption | int >= 500 %}
        red
      {%- elif states.sensor.power_consumption | int < 500 %}
        yellow
      {%- elif states.sensor.power_consumption | int < 200 %}
        green
      {%- endif %}
2 Likes

In case anyone else is looking for a similar solution check out this thread.