Home Assistant and Solar panel dashboards

I have had my solar panels now for one year. I have posted some reflections about this before. When I started to do this there were no Fronius integration in HACS but since then it is. I would really recommend you to use this. Especially if you have a smartmeter installed. You will get tons of info. I have Fronius but you might have another brand like Ferroamp. I think you will still be able to use some of the info below. The sensors might not be the same but still you can get some inspiration about Lovelace cards. So let´s get started.

First of all I would like to thank Nilrog who has given me a lot of inspiration and made most sensors work the way I want them. There is a discussion going on here at the Home Assistant Community about Fronius. Read it. I have tried to make this post a little bit more simple so beginners can make Dashboards as well.

Prerequirements

Hardware
Fronius Inverter and smartmeter (optional but nice)
Raspberry PI for Home Assistant (or any other server)

Software
Home Assistant
HACS (you will install all of the below from HACS)

Integrations
Fronius component

Lovelace cards
Barcard
Bignumber card
Mini graph card
Piechart card
Power Wheel card
Synthwave Theme
Card mod
Auto-entities

You will need this as the 80s has the best colors for your Lovelace. It looks great.

I won’t go through all the steps how to setup Home Assistant. There are so many good guides so just use the setup instructions on the official site.

HACS

What is Hacs? It is a repository or a marketplace to install all kind of things.  Integrations, themes or cards. It will make everything so much easier. To install HACS or Home Assistant Community Store you will need.

  • Home Assistant version 0.98.0 or higher.
  • GitHub account

Download the latest HACS release file from  here
Extract it into custom_components/hacs inside your Home Assistant configuration folder
To enable Themes in HACS  add the following to your configuration.yaml

  themes: !include_dir_merge_named themes

Restart Home Assistant

Hacs should now be visible for you.

So lets install all of the integrations, plugins and themes above. Search for them and press install like in the image below.

Notice that you will have to press “add to lovelace” so that the components are added to the configuration. Since 0.107 or something they have been moved so you can see them if you press configuration->Lovelace dashboards and resources. After you have added them you can verify that they exists here.

Configure the Fronius component.

You will need to add this to your configuration.yaml. In my case I have it my sensors.yaml. Notice that yours might be different. Read the manual at the repository for the Fronius integration. Restart Home Assistant.

- platform: fronius_inverter
ip_address: YOURIP
powerflow: true
units: kWh
power_units: W
smartmeter: true
smartmeter_device_id: 0

I did create a separate dashboard in configuration -> lovelace dashboards and called i lab. I put all my non finished testcards here and eventually moved them to a solar overview view when I was happy with them.

First we start off with the new installed auto-entities card. We do this because when you installed the Fronius component you did get a lot of new sensors. It might be easy to miss any of theese so we just want to see all the sensors we have about Fronius. Create a manual card like this. Press the plus icon and choose manual. Paste the code.

card:
show_header_toggle: false
title: Fronius
type: entities
filter:
include:
- entity_id: '*fronius*'
type: 'custom:auto-entities'

The card might look something like this but more entities.

 

What we will use

When you install the Fronius integration you will get a lot of sensors. They are read directly from the inverter and smartmeter via API calls. However there might other data you want that do not exists here that we will need to use Home Assistant for. We will use the platforms or integrations below to create som more sensors.

Influx – To download historic data from your Influx database. If you are using Influx?

Template – To calculate some sensors

Utility meter – To schedule daily, monthly and yearly data. The utility meter is far from perfect but might be nice to have.

Integration  – To convert

Templates

The two templates below might not be perfect and accurate but will give you some indication and can be fun to have. The first will calculate the amount of energy in kWh your solar panels have produced and take this time the amount of money you normally pay for each kWh.  You might pay different depending of the time of the day or you might get more money for selling and in this case use an average value you think is correct.

The second one takes the energy sold today (a utility meter from the sensor sensor.fronius_smartmeter_energy_ac_sold) and multiples with what you get payed and returns the amount of money you have sold for today. You could replace the * 0.9 with a sensor from example Tibber accrual price if the price varies during the day.

- platform: template
sensors:
time_until_payed:
value_template: '{{ ((states.sensor.fronius_total_energy.state | float * 0.9 - REPLACEWITHWHATYOUPAYED)) | round(0) }}'
friendly_name: 'Time until payed'
unit_of_measurement: 'kr'

today_sold_energy_in_sek:
value_template: '{{ ((states.sensor.grid_sold_energy_day.state | float * 0.9 )) | round(0) }}'
friendly_name: 'Sold energy today'
unit_of_measurement: 'kr'

I will add some more Lovelacecards later with the second sensor but with the first we can create one using the barcard we installed earlier.

 
      time_until_payed:
        value_template: '{{ ((states.sensor.fronius_total_energy.state | float * 0.9 - 180000)) | round(0) }}'
        friendly_name: 'Kvar till avbetalt'
        unit_of_measurement: 'kr'
 

It will look something like this.

