You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My configuration is showing me the last value from the array in the header (with in_header: true) - I want the first or second value (which should be close in time after now since this is a forecast) to be displayed in the header, what should I change?
in_header: raw gives "NaN"
in_header: after_now gives N/A,
in_header: true gives the last value in the array.
Where to go from this? The array data and config are below.
- entity: sensor.national_grid_renewables_3_day_forecast
yaxis_id: MW
color: black
opacity: 0.8
stroke_width: 2
name: Nuclear + Solar + Wind
data_generator: |
var now = new Date().getTime();
var forecastData = entity.attributes.forecast.filter(entry => {
var startTime = new Date(entry.start_time).getTime();
if (startTime > start){
return true
}
return false
});
return forecastData.map(entry => {
return [entry.start_time, entry.generation]
});
type: line
show:
legend_value: false
in_header: true
Sensor data: (real data is much longer but you get the idea, I want to show the next one in time not the last in the array, which is what I get with in_header: true)
Reason being: the next one in the forecast is quite close to reality, the last one in the forecast is very likely to have changed significantly by the time we get there...
I'll probably end up fudging this by creating a custom sensor to get the now value as a state rather than first value in an array, but it would be good to know how to achieve this, or if it's a feature/bug with after_now (the setting I was expecting to use).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
My configuration is showing me the last value from the array in the header (with in_header: true) - I want the first or second value (which should be close in time after now since this is a forecast) to be displayed in the header, what should I change?
in_header: raw gives "NaN"
in_header: after_now gives N/A,
in_header: true gives the last value in the array.
Where to go from this? The array data and config are below.
Sensor data: (real data is much longer but you get the idea, I want to show the next one in time not the last in the array, which is what I get with in_header: true)
Reason being: the next one in the forecast is quite close to reality, the last one in the forecast is very likely to have changed significantly by the time we get there...
I'll probably end up fudging this by creating a custom sensor to get the now value as a state rather than first value in an array, but it would be good to know how to achieve this, or if it's a feature/bug with after_now (the setting I was expecting to use).
Beta Was this translation helpful? Give feedback.
All reactions