I am using this code in my card configuration:
data_generator: |
let data = [];
if (entity.attributes.raw_tomorrow === "-") {
entity.attributes.forecast.map((hour, index) => {
data.push([new Date(hour["hour"]).getTime(), entity.attributes.forecast[index]["price"]]);
});
} else {
entity.attributes.raw_tomorrow.map((hour, index) => {
data.push([new Date(hour["hour"]).getTime(), entity.attributes.raw_tomorrow[index]["price"]]);
});
}
return data;
When the condition is not met, data is shown in accordance with the ‘else’ part.
When the condition is met, nothing is shown.
If I make a card without the condition, data is shown:
data_generator: |
let data = [];
{
entity.attributes.forecast.map((hour, index) => {
data.push([new Date(hour["hour"]).getTime(), entity.attributes.forecast[index]["price"]]);
});
}
return data;
Now, why does half the condition work and the other half not?
Hope someone can point me to a fix here
Thanks