Lovelace: Weather card with chart

(York_Yu_Chan)

You will find a link at the top of this series of postings I.E. post number one.
It will take you to the GitHub page.
Also

https://github.com/Yevgenium/lovelace-weather-card-chart

All seems to be working well but am having an issue with the bar chart. I assume this shows rain in inches and not snowā€¦ But even if snow here in +New England we are not getting 21 inches. I have not seen any way to influence this reading.

Update: Checked Open Weather States and see they are reporting 21 for Tuesday. Assume this is not inches but mm. Wonder how to have it graph in inches.

  • datetime: ā€˜2021-02-15T17:00:00+00:00ā€™
    precipitation: 1
    pressure: 1024
    wind_speed: 1.36
    wind_bearing: 342
    condition: snowy
    temperature: 29.4
    templow: 22.6
  • datetime: ā€˜2021-02-16T17:00:00+00:00ā€™
    precipitation: 21
    pressure: 1000
    wind_speed: 1.08
    wind_bearing: 22
    condition: pouring
    temperature: 40.7
    templow: 21.5

Iā€™m still having trouble, How did you fix the card config?

If I remember correctly just by removing the ā€˜-ā€™ at the beginning.

Thanks, got it to work following the instructions, but make sure you have OpenWeatherMap integration installed. I didnā€™t so I had to change ā€œweather.openweathermapā€ to ā€œweather: weather.homeā€ because I have Meteorologisk institutt integration installed instead.

easier to do that is to use styles, though the page still has to load the info, and the hide it. It would be nice that your code gets added in the main version of the plug-in as an option, maybe post it in GitHub!

If anyone else wants the code:

type: 'custom:weather-card-chart'
weather: weather.xxxxxxxxx
mode: daily
style: |


  .main {
    display: none !important;
  }



  .attributes {
    display: none !important;
  }

Hi all, in case anyone is interested, I created a fork of the card with the below fixes/changes. It may not work well for everyone, especially people using openweathermap as that was the service that the card was designed for (it seems).

My card works well with smartweather weather stations, though, and might be better for anyone who has an hourly weather source but wants a 24 hour graph (current card draws 9 hours). Here is the list of my changes:

  • Added 24 hour daily chart for an hourly source which averages each 3 hour period together
  • Implemented the-louieā€™s fix for longstanding Uncaught TypeError: Cannot read property ā€˜forecastā€™ of undefined
  • Gave a bit more room for the axis numbers so that digits donā€™t get clipped
  • Removed the wind conversion from km/h to m/s since mine was already m/s

I certainly wonā€™t promise you the code is good as I have little real world programming experience and really only practiced programming in school 30 years ago, but it works well for me. I might make it a little better if someone had interest in it (but no promises).

Anyhow, you can find it here

Also, Iā€™d be curious to know if there are any other well maintained forks out there. There are an awful lot of PRā€™s open against this one which implement fairly needed features, I would be happy if I could start following someone who was more actively maintaining the card.

1 Like

Hi all, is it possible to replace weather icons with those of the standard [colored] HA weather card? (I canā€™t figure it out how to refer them properly from the script.)

I think you could replace roundNumber(weatherObj.attributes.pressure) with a call of smth like this:

computePressure(hpa) {
  var calcMmhg = Math.round(hpa / 1.333);
  return calcMmhg;
}

cool, will have a look.
you missed one Pr though https://github.com/Yevgenium/lovelace-weather-card-chart/pull/44 :wink:

moving from km/h to m/s is ā€˜againstā€™ HA defaults though, youā€™re sure you want to do so?

that is for the integration itself of course, not necessarily for a frontend cardā€¦

My goal is definitely not to integrate all the open PRā€™sā€¦ But there are more Iā€™m considering to look atā€¦ I think to make my version useful to everyone, I will first have to make some of my changes optional, so maybe that should be a higher priority.

As for the wind speed, it seemed that no matter what I did, my weather component was reporting m/s which the card was then attempting to convert and making wrong, so just commenting out the conversion was the easiest fix for me.

Maybe I should tell the maintainer of the smartweather component that it should be doing conversion to km/h by default. I have had to notify him of other things such as using ā€œnullā€ instead of zero for rain amounts.

cool, looking forward to a new and better card. the Pr is only minor, but is a certain improvement, check the position of the top icons, which are now aligned correctly:

You are right, that was bugging me too. Added it. Looks like you have a nice version as well. I will see if I can get mine to a state thatā€™s a bit more fit for general use, but you might consider doing your own fork?

I feel so stupid, canā€™t get this goingā€¦
Error message:
Component error: resources - Integration ā€˜resourcesā€™ not found.

Input in configuration.yaml:
resources:
-type: module
url: /local/weather-card-chart.js

What am I missing?

Nope, It doesnā€™t work, I tried with:

Lovelaceā€™s resource:
image

Manual Card Config:

Also, can I add my own sensor for humidity and pressure? I have my own weather station.

1 Like

OK, fixed it. When adding a resource to Lovelace all you need to do is make sure it doesnā€™t contain:

ā€œresources: - type: module url:ā€ but just the link to the card.

The question still stands, can I replace weather humidity and pressure with my own sensor data?

If the card uses the weather entity no. There are custom cards you can use that will let you though.

beta 2021.6 throws a warning on. raised an issue in the repo

bar chart: "scales.[x/y]Axes.maxBarThickness" is deprecated. Please use "dataset.maxBarThickness" instead

I dont know yet how to replace that in the resource, so Ive commented the line completely, and seeing no difference :wink:

however, it might be nice to know how to correct the code, so if anyone would be able to help out here?
thanks!

Update

I did add this in the datasets list:

          {
           maxBarThickness: 15,
          },

and see no errors. However, I dont see anything changed either, so not sure this does anything at allā€¦

it is loaded correctly alright:
Schermafbeelding 2021-05-31 om 11.55.16

just as a FYI: this card is broken as of 2021.7, because of changed core charts.
Dont have details yet, but running the beta now, and it is chartless :wink:

1 Like

and 2 fixes are live!:

PR by @koying Bump to ChartJs3 (mandatory for 2021.7). Fixes #59 by koying Ā· Pull Request #60 Ā· Yevgenium/lovelace-weather-card-chart Ā· GitHub
and a fork by @fancygaphtrn GitHub - fancygaphtrn/lovelace-weather-card-chart: Custom weather card with charts

now that this is fixed, I notice my ll(str) doesnt work, and it always shows the locale.enā€¦ guess because my HA instance uses the English language I never noticed, but I do in fact have a weather-card-chart config using:

      type: custom:weather-card-chart
      title: Woensdrecht
      weather: weather.buienradar
      temp: sensor.buienradar_feel_temperature
      locale: nl

so I want it to display the nl strings. Anyone else notice this?

should this line:

this.lang = this._hass.selectedLanguage || this._hass.language;

be changed to use the this.config.locale ?

edit, yes, it should:

    this.lang = this.config.locale || this._hass.language;

does the trickā€¦ cant believe we never stumbled over this before?

hereā€™s my adaptation with animated icons:

3 Likes