The smartmeter and sensor house load below is negative when you buy energy and positive when you export energy. It will be hard to use this in Home Assistant. So we use the template to convert and get a sensor that is always positive. We will use this later on.


# 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 }}'

We want to calculate what we sell to the grid.

# sold to grid
current_sold_grid:
friendly_name: 'Sold effect'
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 %}

I also want to know how much we use the solar panels in percent. We do this by taking the panel status and divide this by the max effect of our installation. Mine is 13.3 kW

# solar panel utilization
solar_panel_utilization:
friendly_name: 'Usage of panels in percent'
unit_of_measurement: '%'
value_template: >
{{ (states("sensor.fronius_panel_status") | float * 100 / 13300) | round(1) }}

Integrations

The integrations below converts from used to hour. We will use them later in the utility sensor. And as you might see some sensors are still missing. We will add them later on as utility sensors. There is some documentation about this here. I had some hard times understanding why this sensor was giving me strange values. It turned out that I had to recreate the sensor as the old one was storing some data. Even if I removed it and created it again the old values appeared again.


# 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

Converts consumed grid power to energy. How many W you are using from the grid converted to kWh per hour. The source is the Fronius grid usage.

# convert consumed grid power to energy
- platform: integration
source: sensor.fronius_grid_usage
name: energy_grid_consumed_hour
unit_prefix: k
unit_time: h
round: 2
method: left

And how much have you sold the last hour. This takes the source from the template sensor.


# 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

Utility Meters

Utility meters can be used to track consumptions over time. It can be quite handy. There are some issues when something goes wrong. You might have to clear the sensor and reset it sometimes. If you have a meter that is for example yearly you might have to wait one year in order to get it right. The meters below was made by Nilrog and I have just used them in my setup. Just add them like this in your configuration.yaml. They will be used for the other integration sensors above as well to create some Lovelace cards later.


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

Influx

If you are storing your data to an influx database you can query it via Home Assistant. Setting up Influx is not very hard. There are guides how to do this. Add the code below to your configuration.yaml


- platform: influxdb
host: !secret influxdb_host
username: !secret influxdb_user
password: !secret influxdb_pass

As well as this.
queries:
# max effect from the panels today (00:00 - 23:59)
    - name: Fronius Panel Status Max Day
      database: home
      unit_of_measurement: 'W'
      value_template: '{{ value | round(0) }}'
      group_function: max
      where: '"entity_id" = ''fronius_panel_status'' > {{(as_timestamp(now()) - (now().hour * 3600) - (now().minute * 60) - (now().second)) | round(0)}}s'
      field: value
      measurement: 'W'
    # max effect from panels the latest 7 days
    - name: Fronius Panel Status Max Week
      database: home
      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 effect since panels was installed
    - name: Fronius Panel Status Max Ever
      database: home
      unit_of_measurement: 'W'
      value_template: '{{ value | round(0) }}'
      group_function: max
      where: '"entity_id" = ''fronius_panel_status'' and time > ''2019-03-01'''
      field: value
      measurement: 'W'

Ok, We are done setting up all the sensors and other stuff. Restart Home Assistant. Check the Auto-entities card you created in the lab dashboard.
Many new sensors should be there now. You might want to add another basic card just checking that the other sensors works as well. You may want to
log in to solar.webb and make sure you get the same info in Home Assistant that you get there. It could be information like daily consumption and usage.

Dashboards and Lovelace cards

Now we can start to add some cards. We have already added one. The time until payed. So let’s go crazy

Powerwheel card

This card will create a nice overview of your production and consumption. The exaple blow is quite simple but the card offers many other settings. Jsut paste the below code in a manual card.

grid_icon: 'mdi:flash'
grid_power_entity: sensor.fronius_grid_usage
home_energy_entity: sensor.fronius_house_load
production_is_positive: false
solar_icon: 'mdi:white-balance-sunny'
solar_power_entity: sensor.fronius_panel_status
title: Solar Power
type: 'custom:power-wheel-card'

Big number card

This card can be used in many different ways. With a bar like below or just a number. Or with severity colors. I wanted a card showing the most important things like Solar production, House load and solar today. This was placed in a vertical stack card.

cards:
- entity: sensor.fronius_panel_status
from: left
max: 15300
min: 0
scale: 30px
severity:
- style: '#ffcc00'
value: 0
- style: '#ff1155'
value: 4000
- style: '#ff0000'
value: 15300
title: Solar Power
type: 'custom:bignumber-card'
- entity: sensor.current_consumed_positive
from: left
max: 15000
min: 0
scale: 30px
severity:
- style: var(--label-badge-green)
value: 0
- style: var(--label-badge-yellow)
value: 3000
- style: var(--label-badge-red)
value: 15000
title: House load
type: 'custom:bignumber-card'
- entity: sensor.fronius_day_energy
from: left
max: 100
min: 0
scale: 30px
severity:
- style: var(--label-badge-red)
value: 5
- style: var(--label-badge-yellow)
value: 20
- style: var(--label-badge-green)
value: 80
title: Solar Today
type: 'custom:bignumber-card'
type: vertical-stack

