Add fixed power consumption attribute to light/switch entities

If I have a lamp with, say a 10W light bulb, I know that it draws 10W when it’s on. If I could manually add that attribute to my WiFi or RF switch, it could be the beginning of an interesting power consumption overview of my whole home. Most Zwave devices already does this. I know I could manually add template sensors for each switch, but that’s a load of work, not only to create, but also to maintain. If I could add that, and maybe on a later stage, such data could be available as secondary info, and it could also go to categorize how much of my electricity is used to light, heating etc.

Wouldn’t you still need a template sensor to make use of that attribute? After all an entity is needed to do graphing or to publish metrics to some database.
Besides that, this would heavily depend on the platforms that are being used. Lets take Philips Hue. There you only configure your hub, no individual lights (which may have different consumption values). And even if that was available, you’d still have to configure it per entity. In that case I don’t really see any benefit compared to using template sensors straight away. Especially because sometime people (or at least I) use light groups. And there I only have one template sensor with the sum of energy consumption instead of multiple individual ones.

I do see how this can become messy in the configuration. But as said above, you wouldn’t get rid of that because you still would need additional sensor entities.

Since I don’t know how you’ve done it, here’s how I am doing this:

- platform: template
  sensors:
    kitchen_ambience_watt:
      unit_of_measurement: "W"
      entity_id: group.kitchen_ambience
      value_template: >-
        {% if is_state('group.kitchen_ambience', 'on') %}
          10.5
        {% else %}
          0
        {% endif %}
1 Like

What I had in mind, was (ideally) to be able to set a power consumption and consumption type, say light, heat, appliance, electronics etc. values from the UI for such as my sonoff devices controlling most lamps in my home. I imagine a built-in component gathering this data into a graph/pie chart where one could read how much is used in which category. Some people also have a main power consumption sensor on their kWh meter, so this could be used, subtract all specified values, and the rest would then be “misc”.

All this data could be handled locally, and the data from the stats/pie chart could be published collectively to a db for more historic data. I think many people would love something like this, but I also think it could be challenging to integrate into HA, not that I’m qualified to say much about the programming side of things.

1 Like

You might be interested in this discussion:

1 Like

I use this concept and added a sensor, that adds up all my lights, based on their power rating.
Maybe usful for someone…

- platform: template
  sensors:
  - name: Light Power
    unique_id: lp1
    state: >
      {% set list = [
          ('light.one',9),
          ('light.two',9),
          ('switch.lamp',40),
      ] %}
      {% set accumulator = namespace(total=0) %}
      {% for (light, watts) in list %}
        {% if is_state (light, "on" ) %}
          {% set accumulator.total = accumulator.total + dict(list)[light] %}
        {% endif %}
      {% endfor %}
      {{accumulator.total / 1000}}
    state_class: measurement
    icon: 'mdi:lamp'
    unit_of_measurement: W
    device_class: power

Now to figure how to get it into the Energy dashboard…

Did you look at https://github.com/bramstroker/homeassistant-powercalc ?

Wow, no, I had not seen that. Thanks,