Comments (5)
Hello!
If you want to add the transmission and other extra fees only to the chart, then maybe this quick hack could work:
type: custom:apexcharts-card
graph_span: 48h
experimental:
color_threshold: true
show:
last_updated: true
header:
title: Electricity price (c/kWh)
show: true
show_states: true
colorize_states: true
span:
start: day
yaxis:
- min: 0
decimals: 2
apex_config:
forceNiceScale: true
now:
show: true
label: Now
series:
- entity: sensor.shf_electricity_price
show:
in_header: false
extremas: true
type: column
color: lightgray
float_precision: 2
data_generator: |
var extra_fees = [5.46, 5.46, 5.46, 5.46, 5.46, 5.46, 5.46, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 5.46, 5.46 ] ;
return entity.attributes.data.map((d, index) => {
var tempdate = new Date(d["DateTime"]);
var hour = tempdate.getHours();
return [tempdate.getTime(), entity.attributes.data[index]["PriceWithTax"]*100+extra_fees[hour]];
});
color_threshold:
- value: 0
color: 368f39
- value: 10
color: a3b34d
- value: 20
color: ffd57e
- value: 30
color: f18c56
- value: 40
color: de425b
- entity: sensor.shf_electricity_price
show:
in_header: true
header_color_threshold: true
in_chart: false
type: line
color: lightgray
float_precision: 2
stroke_width: 0
data_generator: |
var extra_fees = [5.46, 5.46, 5.46, 5.46, 5.46, 5.46, 5.46, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 7.02, 5.46, 5.46 ] ;
var currentTime = new Date().setMinutes(0, 0, 0);
let currentPrice = entity.attributes.data.find(d => {
return new Date(d["DateTime"]).getTime() === currentTime;
})["PriceWithTax"];
return entity.attributes.data.map((d, index) => {
var t = new Date();
return [new Date(d["DateTime"]).getTime(), currentPrice*100 + extra_fees[t.getHours()]];
});
color_threshold:
- value: 0
color: 368f39
- value: 10
color: a3b34d
- value: 20
color: ffd57e
- value: 30
color: f18c56
- value: 40
color: de425b
Currently implementing transmission fees + other extra fees to the data loader isn't that simple as this package is using Restful sensor included in the HomeAssistant. Modifying the Array of prices isn't right now possible (or at least easy) as Template Sensors always output a String. But I'm going to think about this as I see the value of this. Sometimes day/night transmission fees could change the outcome of some scripts.
from spotprices2ha.
Great, thank you! This was exaclty what I was looking for.
from spotprices2ha.
Alright, nice to hear! I will close this issue then.
But please note that the code provided affects only the charts and other logic inside this package does not know about your transmission fees. I might add some functionality for this in the future.
from spotprices2ha.
Yes, this was the target. I have the template sensors controlling automations, which take the margins and transfer prices into account. The only problem I had was the apexchart not showing the total amount of the price, but with this hack it works perfectly.
from spotprices2ha.
I added some functionality around these transmission fees etc. They are not fully tested and therefore they are currently available in a separate branch: https://github.com/T3m3z/spotprices2ha/tree/price_margins
Feel free to test this. Could be useful for automations too and not only for the chart.
from spotprices2ha.
Related Issues (20)
- "sensor.shf_electricity_price_now" not working after HA update to 2023.5.0 HOT 14
- Average price Selected period HOT 5
- Negative energy prices + vat HOT 2
- shf_electricity_price_now sensor getting price from one hour ahead HOT 8
- Apexcharts not working HOT 1
- Electricity price in cents instead of euros HOT 16
- Night time price (SHF Price2) not working even though times are set HOT 3
- Ranking the hourly prices is not taking Price1 and Price2 into account HOT 10
- Breaks a lot on background HOT 6
- Yield overhead costs (selling electricity) HOT 3
- Visualization card size HOT 2
- rank-automation.yaml Blueprint fails with "TemplateSyntaxError: unexpected char '\\' at 1930" HOT 3
- UI screenshots in README not up to date(?) HOT 1
- Import blueprint unsupported url HOT 4
- HA 2023.12 re-importing (updating) blueprints HOT 3
- Afternoon rank HOT 4
- Add sensor for current electricity price without taxes HOT 1
- rank-automation.yaml doesn't work HOT 7
- SHF Control Factor +-1 throws DivisionByZero error HOT 1
- Feature request : one more price sensor (price for electricity returned to grid)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spotprices2ha.