Hi, I’m trying to create a simple line chart that uses Apple’s WeatherKit hourly data to display a linegraph that shows the next 24 hour’s pressure data, by hour.
I can call the service and get the data back in the developer tools page, and I can create a linechart that shows the last 24 hours worth of data, but no matter what I try, i can’t get it to display the next 24 hours data with out getting the error in the title.
this is my code:
type: custom:apexcharts-card
header:
title: Predicted Barometric Pressure
show: true
show_states: true
colorize_states: true
graph_span: 48h
now:
show: true
label: ‘’
color: red
span:
start: hour
offset: ‘-24h’
series:
- entity: sensor.pressure_forecast_next_hour
data_generator: |
const now = new Date();
const oneHour = 1000 * 60 * 60; // milliseconds in one hour
const start = new Date(now - 24 * oneHour); // 24 hours before now
const end = new Date(now + 24 * oneHour); // 24 hours after now
return entity.attributes.forecast
.filter(entry => {
const entryDate = new Date(entry.datetime);
return entryDate >= start && entryDate <= end;
})
.map(entry => {
return [new Date(entry.datetime).getTime(), entry.pressure];
});
any idea what I’m doing wrong? If i delete the data_generator text, it will not give an error.
thank you for any help!