Chained Power Usage

Hi all,

I have a question and I was hoping someone could shed some lights on it.

I have a UPS where my switch, router, storage etc are connected. There is a smart socket monitoring usage of the UPS and added as individual device to HA.

I also have a PC and monitor with it’s own sockets and energy monitoring (both listed as separate individual devices) so I know exactly how much my PC and monitor are using.

Both PC & Monitor are also connected to UPS so UPS smart socket is showing power of all equipment connected to it including PC and monitor.

Is there a way I can modify individual device power usage (UPS) and decrease it by PC power usage and monitor power usage?

If someone could point me in a right direction that would be amazing.

Thank you,
Pawel

Hello,

you need a template sensor like:

template:
  - sensor:
      - name: "UPS_net"
        unit_of_measurement: "W"
        state: "{{ states('sensor.total_UPS_power')|float(0) - states('sensor.ess_PC_power')|float(0) }}"

Hope it helps.

2 Likes

Some additions to make it more robust and configurable from the frontend:

template:
  - sensor:
      - name: "UPS_net"
        unique_id: ups_net
        unit_of_measurement: "W"
        device_class: power
        state_class: measurement
        state: "{{ states('sensor.total_UPS_power')|float - states('sensor.ess_PC_power')|float }}"
        availability: "{{ has_value('sensor.total_UPS_power') and has_value('sensor.ess_PC_power') }}"

Note you can do this from the UI:

Settings → Devices & Services → Helpers → Add Helper → Template → Template a sensor

2 Likes

Hello,

will double check my configuration, thanks for improving my uneducated code.

Amazing. Thank you both.