Created
March 27, 2023 16:34
-
-
Save ondrejbartas/f328f7cef5312754d78b56a9e34f7ffe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template: | |
- sensor: | |
- name: "Solarman PV Power" | |
unit_of_measurement: "W" | |
state: > | |
{{ states('sensor.solarman_pv1_power') | float + states('sensor.solarman_pv2_power') | float }} | |
- name: "Solarman Battery discharge" | |
unit_of_measurement: "W" | |
state: > | |
{% set batter_cons = states('sensor.solarman_battery_power') | int %} | |
{% if batter_cons > 0 %} | |
{{ batter_cons | int }} | |
{% else %} | |
0 | |
{% endif %} | |
- name: "Solarman Battery charge" | |
unit_of_measurement: "W" | |
state: > | |
{% set batter_cons = states('sensor.solarman_battery_power') | int %} | |
{% if batter_cons < 0 %} | |
{{ batter_cons | int * -1 }} | |
{% else %} | |
0 | |
{% endif %} | |
- name: "Solarman graph generation to battery" | |
unit_of_measurement: "W" | |
state: > | |
{% set pv_power = states('sensor.solarman_pv_power') | int %} | |
{% set batter_cons = states('sensor.solarman_battery_power') | int %} | |
{% if batter_cons < 0 %} | |
{% if pv_power < (batter_cons * -1) %} | |
{{ pv_power }} | |
{% else %} | |
{{ batter_cons | int * -1 }} | |
{% endif %} | |
{% else %} | |
0 | |
{% endif %} | |
- name: "Solarman graph grid to battery" | |
unit_of_measurement: "W" | |
state: > | |
{% set batter_cons = states('sensor.solarman_battery_power') | int %} | |
{% set batter_pv_cons = states('sensor.solarman_graph_generation_to_battery') | int %} | |
{% if batter_cons < 0 %} | |
{{ (batter_cons * -1) - batter_pv_cons }} | |
{% else %} | |
0 | |
{% endif %} | |
- name: "Solarman graph generation to house" | |
unit_of_measurement: "W" | |
state: > | |
{% set pv_power = states('sensor.solarman_pv_power') | int %} | |
{% set load = states('sensor.solarman_total_load_power') | int %} | |
{% if load > pv_power %} | |
{{ pv_power | int }} | |
{% elif pv_power > load %} | |
{{ load }} | |
{% else %} | |
0 | |
{% endif %} | |
- name: "Solarman Gridd buy" | |
unit_of_measurement: "W" | |
state: > | |
{% set batter_cons = states('sensor.solarman_total_grid_power') | int %} | |
{% if batter_cons > 0 %} | |
{{ batter_cons | int }} | |
{% else %} | |
0 | |
{% endif %} | |
- name: "Solarman Grid sell power" | |
unit_of_measurement: "W" | |
state: > | |
{% set grid = states('sensor.solarman_total_grid_power') | int %} | |
{% set pv_power = states('sensor.solarman_pv_power') | int %} | |
{% if grid < 0 and pv_power > 0 %} | |
{{ grid | int * -1 }} | |
{% else %} | |
0 | |
{% endif %} | |
- name: "Solarman Grid buy power" | |
unit_of_measurement: "W" | |
state: > | |
{% set grid = states('sensor.solarman_total_grid_power') | int %} | |
{% if grid > 0 %} | |
{{ grid | int }} | |
{% else %} | |
0 | |
{% endif %} | |
- name: "Solarman Grid to house buy power" | |
unit_of_measurement: "W" | |
state: > | |
{% set grid = states('sensor.solarman_total_grid_power') | int %} | |
{% set battery_from_grid = states('sensor.solarman_graph_grid_to_battery') | int %} | |
{% if grid > 0 %} | |
{{ grid - battery_from_grid }} | |
{% else %} | |
0 | |
{% endif %} | |
- name: "Solarman Inverter Power" | |
unit_of_measurement: "W" | |
state: > | |
{% set pv = states('sensor.solarman_pv_power') | int %} | |
{% set load = states('sensor.solarman_total_load_power') | int %} | |
{% set battery = states('sensor.solarman_battery_power') | int %} | |
{% set grid = states('sensor.solarman_total_grid_power') | int %} | |
{{ (pv+battery+grid) - load }} | |
- name: "Solarman Battery discharge to house" | |
unit_of_measurement: "W" | |
state: > | |
{% set batter_cons = states('sensor.solarman_battery_power') | int %} | |
{% set pv_power = states('sensor.solarman_pv_power') | int %} | |
{% set grid = states('sensor.solarman_total_grid_power') | int %} | |
{% if batter_cons > 0 %} | |
{% if pv_power == 0 and grid < 0 %} | |
{{ batter_cons - (grid * -1) | int}} | |
{% else %} | |
{{ batter_cons | int }} | |
{% endif %} | |
{% else %} | |
0 | |
{% endif %} | |
- name: "Solarman Battery discharge to grid" | |
unit_of_measurement: "W" | |
state: > | |
{% set batter_cons = states('sensor.solarman_battery_power') | int %} | |
{% set pv_power = states('sensor.solarman_pv_power') | int %} | |
{% set grid = states('sensor.solarman_total_grid_power') | int %} | |
{% if batter_cons > 0 and pv_power == 0 and grid < 0 %} | |
{{ grid * -1 | int}} | |
{% else %} | |
0 | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment