Since some time I am expanding my power monitoring, I have a power meter on the main energy source that show me the total power used and then several power meters / plugs that show me the power used by some individual devices.
But I don’t have a power meter yet in every single wall soket so I decided to create a sensor that will “monitor the unmonitored” as the difference betweent the total power used and the ones used from all devices I monitor. This way I can quickly notice how much is not monitored and I can also create an energy sensor to display in the energy daskboard as individual device and now the sum of all individual devices will match with the total house energy used.
This is the sensor I created:
- platform: template
sensors:
unmonitored_power:
friendly_name: Unmonitored Power
device_class: power
unit_of_measurement: W
value_template: "{{ ((states('sensor.legrand_din_power_consumption_module_electricalmeasurement') | float) - (states('sensor.presa_asciugatrice_power') | float) - (states('sensor.presa_friggitrice_power') | float) - (states('sensor.presa_frigorifero_power') | float) - (states('sensor.presa_lavastoviglie_power') | float) - (states('sensor.presa_mobiletv_power') | float) - (states('sensor.presa_calorifero_power') | float) - (states('sensor.shelly_bagno_power') | float) - (states('sensor.shelly_camera_cassettiera_power') | float) - (states('sensor.shelly_camera_letto_power') | float) - (states('sensor.shelly_cameretta_scrivania_power') | float) - (states('sensor.shelly_taverna_mobile_power') | float) - (states('sensor.shelly_taverna_scrivania_power') | float) - (states('sensor.shelly_sala_divano_power') | float) - (states('sensor.shelly_caldaia_power') | float)) | float | round(1)}}"
The issue I have is that I had to exclude one of my entities as it is showing ‘unavailable’ and if I add it to the template, it won’t work.
I guess that if any other of the entities I included will become unavaible, my sensor will stop working.
So here is my question, how can I include in my template a check that if any sensor is unavailable it should be 0 ?
Is there a better way to do what I am doing?