Multiply sensor value with another value

states.sensor.total_power_usage.state is the total of adding your individual sensors using this template:

platform: template
sensors:
  total_energy_used:
    value_template: '{{ ((states.sensor.xiaomi_office_power.state | float) + 
    (states.sensor.xiaomi_tv_power.state | float) + 
    (states.sensor.cupboard_light_power.state | float) + 
    (states.sensor.pc_energy_2_0.state | float) + 
    (states.sensor.server_energy_3_0.state | float) + 
    (states.sensor.soffa_energy_6_0.state | float) + 
    (states.sensor.sovrum_energy_10_0.state | float) + 
    (states.sensor.hall_energy_11_0.state | float) + 
    (states.sensor.tvattmaskin_energy_9_0.state | float)) | round(0) }}'
    friendly_name: 'Total used'
    unit_of_measurement: 'kWh'
  • I have changed the first couple for you so you get the gist… this will then create the sensor you need for your second template sensor. total_energy_used:

use this sensor in the utility monitor…

I have also taken it a step further and calculated the cost with these template sensors (I had to add my off-peak and peak each being muliplied by their respective tarriff:

- platform: template
  sensors:
    offpeak_monthly_electricty_cost:
      value_template: '{{ ((states.sensor.monthly_energy_offpeak.state | float * 0.078)) | round(0) }}'
      friendly_name: 'Off Peak Monthly cost'
      unit_of_measurement: '£'

- platform: template
  sensors:
    peak_monthly_electricty_cost:
      value_template: '{{ ((states.sensor.monthly_energy_peak.state | float * 0.155)) | round(0) }}'
      friendly_name: 'Peak Monthly cost'
      unit_of_measurement: '£'

- platform: template
  sensors:
    total_electricity_used:
      value_template: '{{ ((states.sensor.offpeak_monthly_electricty_cost.state | float) + 
      (states.sensor.peak_monthly_electricty_cost.state | float)) | round(2) }}'
      friendly_name: 'Total used'
      unit_of_measurement: '£'
2 Likes