Custom Dark Sky Animated Weather Card

It’s not getting the UOM from Hass - it’s hard wired in the script. t isn’t too hard to search for km/h in the script and replace it with m/s

Well this is exactly my problem. It does not seem to be hard-wired in the script. I assume this is the crucial part of the script (line 651):

  getUOM(measure) {
    
    const lengthUnit = this._hass.config.unit_system.length;
    
    switch (measure) {
      case 'air_pressure':
        return lengthUnit === 'km' ? 'hPa' : 'mbar';
      case 'length':
        return lengthUnit;
      case 'precipitation':
        return lengthUnit === 'km' ? 'mm' : 'in';
      case 'intensity':
        return lengthUnit === 'km' ? 'mm/h' : 'in/h'
      default:
        return this._hass.config.unit_system[measure] || '';
    }
  }

The value seems to be calculated in line 100:

    var windSpeed = this.config.entity_wind_speed ? Math.round(this._hass.states[this.config.entity_wind_speed].state) : 0;

The HTML ist build in line 313:

    var wind = this.config.alt_wind ? html`<li><span class="ha-icon"><ha-icon icon="mdi:weather-windy"></ha-icon></span><span id="alt-wind">${this._hass.states[this.config.alt_wind].state}</span></li>` : this.config.entity_wind_bearing && this.config.entity_wind_speed ? html`<li><span class="ha-icon"><ha-icon icon="mdi:weather-windy"></ha-icon></span><span id="beaufort-text">${this.current.beaufort}</span><span id="wind-bearing-text">${this.current.windBearing}</span><span id="wind-speed-text"> ${this.current.windSpeed}</span><span class="unit"> ${this.getUOM('length')}/h</span></li>` : ``;

There are no hard-coded UOM… :thinking:

Ok so it’s not returning anything according to that.

Are you sure the wind speed entity is returning a unit - in dev-tools states for that entity?

Yes! It’s m/s. That is exactly the point I do not understand…

Yeah but the STATE is unit less… I will take a look at this. I have a fork of this card in HACS ( the BOM one will work with this config as well). I will see if I can fix this issue…

Ah. Ok. The state itself is unit less. I understand. It would be nice to have the wind speed in (real) km/h rounded to one decimal place. Also, I would like to have the visibility in km and rounded to one decimal place. Maybe you could be so kind to tell me how to do that. I’m willing to learn… :wink:

OK!!! so that’s actually pretty easy to do. No change to the card is required.
What we need is a Template Sensor to convert the windspeed from m/s to km/hr and then to parse that to the card instead of the m/s one…

So… m/s*3.6 should do it right? (m/s*60*60/1000=km/h) and then we can round that to 1 decimal place.

So in my case, I use BOM in Australia which provides km/h instead of m/s but if I wanted to convert that to m/s I would make a template like this:

{{ (states('sensor.bom_gosford_wind_speed_kmh')|float*1000/3600) | round(1) }}

So in your case, I would make a template sensor like this:

  - platform: template
    sensors:
      wind_speed_kmh:
        value_template: >
            {{ (states('sensor.dark_sky_wind_speed')|float*3.6) | round(1) }}

Then in the card config, instead of this:

entity_wind_speed: sensor.dark_sky_wind_speed

Use this:

entity_wind_speed: wind_speed_kmh

You can make a similar template sensor for the visibility.

1 Like

You made my day! Yeah! Thx a lot! Of course, it is possible to simply use a template. The whole time I was looking at the script to solve the problem! But it is so much easier to simply use a template. It works now but still I am curious what the reason for the original problem is? :thinking:

Best regards to the other end of the world! Keep well!

Thorsten

1 Like

It’s no more complicated than the state not including the unit. The card looks at the unit system and picked the appropriate unit but darksky is returning the non-standard unit in the state and that unit isn’t parsed with the state to the card. In Australia, the wind speed is already in km/h…

1 Like

Hi David,
You have helped me in the past and many of your answers (after I gained enough knowledge to understand the issues) was indeed operator error. Most of my “operator errors” have to do with me not understanding how home assistant interprets my yaml files or yaml code inside of different home assistant editors. If I use the UI editor, it is different than raw editor and understanding how the !include statements works can be the same as one or the other or different entirely. I have read

http://thomasloven.com/blog/2018/08/YAML-For-Nonprogrammers/

Which has helped me a lot in understanding yaml statements, but I still make mistakes on when the - for example is use in the yaml file and when the - is inserted by HA depending on how the include or editor is used . Do you have any other reference documents that I can hopefully read and learn from? It took me much to long to figure out how to add 5 simple Coronavirus sensors. Again, operator error understanding lists, dic, etc in my include file.
Thanks again for all the help you offer to the group.

Thomas’ blog article is great. A lot of the time it’s trial and error and the config checker helps. I am gradually starting to understand more and more - only taken 3 years and there’s lots I still don’t understand or know how to do. I recommend just starting a thread on the forum when you find an issue and people will fall over themselves to help you. That is the way I learn.

I hate learning by trial and error. I would much rather understand what it should be. I have one sensor file that when it is split it works, combined into one yaml it doesn’t. I will try your suggestion and create a new yaml code question.
Thanks again.

1 Like

Apple has bought Dark Sky and decided to give API users the shaft. You’ll need to find a new weather feed.

Do you know some other reliable weather feed?
Thanks

I’m currently using the NWS for weather data now.

thank you!
I live in Italy, do you know a service working well in Europe?
National weather service provides forecast just for US

