Hi everyone, i would like to import data with the data generator function
I recently switch to a french energy provider which provides API to get the lowest price of the day.
I managed to get the prices in either pyscript and nodered for comparaison purpose (pyscript will disapear as soon as i will be sure that everything is ok).
Data are stored in attributes under the dictionnary template {‘time’:value}.
Between NodeRed & Pyscript, no probs, they both have the same chart and the base time is in accordance with the official app.
I used one of the script if found in this topic:
type: 'custom:apexcharts-card'
header:
show: true
title: Barry Electricité NODERED (€/kWh)
show_states: false
colorize_states: true
y_axis_precision: 4
span:
start: day
offset: '-1day'
graph_span: 72hours
all_series_config:
stroke_width: 2
extend_to_end: false
curve: stepline
now:
show: true
label: now
color: red
series:
- entity: sensor.general_prices
unit: €/kWh
float_precision: 5
data_generator: |
let res = [];
for (const [key, value] of Object.entries(entity.attributes.values)) {
res.push([new Date(key).getTime(), value]);
}
return res.sort((a, b) => { return a[0] - b[0] })
I decided to process a moving average on NodeRed; no probs here, when i do the maths manually, i get the good time and the good average with the same data template
But when i’m using the same function used to plot the general prices, I now have a 2hr offset…
We can see there that between the lowest price in attributes and the lowest price in the graph, i have a 2hr offset.
Did anyone manage to get it working with two y-axes? I have three series I want to plot, so I put the one I want on the right y-axis first and then the other two since everything after the first is supposed to end up on the second axis.
This doesn’t work for me, the two series on the same axis are offset for some reason, one of them not really matching the scale of any axis:
maybe its a latency issue of HA getting to the DB too slowly, but still there’s many errors there in just the flash of an eye…
and another one after clicking restart HA:
I noticed that the #header comes with a padding of only 8px while I see most cards coming with 16px. Of course, I could use card_mod to adjust this, but I was wondering if I miss something?
bonjour, j’utilise votre code pour analyser des senseurs dans mon jardin, seulement je crois que je n’ai pas la dernière version que vous utilisez car je n’ai toujours pas la barre “now” au bon endroit!
auriez-vous la gentillesse de m’aider avec votre code le plus récent, c’est de cette façon que j’apprends, en regardant le code des autres.
I am trying to display solar monthly production history data which is in an influx DB.
All I get it the average amount for the total months as below which I have data for Jan to April 2021.
The data is in influxDB. It is added the last day of the month
root@pi4HA:~# influx -database 'sensors' Connected to http://localhost:8086 version 1.8.5
InfluxDB shell version: 1.8.5
> SELECT "value" FROM "solar" WHERE "entity_id"='month'
name: solar
time value
---- -----
1612085400000000000 588.8
1614504600000000000 596.5
1617183000000000000 736.7
1619775000000000000 572.9
>
Hello everyone,
super done first of all. Thanks - was amazed at this card.
A question (maybe newbie).
I am trying a simple line chart but with Y axis lines to show todays maximum electricity price. Here using the Tibber integration. The value that I am looking for is a state attribute - I have tried under developer and it returns a value but it does not work in my apex card. Maybe something fundamentally misunderstood? 2nd step will be to show in x-axis the times when certain levels are active.
type: 'custom:apexcharts-card'
graph_span: 3d
header:
show: true
title: ApexCharts-Card
show_states: true
colorize_states: true
series:
- entity: sensor.electricity_price_my_address
apex_config:
annotations:
position: back
yaxis:
- 'y': states.sensor.electricity_price_my_address.attributes.max_price //returns wrong value.
label:
text: Maximum
- 'y': 0.2 // here I just tried out with 0.2 to check it out
borderColor: '#00E396'
borderWidth: 1
label:
text: Minimum
Again thanks for all your work and thank for any help on this.
I love the card!
Intstalled it from HACS but doesn’t work with Home assistant Cast for me. I get the: Custom element doesn’t exist message.
That would be a great feature!
The timestamps in the attributes are UTC based, the chart is displayed with your timezone (France = UTC +2). It’s totally expected. Unless the data in the attributes is actually set with the wrong timezone, the chart is correct.
Hi RomRider, Thanks for the reply. Below is what the influx 1.8 DB looks like. How should it be ?
database name is sensors, measurement is solar. I didnt add the friendly_name_str and guess HA added that.
> SELECT * FROM "solar"
name: solar
time day entity_id friendly_name_str month value year
---- --- --------- ----------------- ----- ----- ----
1609493400000000000 01 day 01 14.7 2021
1609493400000000000 01 total 01 13719.7 2021
1609579800000000000 02 day 01 22.7 2021
1609579800000000000 02 total 01 13742.4 2021
1609666200000000000 03 day 01 18 2021
1609666200000000000 03 total 01 13760.4 2021
1609752600000000000 04 day 01 10.8 2021
1609752600000000000 04 total 01 13771.3 2021
.....
1611999000000000000 30 day 01 23.9 2021
1611999000000000000 30 total 01 14271.8 2021
1612085400000000000 31 day 01 22 2021
1612085400000000000 31 month 01 588.8 2021
1612085400000000000 31 total 01 14293.8 2021
When the data is inserted into influx the command is:
How should I setup the influxdb table etc and how do I then access it to get it into apex.
I have searched the forums and googled, and most of what I could find was getting the data into influx from HA, but not the other way around for chatting historical data.
thanks
Because everyone has different tastes card-mod is there to address specifically that.
The missing numbers at the beginning is a bug from the library I use, nothing I can do. At the end, it’s because the days are displayed only every 3 days and the last value is on the 20th, it might also be related to the same bug.