Lovelace: Weather card with chart

Thank you Yevgenium,

Great card, I really enjoy it! I have a home weather station. Have you considered allowing to replace the forecast attributes (Pressure, wind, humidity…) with custom sensors?

Thanks for the consideration!

well, this stopped being ok… the graph is still created nicely, but I now get an error on an invalid date popup

while I didnt touch this:

        plugins: {
           tooltip: {
             callbacks: {
               title: function(context) {
                 return new Date(context[0].label).toLocaleDateString(locale, {
                   month: 'long',
                   day: 'numeric',
                   weekday: 'long',
                   hour: 'numeric',
                   minute: 'numeric',
                 });
              }
            }
           }

and I dont think the source changed. must check

Yeah that happened to me too.

seems the source must have changed after all…

The HA frontend changed and this card has not been updated to fix that change.

1 Like

Would you happen to know what changed in the date format? This is my own fork ( and hack) of the former chart-card, so I’d like (need) to update it myself :wink:

it must have been a recent change, and not the issue discussed a few posts above. This started very recently, maybe even with 2022.11

update

it was a recent change, but it was a user change… I changed to my local language Dutch, in stead of English. apparently the card then checks if I have a locale set in the config, and flukes on that.

a bit odd because I havent set it at all:

  - type: custom:weather-chart
    weather: weather.buienradar

Changing back to English, I see my pop ups back, in Dutch :wink: huh…

need to review that logic obviously. Would appreciate some extra eyes here:

somehow this all seems correct, though the actual behavior is really off…
no matter if I add locale: nl to the card config, the behavior is the same: setting HA language to English shows the popup in Dutch, while setting the HA language to Dutch, the popup shows Invalid date.

Meaning 2 things:
1 the locale:nl doesnt change a thing, so that logic seems incorrect in the card
2 the displayed text without Locale is somehow displaying Dutch without an obvious logic behind that…

now what is wrong here…

I would love to know this too, as I too am maintaining my own fork of the old card :-). FWIW my locale is English and my popups don’t work, so I’m not sure what that means.

My Home Assistant is running in dark mode, yet I have one template which uses “light” theme. With this configuration the chart uses the wrong colors for the labels (black background). Can this be fixed? I do not want to run whole Home Assistant in light mode.
/edit: Also the column labels use the wrong color

with popups you also mean the date tooltip…?

still trying t figure that one out, and stop it from showing ‘Invalid date’.
if your tooltips show correctly, I can have a quick peek and copy how you manage that

guess, bit, because you had the same JS as I did.

for now I changed that date tooltip to:

        plugins: {
           tooltip: {
             callbacks: {
               title: function(context) {
                 console.log(context[0].label);
                 return context[0].label;
              }
            }
           }
        },

and it at least shows a correct tooltip once again, albeit it no longer formatted, and put forward as is.

been trying to get that date formatted

let dateArr = context[0].label.split(' ');
let date = dateArr[0].split('-');
let time = dateArr[1].split(':');
let validDate = new Date(date[2], date[1]-1, date[0], time[0], time[1]);
validDate = new Date(validDate.toISOString());
return validDate.toLocaleDateString(this.lang, {
    month: 'short',
    day: 'numeric',
    weekday: 'short',
    hour: '2-digit',
    hour12: false
});

but it keeps returning the Invalid date…

so context[0].label is already in the form: 20 januari 2023 om 00:00

and can not be input into the new Date() function as is.

secondly, I still dont get why the locale: nl in the card config has no effect anymore. The card does respond to the language settings in HA, so thats ok too. But I recall being able t set it in the card config, overriding the System settings.

All in all, Ive hacked my way to current Dashboard, and since there is no alternative yet, will try and keep it up to date…

update

this is much better, and correctly formattable,:

        plugins: {
           tooltip: {
             callbacks: {
               title: function(context) {
                 console.log(context[0].label);
                 /*console.log(new Date(context[0].label));*/
                 let date = new Date(context[0].label);
                 let options = {
                   year: '2-digit', //numeric
                   month: 'short',
                   day: 'numeric' ,
                   weekday: 'long',
//                   hour: 'numeric',
//                 minute: 'numeric',
                 };
                 let formattedDate = date.toLocaleDateString(locale,options);
                 /*console.log(formattedDate);*/
                 return formattedDate;
              }
            }
           }
        },

still an issue with locale though (as you can see) and when I set HA to Dutch, the string changes to an incompatible 20 januari 2023 om 00:00 compared to the valid January 20, 2023 at 12:00 AM

1 Like

See Blank card in Firefox, works in Chrome. · Issue #118 · Yevgenium/weather-chart-card · GitHub

for any one interested: Custom weather-chart card · GitHub

uses the Home Assistant language to set the tooltips and the other date settings in the card. Maybe not very pretty, but it does the job

1 Like

Why are you telling me to see an issue I opened?

Also I no longer use this card.

I thought a link to the issue would be useful to those searching this thread for a solution.

well, that didnt take long…
2023.2 causes the weather-chart card I posted above to throw an error, and not show at all now.

Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'e.language')

1 Like

Yep - I liked your good work while it lasted. Any chance it will be fixed?

1 Like

nope, not yet.
I had hoped a recent front-end pr on language would have fixed it but unfortunately not.

I use this, and deleted the chart card

1 Like

OK - thanks.

Anyone know if this card is still working, for the last few weeks now the graph part on my card has disappeared, now looks like this:

image

Running HA2023.2

Is this the error you were referring to above @Mariusthvdb ?

nope, I had an issue showing Invalid date in my graph popups.

I abandoned the card, no longer wanting to keep hacking it. The only added value it had t the plethora of there weather cards was this nice graph. and I have replaced that with something way more professional

only minor issue there is it doesnt use my most local weather resource… its a fixed .svg
so, if ever there will be a configurable graph chart again, Id have a look at it…

Thanks, yeah it was the graph in particular I liked in the card. I suspect I need to find an alternative (or use yours and move to Norway!)