##ARCHIVO AA_TEMPLATES.yaml - sensor: ## Sensor de autoconsumo. - name: autoconsumo_diario state_class: measurement unit_of_measurement: "kWh" state: > {% set energia_generada = states('sensor.energia_generada') | float %} {% set energia_exportada = states('sensor.energia_exportada_riemann_diario') | float %} {{ (energia_generada - energia_exportada) | round(1) }} ## SENSORES BÁSICOS DE FUNCIONAMIENTO PARA LAS GRÁFICAS DE PRODUCCIÓN ## # Sensor de la red electrica fija, puede ser numero negativo al exportar o positivo al consumir energia. - name: powen_red_entidad device_class: power state_class: measurement unit_of_measurement: "W" state: "{{ (states('sensor.luz_exterior_power_corregido')|float(0)*1)|int(0) }}" # Este sensor siempre debe ser 0 o positivo, indica el consumo de energía en casa. Es la suma de la potencia solar más la potencia luz (negativo o positivo). - name: powen_carga_casa device_class: power state_class: measurement unit_of_measurement: "W" state: > {% if states('sensor.solar_power_2')|float(default=0) > 0 %} {% set potencia_solar = states('sensor.solar_power_2') | float(default=0) %} {% set potencia_luz = states('sensor.luz_exterior_power_corregido') | float(default=0) %} {{ (potencia_luz+potencia_solar) }} {% else %} {% set potencia_solar = 0 %} {% set potencia_luz = states('sensor.luz_exterior_power_corregido') | float(default=0) %} {{ (potencia_luz+potencia_solar) }} {% endif %} # Este sensor siempre es 0 o positivo, es el sensor de la potencia de las placas solares. - name: powen_generacion_solar device_class: power state_class: measurement unit_of_measurement: "W" state: > {% if states('sensor.solar_power_2')|float(default=0) > 0 %} {{ states('sensor.solar_power_2')|float(default=0) | round(1) }} {% else %} 0 {% endif %} # Este sensor siempre es 0 o positivo, es el sensor de la potencia real de la casa + lo que gasta el inversor si es que se controlase. - name: powen_carga_real_casa device_class: power state_class: measurement unit_of_measurement: "W" state: "{{ states('sensor.powen_carga_casa')|int(default=0) }}" icon: mdi:home-lightning-bolt ## OTROS SENSORES PARA LOS GRAFICOS MODO TESLA ## - name: powen_red2casa device_class: power state_class: measurement unit_of_measurement: "W" state: > {% if states('sensor.powen_red_entidad')|int(default=0) > 0 %} {{ states('sensor.powen_red_entidad')|int(default=0)|abs }} {% else %} 0 {% endif %} - name: powen_solar2red device_class: power state_class: measurement unit_of_measurement: "W" state: > {% if states('sensor.powen_red_entidad')|int(default=0) < 0 %} {{ states('sensor.powen_red_entidad')|int(default=0)|abs }} {% else %} 0 {% endif %} - name: powen_solar2casa device_class: power state_class: measurement unit_of_measurement: "W" state: > {{ states('sensor.powen_carga_real_casa')|int(default=0) - states('sensor.powen_red2casa')|int(default=0) }} ########### FIN ############# ## CORRECION DE LA DESVIACION DE LA IMPORTACION Y EXPORTACION DE ENERGIA - name: luz_exterior_importacion_corregido device_class: power state_class: measurement unit_of_measurement: "W" state: > {% if states('sensor.luz_exterior_power_2')|float(default=0) > 0 %} {% set potencia_luz = states('sensor.luz_exterior_power_2') | float(default=0) %} {{ (potencia_luz*1.03) }} {% else %} {% set potencia_luz = 0 | float(default=0) %} {{ (potencia_luz) }} {% endif %} - name: luz_exterior_exportacion_corregido device_class: power state_class: measurement unit_of_measurement: "W" state: > {% if states('sensor.luz_exterior_power_2')|float(default=0) < 0 %} {% set potencia_luz = states('sensor.luz_exterior_power_2') | float(default=0) | abs %} {{ (potencia_luz*0.98) }} {% else %} {% set potencia_luz = 0 | float %} {{ (potencia_luz) }} {% endif %} - name: luz_exterior_power_corregido device_class: power state_class: measurement unit_of_measurement: "W" state: > {% if states('sensor.luz_exterior_power_2')|float(default=0) > 0 %} {% set potencia_luz = states('sensor.luz_exterior_power_2') | float(default=0) %} {{ (potencia_luz*1.03) | round(1) }} {% else %} {% set potencia_luz = states('sensor.luz_exterior_power_2') | float(default=0) %} {{ (potencia_luz*0.98) | round(1) }} {% endif %} ##