No idea for the EU sorry.

Did somebody check this as replacement: https://www.visualcrossing.com/weather-api?
Is it possible to modify this interface and reroute the requests to this api?

2 Likes

Please help.

My yaml is:

    cards:
      - type: weather-forecast
        entity: weather.home
        theme: vintage
      - type: 'custom:lovelace-darksky-card'
        entity_current_conditions: sensor.dark_sky_icon
        entity_temperature: sensor.dark_sky_temperature
        entity_forecast_high_temp_1: sensor.dark_sky_daytime_high_temperature_1d
        entity_forecast_high_temp_2: sensor.dark_sky_daytime_high_temperature_2d
        entity_forecast_high_temp_3: sensor.dark_sky_daytime_high_temperature_3d
        entity_forecast_high_temp_4: sensor.dark_sky_daytime_high_temperature_4d
        entity_forecast_high_temp_5: sensor.dark_sky_daytime_high_temperature_5d
        entity_forecast_icon_1: sensor.dark_sky_icon_1d
        entity_forecast_icon_2: sensor.dark_sky_icon_2d
        entity_forecast_icon_3: sensor.dark_sky_icon_3d
        entity_forecast_icon_4: sensor.dark_sky_icon_4d
        entity_forecast_icon_5: sensor.dark_sky_icon_5d
        entity_forecast_low_temp_1: sensor.dark_sky_overnight_low_temperature_0d
        entity_forecast_low_temp_2: sensor.dark_sky_overnight_low_temperature_1d
        entity_forecast_low_temp_3: sensor.dark_sky_overnight_low_temperature_2d
        entity_forecast_low_temp_4: sensor.dark_sky_overnight_low_temperature_3d
        entity_forecast_low_temp_5: sensor.dark_sky_overnight_low_temperature_4d
        entity_summary_1: sensor.dark_sky_summary_1d
        entity_summary_2: sensor.dark_sky_summary_2d
        entity_summary_3: sensor.dark_sky_summary_3d
        entity_summary_4: sensor.dark_sky_summary_4d
        entity_summary_5: sensor.dark_sky_summary_5d

Card Configuration keep coming up with "No visual editor available for :custom:lovelace-darksky-card"

type: 'custom:lovelace-darksky-card'
entity_current_conditions: sensor.dark_sky_icon
entity_temperature: sensor.dark_sky_temperature
entity_forecast_high_temp_1: sensor.dark_sky_daytime_high_temperature_1d
entity_forecast_high_temp_2: sensor.dark_sky_daytime_high_temperature_2d
entity_forecast_high_temp_3: sensor.dark_sky_daytime_high_temperature_3d
entity_forecast_high_temp_4: sensor.dark_sky_daytime_high_temperature_4d
entity_forecast_high_temp_5: sensor.dark_sky_daytime_high_temperature_5d
entity_forecast_icon_1: sensor.dark_sky_icon_1d
entity_forecast_icon_2: sensor.dark_sky_icon_2d
entity_forecast_icon_3: sensor.dark_sky_icon_3d
entity_forecast_icon_4: sensor.dark_sky_icon_4d
entity_forecast_icon_5: sensor.dark_sky_icon_5d
entity_forecast_low_temp_1: sensor.dark_sky_overnight_low_temperature_0d
entity_forecast_low_temp_2: sensor.dark_sky_overnight_low_temperature_1d
entity_forecast_low_temp_3: sensor.dark_sky_overnight_low_temperature_2d
entity_forecast_low_temp_4: sensor.dark_sky_overnight_low_temperature_3d
entity_forecast_low_temp_5: sensor.dark_sky_overnight_low_temperature_4d
entity_summary_1: sensor.dark_sky_summary_1d
entity_summary_2: sensor.dark_sky_summary_2d
entity_summary_3: sensor.dark_sky_summary_3d
entity_summary_4: sensor.dark_sky_summary_4d
entity_summary_5: sensor.dark_sky_summary_5d

is this card still updated/maintained? I must admit Ive lost sight of updates a bit, using other weather cards. Since all of those use customized icons for wind bearing, I only noticed now that this custom card uses a fixed icon for windbearing.

Could/would anyone here be able to help me use this instead:

// #####
// ##### windIcons: returns icon names based on current windbearing
// #####

  get windIcons() {
    return {
          var icons = ['mdi:arrow-down','mdi:arrow-bottom-left','mdi:arrow-left',
                       'mdi:arrow-top-left','mdi:arrow-up','mdi:arrow-top-right',
                       'mdi:arrow-right','mdi:arrow-bottom-right'];
          var quadrant = Math.round(Number(this.config.entity.windbearing)/45);
          if (quadrant < icons.length) return icons[quadrant];
          return 'mdi:arrow-down';
    }
  }

this is not correctly formatted yet for the card, but the template shows what its doing. check the custom card now:

while the same data customized with my template is showing more to the point:

in regular custom-ui syntax:

    sensor.owm_wind_bearing:
      friendly_name: Wind bearing
      templates: &direction_icon
        icon: >
          var icons = ['mdi:arrow-down','mdi:arrow-bottom-left','mdi:arrow-left',
                       'mdi:arrow-top-left','mdi:arrow-up','mdi:arrow-top-right',
                       'mdi:arrow-right','mdi:arrow-bottom-right'];
          var quadrant = Math.round(Number(state)/45);
          if (quadrant < icons.length) return icons[quadrant];
          return 'mdi:arrow-down';

thanks for having a look.