Skip to content

Commit 8104cd6

Browse files
TypQxQpurcell-labBrendanAnnablelawther
authored
v.1.1.11 (#277)
* Modify is_on_fn to check for non-zero power (#251) Updated is_on_fn to check for non-zero output power, reflecting both charging and discharging states. Fixes #250 * Enable plant rated sensors by default (#219) * simple comment typo fix (#216) * swap import and export icons (#212) These icons are designed from the perspective of the grid. "tower-import" means the grid is importing power. From the SigenStor perspective, this is when the SigenStor is sending/exporting power to the grid. So when the local system is 'exporting', we need to use the 'tower-import' icon. And vice versa for importing. * Swap import/export icons and update sensor icons Swap transmission-tower import/export icons for grid and PCS entities; replace several transmission-tower-export icons with generator-stationary and ev-station for clearer sensor representation. * README: separate copyright from license link and add Step-by-step guide link * Dashboards: add Nordpool energy chart card, README and example image - Add card_nordpool_energy_chart.yaml: configurable Lovelace chart (custom:config-template-card + custom:apexcharts-card) - Displays today/tomorrow Nordpool prices, grid import and battery SOC - Dynamic price calculations, color thresholds, formatted axes and grouping - Add README with installation, configuration and disable instructions - Add example screenshot HA_energy_chart.jpg * Dashboards: nordpool energy chart - use filtered plant sensors, update cost calc, fix graph span and formatting - Switch to plant-filtered sensors for grid import and battery SOC - Replace simple cost template with expanded additional_cost_template - Add update_interval and correct graph_span calculation (divide by 4) - Normalize quoting and color string styles for consistency - Minor formatting tweaks (offset quoting, newline at EOF) * Dashboards: add Energy Flow dashboard (yaml + preview image) and update README add-ons links - Add Dashboards/energy_flow_gauge/energy_flow.yaml (new Energy Flow dashboard with multiple apexcharts gauges) - Add Dashboards/energy_flow_gauge/energy_flow.jpg (dashboard preview image) - Update README: add links for Energy Flow Dashboard and Nordpool custom prices; rename Si-GCG link to "Add-ons & tools by Si-GCG" * Dashboards: add Energy Flow dashboard README and update main README link * README: add Step-by-step guide link to Add-ons section * Fix typo (#213) * Bump version to 1.1.11 in manifest.json --------- Co-authored-by: Mark Purcell <[email protected]> Co-authored-by: Brendan Annable <[email protected]> Co-authored-by: lawther <[email protected]>
1 parent 66f8938 commit 8104cd6

File tree

13 files changed

+2979
-26
lines changed

13 files changed

+2979
-26
lines changed
60.3 KB
Loading

Dashboards/energy_flow_gauge/energy_flow.yaml

Lines changed: 2564 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Energy flow gauge displaying energy consumption and generation.
2+
3+
This is a set of gauges displaying energy flow from grid, solar and battery.
4+
5+
![alt text](energy_flow.jpg)
6+
7+
# Pre-requirements
8+
9+
This has not been tested on HA earlier than 2024.9 and requires the following HACS addons:
10+
11+
- Apex-Charts card
12+
- Config Template Card Card - For scripting inside the chart card.
13+
- lovelace-card-mod - For styling.
14+
- bar-card
15+
16+
The sensor names needs to be changed to suit your system.
17+
18+
# Installation
19+
- Copy - paste the raw card code from `energy_flow.yaml` to your a new card on you lovelace dashboard. Add any card and replace the raw code that you can edit by clicking on the *SHOW CODE EDITOR* in the bottom left.
20+
21+
22+
# Configuration
23+
24+
In the chart-card you should change the following variables to suit your needs:
25+
26+
- Check so the sensor names are correct.
147 KB
Loading
Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
# This code should be copy-pasted into a lovelace card.
2+
# Requires the custom:config-template-card, custom:apexcharts-card, custom:nordpool-card and custom:congif-template-card to be installed.
3+
4+
type: custom:config-template-card
5+
update_interval: 60s
6+
variables:
7+
nordpool_sensor: "'sensor.nordpool'"
8+
grid_import_sensor: "'sensor.sigen_plant_filtered_daily_grid_import_energy'"
9+
battery_soc_sensor: "'sensor.sigen_plant_filtered_battery_charge'"
10+
additional_cost_template: "'*1.25 +(27.2 + 42.8 + 3.04 + 2.19 + 1.4) *1.25'"
11+
decimals_in_prices: 0
12+
decimals_in_energy: 1
13+
chart_price_cutoff_coerficient: 0.1
14+
price_y_axis_unit: "'öre'"
15+
energy_y_axis_unit: "'kWh'"
16+
price_overview_unit: "'öre/kWh'"
17+
chart_title: "'Electricity prices today'"
18+
total_purchease_price_text: "'Total purchease price'"
19+
grid_import_text: "'Grid Import today'"
20+
battery_soc_text: "'Battery charge'"
21+
lowest_price_text: "'Lowest future price'"
22+
highest_price_text: "'Highest future price'"
23+
price_now_text: "'Current price'"
24+
now_text: "''"
25+
get_chart_cutoff: |
26+
(_min_price, _max_price, _coefficient) => {
27+
if (_min_price <= 0) {
28+
return "auto";
29+
}
30+
return _min_price - ((_max_price-_min_price) * _coefficient)
31+
}
32+
get_total_max_nordpool_price: |
33+
(_nordpool_sensor, _additional_cost_template) => {
34+
return states[_nordpool_sensor].attributes.raw_today.concat(states[_nordpool_sensor].attributes.raw_tomorrow).map(data=> eval("data.value"+_additional_cost_template)).reduce((a, b) => Math.max(a, b), -Infinity)
35+
}
36+
get_total_min_nordpool_price: |
37+
(_nordpool_sensor, _additional_cost_template) => {
38+
return states[_nordpool_sensor].attributes.raw_today.concat(states[_nordpool_sensor].attributes.raw_tomorrow).map(data=> eval("data.value"+_additional_cost_template)).reduce((a, b) => Math.min(a, b), Infinity)
39+
}
40+
get_low_bottom_threshold_nordpool_price: |
41+
(_min, _max) => {
42+
return parseFloat(_min) + parseFloat(((_max) - parseFloat(_max)) /10)
43+
}
44+
get_low_threshold_nordpool_price: |
45+
(_min, _max) => {
46+
return parseFloat(_min) + parseFloat(((_max) - parseFloat(_min)) /3)
47+
}
48+
get_high_threshold_nordpool_price: |
49+
(_min, _max) => {
50+
return parseFloat(_min)
51+
+ (( parseFloat(_max) - parseFloat(_min) ) /3) * 2
52+
}
53+
get_high_top_threshold_nordpool_price: |
54+
(_min, _max) => {
55+
return parseFloat(_min) + parseFloat(((_max) - parseFloat(_min)) /10)*9
56+
}
57+
get_total_prices: |
58+
_cost_template => {
59+
return "return (entity.attributes.raw_today.map((start, index) => {return [new Date(start['start']).getTime(), entity.attributes.raw_today[index]['value']"
60+
+ _cost_template
61+
+ "];})).concat(entity.attributes.raw_tomorrow.map((start, index) => {return [new Date(start['start']).getTime(),entity.attributes.raw_tomorrow[index]['value'] "
62+
+ _cost_template + "];}));"
63+
}
64+
get_future_total_prices: |
65+
_cost_template => {
66+
return "const now = new Date().getTime() - 3600000;"
67+
+ "const futureData = entity.attributes.raw_today.concat(entity.attributes.raw_tomorrow).filter(data"
68+
+ " => new Date(data.start).getTime() >= now);"
69+
+ "return futureData.map((data, index) => {"
70+
+ "return [new Date(data.start).getTime(), futureData[index].value"
71+
+ _cost_template + "];});"
72+
}
73+
entities:
74+
- ${nordpool_sensor}
75+
- ${battery_soc_sensor}
76+
- ${grid_import_sensor}
77+
card:
78+
type: custom:apexcharts-card
79+
graph_span: >-
80+
${ (states[nordpool_sensor].attributes.raw_today.length +
81+
states[nordpool_sensor].attributes.raw_tomorrow.length) / 4 + 'h' }
82+
yaxis:
83+
- id: y-price
84+
min: >-
85+
${get_chart_cutoff(get_total_min_nordpool_price(nordpool_sensor,additional_cost_template),get_total_max_nordpool_price(nordpool_sensor,additional_cost_template),chart_price_cutoff_coerficient)}
86+
max: auto
87+
apex_config:
88+
opposite: false
89+
forceNiceScale: true
90+
decimalsInFloat: ${decimals_in_prices}
91+
labels:
92+
formatter: >
93+
${"EVAL:function(value) {return value.toFixed(" + decimals_in_prices
94+
+ ") + ' " + price_y_axis_unit + "' }"
95+
- id: y-energy
96+
min: 0
97+
max: auto
98+
apex_config:
99+
opposite: true
100+
forceNiceScale: true
101+
decimalsInFloat: ${decimals_in_energy}
102+
labels:
103+
formatter: |
104+
${"EVAL:function(value) {return value.toFixed("
105+
+ decimals_in_energy
106+
+ ") + ' " + energy_y_axis_unit + "' }"
107+
- id: y-SOC
108+
show: false
109+
min: 0
110+
max: 100
111+
apex_config:
112+
chart:
113+
height: 340px
114+
legend:
115+
show: false
116+
title:
117+
floating: false
118+
align: center
119+
style:
120+
fontSize: 20px
121+
fontWeight: bold
122+
xaxis:
123+
labels:
124+
datetimeFormatter:
125+
hour: HH:mm
126+
show:
127+
last_updated: true
128+
experimental:
129+
color_threshold: true
130+
header:
131+
title: ${chart_title}
132+
show: true
133+
show_states: true
134+
colorize_states: true
135+
span:
136+
start: day
137+
now:
138+
show: true
139+
label: ${now_text}
140+
series:
141+
- entity: ${nordpool_sensor}
142+
yaxis_id: y-price
143+
name: ${total_purchease_price_text}
144+
offset: "-30min"
145+
float_precision: ${decimals_in_prices}
146+
show:
147+
extremas: false
148+
in_header: false
149+
type: column
150+
data_generator: ${get_total_prices(additional_cost_template)}
151+
color_threshold:
152+
- value: -1000
153+
color: "#00f738"
154+
- value: >-
155+
${get_low_bottom_threshold_nordpool_price(get_total_min_nordpool_price(nordpool_sensor,additional_cost_template),
156+
get_total_max_nordpool_price(nordpool_sensor,additional_cost_template)
157+
)}
158+
color: "#12A141"
159+
- value: >-
160+
${get_low_threshold_nordpool_price(get_total_min_nordpool_price(nordpool_sensor,additional_cost_template),
161+
get_total_max_nordpool_price(nordpool_sensor,additional_cost_template))}
162+
color: "#F3DC0C"
163+
- value: >-
164+
${get_high_threshold_nordpool_price(get_total_min_nordpool_price(nordpool_sensor,additional_cost_template),
165+
get_total_max_nordpool_price(nordpool_sensor,
166+
additional_cost_template))}
167+
color: "#E76821"
168+
- value: >-
169+
${get_high_top_threshold_nordpool_price(get_total_min_nordpool_price(nordpool_sensor,additional_cost_template),
170+
get_total_max_nordpool_price(nordpool_sensor,additional_cost_template))}
171+
color: "#DC182F"
172+
- entity: ${grid_import_sensor}
173+
yaxis_id: y-energy
174+
name: Grid import Chart
175+
color: "#FF4646"
176+
curve: stepline
177+
float_precision: ${decimals_in_energy}
178+
show:
179+
extremas: false
180+
in_header: false
181+
type: line
182+
stroke_width: 3
183+
opacity: 0.75
184+
extend_to: false
185+
unit: ${energy_y_axis_unit}
186+
group_by:
187+
func: delta
188+
duration: 1h
189+
- entity: ${grid_import_sensor}
190+
name: ${grid_import_text}
191+
color: "#FF4646"
192+
float_precision: ${decimals_in_energy}
193+
show:
194+
in_chart: false
195+
in_header: raw
196+
unit: ${energy_y_axis_unit}
197+
- entity: ${battery_soc_sensor}
198+
yaxis_id: y-SOC
199+
name: ${battery_soc_text}
200+
color: "#7a50d9"
201+
float_precision: 0
202+
show:
203+
extremas: false
204+
in_header: raw
205+
header_color_threshold: true
206+
type: line
207+
stroke_width: 3
208+
opacity: 0.75
209+
extend_to: false
210+
group_by:
211+
func: avg
212+
duration: 1h
213+
- entity: ${nordpool_sensor}
214+
color: "#7bff00"
215+
float_precision: ${decimals_in_prices}
216+
name: ${lowest_price_text}
217+
unit: ${price_overview_unit}
218+
show:
219+
in_chart: false
220+
legend_value: false
221+
group_by:
222+
func: min
223+
duration: 2d
224+
data_generator: ${get_future_total_prices(additional_cost_template)}
225+
- entity: ${nordpool_sensor}
226+
name: ${price_now_text}
227+
type: column
228+
unit: ${price_overview_unit}
229+
show:
230+
in_header: before_now
231+
in_chart: false
232+
header_color_threshold: true
233+
float_precision: ${decimals_in_prices}
234+
data_generator: ${get_future_total_prices(additional_cost_template)}
235+
color_threshold:
236+
- value: -1000
237+
color: "#00f738"
238+
- value: >-
239+
${get_low_bottom_threshold_nordpool_price(get_total_min_nordpool_price(nordpool_sensor,additional_cost_template),
240+
get_total_max_nordpool_price(nordpool_sensor,additional_cost_template)
241+
)}
242+
color: "#12A141"
243+
- value: >-
244+
${get_low_threshold_nordpool_price(get_total_min_nordpool_price(nordpool_sensor,additional_cost_template),
245+
get_total_max_nordpool_price(nordpool_sensor,additional_cost_template))}
246+
color: "#F3DC0C"
247+
- value: >-
248+
${get_high_threshold_nordpool_price(get_total_min_nordpool_price(nordpool_sensor,additional_cost_template),
249+
get_total_max_nordpool_price(nordpool_sensor,
250+
additional_cost_template))}
251+
color: "#E76821"
252+
- value: >-
253+
${get_high_top_threshold_nordpool_price(get_total_min_nordpool_price(nordpool_sensor,additional_cost_template),
254+
get_total_max_nordpool_price(nordpool_sensor,additional_cost_template))}
255+
color: "#DC182F"
256+
- entity: ${nordpool_sensor}
257+
color: "#DC182F"
258+
float_precision: ${decimals_in_prices}
259+
name: ${highest_price_text}
260+
unit: ${price_overview_unit}
261+
show:
262+
in_chart: false
263+
legend_value: false
264+
group_by:
265+
func: max
266+
duration: 2d
267+
data_generator: ${get_future_total_prices(additional_cost_template)}
268+
layout_options:
269+
grid_columns: full
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Energy price chart using nordpool prices.
2+
3+
This is my atempt at a chart displaying todays prices and tomorows prices when available along with imported energy.
4+
- Upper and Lower price threshold is calculated for today+tomorows ***comming*** price.
5+
- Orange is upper 3:rd of the pricing interval.
6+
- Green is lower 3:rd of the prices interval.
7+
- Red is the upper 10% of the pricing interval.
8+
9+
![alt text](HA_energy_chart.jpg)
10+
11+
# Pre-requirements
12+
13+
This has not been tested on HA earlier than 2024.9 and requires the following HACS addons:
14+
15+
- Nordpool - For getting energy prices.
16+
- Apex-Charts card
17+
- Config Template Card Card - For scripting inside the chart card.
18+
- lovelace-card-mod - For styling.
19+
20+
The Nordpool entity should be changed from the default name to just "nordpool" as per the components installation instructions.
21+
22+
# Installation
23+
- Copy - paste the raw card code from `card_nordpool_energy_chart.yaml` to your a new card on you lovelace dashboard. Add any card and replace the raw code that you can edit by clicking on the *SHOW CODE EDITOR* in the bottom left.
24+
25+
26+
# Configuration
27+
28+
Configure your Nordpool integration.
29+
30+
In the chart-card you should change the following variables to suit your needs:
31+
32+
- Check so the `nordpool_sensor:` name is correct.
33+
- The Grid import sensor name: `grid_import_sensor:` should be changed if not using Sigenergy system.
34+
- The
35+
- Change `currency` if needed.
36+
- `chart_price_cutoff_coerficient` from 0 to 1 to show more or less barheight under the minimum value.
37+
- `decimals_in_prices` and `decimals_in_energy` to indicate how many decimals to show.
38+
- `additional_cost_template` is used for adding extra costs if not added by nordpol sensor. It should be empty or start with a arithmetic operator.
39+
- Example:
40+
- additional_cost_template: '''*1.25 +(27.2 + 42.8 + 3.04 + 2.19 + 1.4) *1.25'''
41+
- Ads 25% taxes and then other costs as specified by the grid operator with more taxes.
42+
- Change the Now text to any label you want to apear `now_text: '''Now'''` besides the line showing current time in the chart.
43+
- And any of the texts below to suit your language or prefferences.
44+
45+
# Disable the Grid or Battery chart
46+
47+
## Disable the Grid chart
48+
49+
1. Comment out the update entity:
50+
```
51+
entities:
52+
- ${nordpool_sensor}
53+
- ${battery_soc_sensor}
54+
# - ${grid_import_sensor}
55+
```
56+
57+
2. Delete the rows starting with ```- entity: ${grid_import_sensor}``` and all rows under it until the next ```- entity:```. There are currently two such sections.
58+
59+
## Disable the Battery SOC
60+
61+
1. Comment out the update entity:
62+
```
63+
entities:
64+
- ${nordpool_sensor}
65+
# - ${battery_soc_sensor}
66+
- ${grid_import_sensor}
67+
```
68+
69+
2. Delete the row starting with ```- entity: ${battery_soc_sensor}``` and all rows under it until the next ```- entity:```. There is currently only one such section.
70+
71+
72+
# Performance concerns
73+
74+
Most of the calculations are done serverside so it's important to have a good computer.
75+
76+
If the chart flickers and takes long time to load, deactivate updating the chart with each change of battery charge and grid consumption:
77+
```
78+
entities:
79+
- ${nordpool_sensor}
80+
# - ${battery_soc_sensor}
81+
# - ${grid_import_sensor}
82+
```
83+
84+
85+
--
86+
87+
Happy savings!

0 commit comments

Comments
 (0)