RichardHA

Energy template Sarah Jo Davon

May 12th, 2022 (edited)
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. sensor:
  2.   - platform: template
  3.     sensors:
  4.      # sensor used to show power flow from Panels to Grid, but shows a negative at night
  5.       template_grid_feed_in:
  6.         friendly_name: "Solar 2 Grid"
  7.         unit_of_measurement: "W"
  8.         device_class: power
  9.         value_template: >
  10.          {% if states('sensor.grid_active_power') | int > 0 %}
  11.             {{ states('sensor.grid_active_power') }}
  12.           {% else -%}
  13.             0
  14.           {% endif %}
  15.  
  16.       # sensor used to show power flow from Panels to Grid and doesn't allow it to show a negative number only positive numbers
  17.       template_grid_consumption:
  18.         friendly_name: "Grid 2 House"
  19.         unit_of_measurement: "W"
  20.         device_class: power
  21.         value_template: >
  22.          {% if states('sensor.grid_active_power') | int > 0 %}
  23.             0
  24.           {% else -%}
  25.             {{ (states('sensor.grid_active_power') | int) | abs }}
  26.           {% endif %}
  27.  
  28.       # shows the solar power being fed to the house and doesn't allow it to show a negative number only positive numbers
  29.       template_curent_solar_consumption:
  30.         friendly_name: "Verbruik in huis live"
  31.         unit_of_measurement: "W"
  32.         device_class: power
  33.         value_template: >-
  34.           {% if states('sensor.template_grid_consumption') | float(default=0) > 0 %}
  35.             {{ states('sensor.active_power') }}
  36.           {% else -%}
  37.             {{ states('sensor.active_power')| float(default=0) - states('sensor.template_grid_feed_in')| float(default=0) }}
  38.           {% endif %}
  39.          
  40.       # Totaal verbruik per dag
  41.       template_totaal_verbruik_dag:    
  42.         friendly_name: "Totaal verbruik per dag"
  43.         unit_of_measurement: "kW"
  44.         device_class: energy
  45.         value_template: "{{ states('sensor.daily_yield')| float(default=0) - states('grid_export_solar_daily_energy')| float(default=0) + states('grid_import_solar_daily_energy')| float(default=0) }}"
  46.  
  47. utility_meter:
  48.   grid_import_solar_daily_energy:
  49.     source: sensor.grid_consumption
  50.     cycle: daily
  51.   grid_export_solar_daily_energy:
  52.     source: sensor.grid_exported
  53.     cycle: daily
  54.  
Add Comment
Please, Sign In to add comment