Mini-graph & Bignumber

Bignumber card again. Together with the mini graph card. I made it pink to match the retrostyle of the synthwave theme. It is a lot of info here and I am not really sure I will use it like this. However it shows the potential.

The top bignumber code looks like this.

cards:
  - entity: sensor.house_energy_day
    scale: 25px
    style: |
      ha-card {
        background: {% if states('sensor.house_energy_day') | float < states('sensor.grid_sold_energy_day') | float %} #e929a5 {% else %} #00c800 {% endif %};
      }
    title: Usage Today
    type: 'custom:bignumber-card'
  - entity: sensor.fronius_day_energy
    scale: 25px
    style: |
      ha-card {
        background: {% if states('sensor.fronius_day_energy') | float > states('sensor.house_energy_day') | float %} #e929a5 {% else %} #00c800 {% endif %};
      }
    title: Produced today
    type: 'custom:bignumber-card'
  - entity: sensor.grid_consumed_energy_day
    scale: 25px
    style: |
      ha-card {
        background: {% if states('sensor.fronius_grid_usage') | float < 0 %} #e929a5 {% else %} #00c800 {% endif %};
      }
    title: Bought today
    type: 'custom:bignumber-card'
  - entity: sensor.grid_sold_energy_day
    scale: 25px
    style: |
      ha-card {
        background: {% if states('sensor.grid_sold_energy_day') | float > states('sensor.grid_consumed_energy_day') | float %} #e929a5 {% else %} #00c800 {% endif %};
      }
    title: Sold today
    type: 'custom:bignumber-card'
type: horizontal-stack

The minigraphcards looks like this in Lovelace.

cards:
  - decimals: 0
    entities:
      - color: '#00ff00'
        entity: sensor.fronius_panel_status
        name: Solarpanels
        show_points: false
        show_state: true
      - color: '#ff00cc'
        entity: sensor.current_consumed_positive
        name: House load
        show_points: false
        show_state: true
      - aggregate_func: min
        color: gray
        entity: binary_sensor.night
        name: Night
        show fill: true
        show legend: false
        show_line: false
        show_points: false
        show_state: false
        smoothing: false
        y_axis: secondary
    hour24: true
    hours_to_show: 72
    line_width: 1
    lower_bound_secondary: 0
    name: From solar panels
    points_per_hour: 12
    show:
      extrema: true
      labels: false
      labels_secondary: false
      smoothing: false
    state_map:
      - label: Day
        value: 'off'
      - label: Night
        value: 'on'
    type: 'custom:mini-graph-card'
    upper_bound_secondary: 1
  - color_thresholds:
      - color: '#ff0000'
        value: 0
      - color: '#00ff00'
        value: -20000
    color_thresholds_transition: hard
    decimals: 0
    entities:
      - entity: sensor.fronius_grid_usage
        color: '#ff00cc'
        name: Grid
        show_points: false
      - aggregate_func: min
        color: gray
        entity: binary_sensor.night
        name: Night
        show fill: true
        show legend: false
        show_line: false
        show_points: false
        show_state: true
        smoothing: false
        y_axis: secondary
    hour24: true
    hours_to_show: 72
    line_width: 1
    lower_bound_secondary: 0
    name: From grid
    points_per_hour: 12
    show:
      extrema: true
      labels: false
      labels_secondary: false
      smoothing: false
    state_map:
      - label: Day
        value: 'off'
      - label: Night
        value: 'on'
    type: 'custom:mini-graph-card'
    upper_bound_secondary: 1
type: horizontal-stack

Maybe you just wan something more simple? The minigraphcard below gives you the solar generation and the house consumption.

The code looks like this.

entities:
  - color: '#27ae60'
    entity: sensor.fronius_panel_status
    name: Solar Gen
  - color: '#e74c3c'
    entity: sensor.current_consumed_positive
    name: House Usage
    show_state: true
  - aggregate_func: min
    color: gray
    entity: binary_sensor.night
    name: Night Time
    show fill: true
    show legend: false
    show_line: false
    show_points: false
    show_state: true
    smoothing: false
    y_axis: secondary
hours_to_show: 3
name: Solar & Consumption
points_per_hour: 10
show:
  extrema: false
  labels: false
  labels_secondary: false
  smoothing: false
state_map:
  - label: Day
    value: 'off'
  - label: Night
    value: 'on'
type: 'custom:mini-graph-card'

Piechart

The pie chart might be good in some cases. This is most likely not a very good example.

The code looks like this.


entities:
- entity: sensor.fronius_panel_status
name: Solar panel status
title: Panel Status
unknownText: Out of 13.3kWp
total_amount: 13300
type: 'custom:pie-chart-card'

The final dashboard may look something like this. Some values are wrong, cards and Home Assistant gets updates that breaks your configuration.
Watts changes to kW and Kw changes to mW and this will make some of your sensors unusable. Consider the dashboard and cards as a complement to your other

I suppose this will never be finished…

5 2 votes
Article Rating
5
0
Would love your thoughts, please comment.x
()
x