Indirect measurement of electricity usage

In my bathroom I have a 150W electric towel-rail (on-off) and 160W electric underfloor heating (temperature modulated). The controllers are integrated into HA as a switch and a climate entity.

 switch.towel_rail_2
 climate.bathroom_2

I want to monitor the electricity usage in HA.

My proposed approach is to create one new platform sensor which has the value 150 when switch.towel_rail_2 is “on” and a second new platform sensor which has the value 160 when climate.bathroom_2 hvac_action is “heating”. Then create two more integration sensors to integrate these sensors to record the total Watts used.

Is this a sensible approach or is there a simpler way to achieve my outcome?

2 Likes

That looks very promising, not sure how I didn’t find it when searching this community. It looks like I want some fixed sensors. I will try it and report back

1 Like

Another approach is to add a “power” attribute to the entities you have already. You can then use that to calculate usage:

  - platform: template
    sensors:
      balights_power:
        friendly_name: Bathroom light
        unit_of_measurement: Watt
        value_template: >
          {{ expand('light.bathroom_1') | selectattr('state', 'eq', 'on') | map(attribute='attributes.power') | map('int') | sum }}
          

(Not my idea - credit to @123)

1 Like

Initial feed-back is that the installation instructions are sparse.
I installed it (three times) and expected to find something under integrations (as with my other HACS custom component) but nothing. Instead of giving up, I just tried to build a couple of power sensors and it seems to be working:

- platform: powercalc
  entity_id: switch.towel_rail_2
  name: Towel Rails 2
  fixed:
    power: 300

- platform: powercalc
  entity_id: climate.bathroom_2
  name: Bathroom 2
  fixed:
    states_power:
      hvac_action|idle: 0
      hvac_action|cooling: 0
      hvac_action|heating: 160

Which appear to be working very well. Plenty more to try out, but at the moment :+1: thanks.

1 Like

Hi, I am the developer of powercalc component. The reason you don’t see it at integrations is because it does not provide functionality to set things up with the UI. Only integrations which have are configurable with the UI are visible there.
Let me know what you are missing in the installation/setup instructions, we can see if we can improve it.

Hello Bram, Chapeau. Your Powercalc component seems to be solving al my issues. I will raise an issue/enhancement on Github regarding the installation.