- sensor: - name: "power_other" unit_of_measurement: "W" icon: mdi:flash state: > {% set total = states('sensor.netzleistung') | float %} {% set solar = states('sensor.balkonkraftwerk_power') | float %} {% set raumduft = states('sensor.flur_raumduft_power') | float %} {% set keller = states('sensor.keller_power') | float %} {% set anrichte = states('sensor.kuche_anrichte_power') | float %} {% set musik = states('sensor.kuche_musik_power') | float %} {% set bett = states('sensor.schlafzimmer_bett_power') | float %} {% set heimkino_sz = states('sensor.schlafzimmer_heimkino_power') | float %} {% set deko = states('sensor.schreibtisch_deko_power') | float %} {% set schreibtisch = states('sensor.schreibtisch_power') | float %} {% set serverraum = states('sensor.serverraum_power') | float %} {% set heimkino_wz = states('sensor.wohnzimmer_heimkino_power') | float %} {% set spieleschrank = states('sensor.wohnzimmer_spieleschrank_power') | float %} {{ (total + solar - raumduft - keller - musik - bett - heimkino_sz - deko - schreibtisch - serverraum - heimkino_wz - spieleschrank) | round(1) }} device_class: power state_class: measurement attributes: last_reset: '1970-01-01T00:00:00+00:00' # Shelly 3EM cumulative sensors (incl. PV) - sensor: # Template sensor for values of power import (active_power > 0) - name: power_import unit_of_measurement: 'W' state: > {% if (states('sensor.line_power_channel_a_power')|float + states('sensor.line_power_channel_b_power')|float + states('sensor.line_power_channel_c_power')|float) > 0 %} {{ states('sensor.line_power_channel_a_power')|float + states('sensor.line_power_channel_b_power')|float + states('sensor.line_power_channel_c_power')|float }} {% else %} {{ 0 }} {% endif %} device_class: power state_class: measurement icon: mdi:transmission-tower-export attributes: last_reset: '1970-01-01T00:00:00+00:00' # Template sensor for values of power export (active_power < 0) - name: power_export unit_of_measurement: 'W' state: > {% if (states('sensor.line_power_channel_a_power')|float + states('sensor.line_power_channel_b_power')|float + states('sensor.line_power_channel_c_power')|float) < 0 %} {{ (states('sensor.line_power_channel_a_power')|float + states('sensor.line_power_channel_b_power')|float + states('sensor.line_power_channel_c_power')|float) * -1 }} {% else %} {{ 0 }} {% endif %} device_class: power state_class: measurement icon: mdi:transmission-tower-import attributes: last_reset: '1970-01-01T00:00:00+00:00' # Template sensor for values of power consumption - name: power_consumption unit_of_measurement: 'W' state: > {% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.balkonkraftwerk_power')|float(0) - states('sensor.power_export')|float(0)) < 0 %} {% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.balkonkraftwerk_power')|float(0) - states('sensor.power_export')|float(0)) > 0 %} {{ (states('sensor.balkonkraftwerk_power')|float(0)) - states('sensor.power_export')|float(0) }} {% else %} {{ states('sensor.power_import')|float(0) + states('sensor.balkonkraftwerk_power')|float(0) }} {% endif %} device_class: power state_class: measurement icon: mdi:home-lightning-bolt attributes: last_reset: '1970-01-01T00:00:00+00:00'