Last active
March 25, 2020 10:14
-
-
Save nilrog/86e9ac714052e993ab5df78bcd782573 to your computer and use it in GitHub Desktop.
A package file for HA with all sensors I have for displaying stuff in lovelace
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
sensor: | |
# inverter sensor | |
- platform: fronius_inverter | |
name: Fronius | |
ip_address: !secret fronius_host | |
scan_interval: 30 | |
powerflow: true | |
smartmeter: true | |
units: 'kWh' | |
power_units: 'W' | |
- platform: template | |
sensors: | |
# convert house load to positive | |
current_consumed_positive: | |
friendly_name: 'Förbrukad effekt' | |
unit_of_measurement: 'W' | |
value_template: '{{ states("sensor.fronius_house_load") | float * -1 }}' | |
# consumed from grid (positive) | |
current_consumed_grid: | |
friendly_name: 'Köpt effekt' | |
unit_of_measurement: 'W' | |
value_template: > | |
{% if states("sensor.fronius_grid_usage") | float > 0 -%} | |
{{ states("sensor.fronius_grid_usage") | float }} | |
{%- else -%} | |
{{ 0 | float }} | |
{%- endif %} | |
# sold to grid | |
current_sold_grid: | |
friendly_name: 'Såld effekt' | |
unit_of_measurement: 'W' | |
value_template: > | |
{% if states("sensor.fronius_grid_usage") | float < 0 -%} | |
{{ states("sensor.fronius_grid_usage") | float * -1 }} | |
{%- else -%} | |
{{ 0 | float }} | |
{%- endif %} | |
# solar panel utilization | |
solar_panel_utilization: | |
friendly_name: 'Utnyttjandegrad' | |
unit_of_measurement: '%' | |
value_template: > | |
{{ (states("sensor.fronius_panel_status") | float / 18000) | round(1) }} | |
# convert house power consumption to energy | |
- platform: integration | |
source: sensor.current_consumed_positive | |
name: energy_used_hour | |
unit_prefix: k | |
unit_time: h | |
round: 2 | |
method: left | |
# convert consumed grid power to energy | |
- platform: integration | |
source: sensor.current_consumed_grid | |
name: energy_grid_consumed_hour | |
unit_prefix: k | |
unit_time: h | |
round: 2 | |
method: left | |
# convert sold grid power to energy | |
- platform: integration | |
source: sensor.current_sold_grid | |
name: energy_grid_sold_hour | |
unit_prefix: k | |
unit_time: h | |
round: 2 | |
method: left | |
# convert net grid power to energy (difference between consumed and sold) | |
- platform: integration | |
source: sensor.fronius_grid_usage | |
name: energy_grid_net_hour | |
unit_prefix: k | |
unit_time: h | |
round: 2 | |
method: left | |
# convert panel power to energy (needed for monthly calculations) | |
- platform: integration | |
source: sensor.fronius_panel_status | |
name: energy_panel_hour | |
unit_prefix: k | |
unit_time: h | |
round: 2 | |
method: left | |
- platform: command_line | |
name: "Download Solar Panel Production Graph" | |
command: !secret solarpanel_prod_image | |
- platform: command_line | |
name: "Download Energy Consumption Week Graph" | |
command: !secret solarpanel_consumption_week_image | |
- platform: influxdb | |
host: !secret influxdb_host | |
username: !secret influxdb_user | |
password: !secret influxdb_pass | |
queries: | |
# max effekt från panelerna i dag (00:00 - 23:59) | |
- name: Fronius Panel Status Max Day | |
database: home_assistant | |
unit_of_measurement: 'W' | |
value_template: '{{ value | round(0) }}' | |
group_function: max | |
where: '"entity_id" = ''fronius_panel_status'' and time > {{(as_timestamp(now()) - (now().hour * 3600) - (now().minute * 60) - (now().second)) | round(0)}}s' | |
field: value | |
measurement: 'W' | |
# max effekt från panelerna senaste 7 dagarna | |
- name: Fronius Panel Status Max Week | |
database: home_assistant | |
unit_of_measurement: 'W' | |
value_template: '{{ value | round(0) }}' | |
group_function: max | |
# todo: only query for 7 day values, not 168h back from now | |
where: '"entity_id" = ''fronius_panel_status'' and time > now() - 168h' | |
field: value | |
measurement: 'W' | |
# max effekt sedan panelerna installerades | |
- name: Fronius Panel Status Max Ever | |
database: home_assistant | |
unit_of_measurement: 'W' | |
value_template: '{{ value | round(0) }}' | |
group_function: max | |
where: '"entity_id" = ''fronius_panel_status'' and time > ''2019-11-01''' | |
field: value | |
measurement: 'W' | |
### binary sensors | |
binary_sensor: | |
- platform: tod | |
name: Night | |
after: sunset | |
before: sunrise | |
### enery calculations | |
utility_meter: | |
### daily data ### | |
# calculate daily energy used | |
house_energy_day: | |
source: sensor.energy_used_hour | |
cycle: daily | |
# calculate daily energy consumed from grid | |
grid_consumed_energy_day: | |
source: sensor.fronius_smartmeter_energy_ac_consumed | |
cycle: daily | |
# calculate daily energy sold to grid | |
grid_sold_energy_day: | |
source: sensor.fronius_smartmeter_energy_ac_sold | |
cycle: daily | |
### monthly data ### | |
# calculate monthly energy used | |
house_energy_month: | |
source: sensor.energy_used_hour | |
cycle: monthly | |
# calculate monthly energy consumed from grid | |
grid_consumed_energy_month: | |
source: sensor.fronius_smartmeter_energy_ac_consumed | |
cycle: monthly | |
# calculate monthly energy sold to grid | |
grid_sold_energy_month: | |
source: sensor.fronius_smartmeter_energy_ac_sold | |
cycle: monthly | |
# calculate monthly panel production since that is not available from the inverter | |
fronius_month_energy: | |
source: sensor.energy_panel_hour | |
cycle: monthly | |
### yearly data ### | |
# calculate yearly energy used | |
house_energy_year: | |
source: sensor.energy_used_hour | |
cycle: yearly | |
# calculate yearly energy consumed from grid | |
grid_consumed_energy_year: | |
source: sensor.fronius_smartmeter_energy_ac_consumed | |
cycle: yearly | |
# calculate yearly energy sold to grid | |
grid_sold_energy_year: | |
source: sensor.fronius_smartmeter_energy_ac_sold | |
cycle: yearly |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment