-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HA + Apexchart + Tariff prices #4
Comments
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. |
Great, thank you! This was exaclty what I was looking for. |
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. |
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. |
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. |
Hi,
Thanks for a great and simple solution for the SPOT price analysis. I was wondering if it was possible to implement the tariff prices (nigh/day) to the ApexChart configuration so that the tariff prices would be added on top of the SPOT price for every hour? I just can't figure out how to do it. Another solution would be to implement the tariff to the configuration of the main sensor shf_electricity_price somehow.
Our tariffs are 6.8c/kWh during 7-22 and 5.24c/kWh during 22-07.
I already included these to the sensor config of the current price
unique_id: shf_electricity_price_now
unit_of_measurement: "€/kWh"
device_class: monetary
state: >
{%- set siirto_paiva = 0.068 -%}
{%- set siirto_yo = 0.0524 -%}
{%- set alv = 1.10 -%}
{%- set marginaali = 0.002016 -%}
{{ (state_attr("sensor.shf_electricity_price", "data")[states("sensor.shf_idx")|int+now().hour]["PriceWithTax"] + marginaali * alv + siirto_paiva)|round(3) if 6 < (now().hour) < 22 else (state_attr("sensor.shf_electricity_price", "data")[states("sensor.shf_idx")|int+now().hour]["PriceWithTax"] + marginaali * alv + siirto_yo)|round(3) }}
The text was updated successfully, but these errors were encountered: