-
-
Notifications
You must be signed in to change notification settings - Fork 89
Visualisations
Roving Ronin edited this page Feb 23, 2024
·
9 revisions
By using ApexCharts, you can create some fancy visualisations
Source:
type: custom:apexcharts-card
header:
show: true
title: Power
show_states: true
colorize_states: true
all_series_config:
type: area
opacity: 0.1
stroke_width: 1
group_by:
func: last
duration: 5m
series:
- entity: sensor.inverter_input_power
color: lightgreen
- entity: sensor.inverter_active_power
color: blue
- entity: sensor.battery_charge_discharge_power
name: Battery Charge
transform: return Math.max(0,x);
color: orange
- entity: sensor.battery_charge_discharge_power
name: Battery Discharge
color: '#800080'
transform: return -Math.min(0,x);
- entity: sensor.power_meter_active_power
name: Grid Export
transform: return Math.max(0,x);
color: lime
- entity: sensor.power_meter_active_power
name: Grid Import
color: red
transform: return -Math.min(0,x);
Source:
type: custom:apexcharts-card
header:
show: true
title: Battery Status
show_states: true
colorize_states: true
all_series_config:
type: area
opacity: 0.1
stroke_width: 1
group_by:
func: avg
duration: 15m
show:
in_header: false
series:
- entity: sensor.battery_state_of_capacity
type: line
yaxis_id: pct
opacity: 1
stroke_width: 3
group_by:
func: last
duration: 15m
show:
in_header: true
- entity: sensor.battery_charge_discharge_power
name: Battery Charge
transform: return Math.max(0,x);
color: darkgreen
yaxis_id: watts
- entity: sensor.battery_charge_discharge_power
name: Battery Discharge
color: '#800080'
transform: return -Math.min(0,x);
yaxis_id: watts
yaxis:
- id: pct
show: true
opposite: true
decimals: 0
max: 100
min: 15
- id: watts
show: true
decimals: 0
align_to: 250
Source:
Some extra template sensors are needed that compute the necessary values. The inverter efficiency is ignored, so they are not 100% accurate.
template:
- sensor:
- name: Grid to Battery
device_class: power
state_class: measurement
unit_of_measurement: W
state: >
{% set inv = states('sensor.inverter_active_power')|int(default=0) %}
{% if inv < 0 %} {{ 0 - inv | int }}
{% else %} 0
{% endif %}
- name: Grid to House
device_class: power
state_class: measurement
unit_of_measurement: W
state: >
{% set inv = states('sensor.inverter_active_power')|int(default=0) %}
{% set grid = states('sensor.power_meter_active_power')|int(default=0) %}
{% if grid < 0 %}
{% if inv < 0 %} {{ inv - grid | int }}
{% else %} {{ 0 - grid | int }}
{% endif %}
{% else %} 0
{% endif %}
- name: Solar to Battery
device_class: power
state_class: measurement
unit_of_measurement: W
state: >
{% set inv = states('sensor.inverter_input_power')|int(default=0) %}
{% set bat = states('sensor.battery_charge_discharge_power')|int(default=0) %}
{% set out = states('sensor.inverter_active_power')|int(default=0) %}
{% if bat > 0 %}
{% if out < 0 %} {{ inv }}
{% else %} {{ bat }}
{% endif %}
{% else %} 0
{% endif %}
- name: Solar to House
device_class: power
state_class: measurement
unit_of_measurement: W
state: >
{% set grid = states('sensor.power_meter_active_power')|int(default=0) %}
{% set out = states('sensor.inverter_active_power')|int(default=0) %}
{% set bat = states('sensor.battery_charge_discharge_power')|int(default=0) %}
{% if out > 0 %}
{% if grid > 0 %}
{% if bat > 0 %} {{ out - grid }}
{% else %} {{ out + bat - grid | abs }}
{% endif %}
{% else %}
{% if bat > 0 %} {{ out }}
{% else %} {{ out - bat | abs }}
{% endif %}
{% endif %}
{% else %} 0
{% endif %}
- name: Solar to Grid
device_class: power
state_class: measurement
unit_of_measurement: W
state: >
{% set grid = states('sensor.power_meter_active_power')|int(default=0) %}
{% set out = states('sensor.inverter_active_power')|int(default=0) %}
{% if out > 0 and grid > 0 %} {{ grid }}
{% else %} 0
{% endif %}
- name: Battery to Grid
device_class: power
state_class: measurement
unit_of_measurement: W
state: >
{% set inv = states('sensor.inverter_active_power')|int(default=0) %}
{% set bat = states('sensor.battery_charge_discharge_power')|int(default=0) %}
{% set grid = states('sensor.power_meter_active_power')|int(default=0) %}
{% if grid > 0 and bat < 0 and inv > grid %}
{% if grid - inv - bat >= 0 %} {{ grid - inv - bat }}
{% else %} 0
{% endif %}
{% else %} 0
{% endif %}
- name: Battery to House
device_class: power
state_class: measurement
unit_of_measurement: W
state: >
{% set bat = states('sensor.battery_charge_discharge_power')|int(default=0) %}
{% set togrid = states('sensor.battery_to_grid')|int(default=0) %}
{% if bat < 0 %} {{ togrid - bat | int }}
{% else %} 0
{% endif %}
With these extra template sensors, you can define the Tesla Style power card as follows:
- type: custom:tesla-style-solar-power-card
name: Energy Flows
grid_to_house_entity: sensor.grid_to_house
grid_to_battery_entity: sensor.grid_to_battery
generation_to_grid_entity: sensor.solar_to_grid
generation_to_battery_entity: sensor.solar_to_battery
generation_to_house_entity: sensor.solar_to_house
battery_to_house_entity: sensor.battery_to_house
battery_to_grid_entity: sensor.battery_to_grid
battery_extra_entity: sensor.battery_state_of_capacity
#grid_extra_entity: sensor.electricity_current_rate
#generation_entity: sensor.inverter_daily_yield
show_gap: true
threshold_in_k: 1
Source: Post by m4xg in the HA Community Thread
One extra template sensor is needed, of which the reasoning is described in a HA Community Forum post:
# Real house load
#
- name: house_consumption_power
unique_id: house_consumption_power
state_class: measurement
device_class: power
unit_of_measurement: "W"
icon: mdi:solar-power
state: >-
{% set inv_active_power = states('sensor.inverter_active_power')|float(0) %}
{% set pm_active_power = states('sensor.power_meter_active_power')|float(0) %}
{{ (inv_active_power - pm_active_power)|float(0)|round(0) }}
availability: >-
{{ (states('sensor.inverter_active_power')|is_number)
and (states('sensor.power_meter_active_power')|is_number) }}
With this extra sensor, you can define the Power Flow Plus Card as follows:
- type: custom:power-flow-card-plus
title: Power Flow - Now
min_flow_rate: 3
max_flow_rate: 10
watt_threshold: 7800
kw_decimals: 3
w_decimals: 0
clickable_entities: true
dashboard_link: /energy
entities:
home:
entity: sensor.house_consumption_power
solar:
entity: sensor.inverter_input_power
battery:
entity: sensor.battery_charge_discharge_power
state_of_charge: sensor.battery_state_of_capacity
color_circle: true
grid:
entity: sensor.power_meter_active_power
inverted_entities: grid,battery
Sources: Post 1 by heinemannj in the HA Community Thread and Post 2 by heinemannj in the HA Community Thread