Use of Multipule Weather Components

I was just curious in finding out in the Configuration.yaml you can use Darkskys as the weather component like below:

weather:

  • platform: darksky
    api_key: !secret darksky_api_key

But can you use other forms of weather components along with it? or does it only work with the one?

So something like this?

weather:

  • platform: darksky
    api_key: !secret darksky_api_key
  • openweathermap
    api_key: !secret openweathermap_api_key
  • platform: yr

Is that possible to do? Just curious to pull weather stats from different location for a weather page on HA. I tried to do a directory called “weather” and put separate component files (i.e. darksky.yaml, openweathermap.yaml, etc) and did an "!include_dir_merge_list weather/ " it seem to work for a moment then start switching between one weather component over the other and not sure why.

Thanks in advance for any advice.

Definitely can have multiples. I use 3 and I have them in a package I made… never used the include dir though. Maybe look in the ‘cookbook’ to make sure you have the syntax/structure right for doing that.

Thanks never done a package as of yet can you post what you did?

see timetides.yaml and weather.yaml here https://github.com/DavidFW1960/home-assistant/tree/master/packages

Thanks David I saw how you had it in the package. I like that. I have an Accurite Stations so planning on adding that.

David I liked the way you did you package on the weather.yaml but I seem to get an error when I did it. Now my Darksky sensor for some reason are worded different than yours “darksky_weather” vs “dark_sky” so I made those changes to the file. My icons are in the exact same spot as yours and changed Moon to “N” for the Northern Hemisphere. I am getting this error “expected a dictionary for dictionary value @ data[‘packages’][‘weather’]” Below is my file:

#####################################
#####  Darksky Weather Package  #####
#####################################

  - platform: darksky
    name: Darksky Weather
    api_key: !secret darksky_api_key
    forecast:
      - 0
      - 1
      - 2
      - 3
      - 4
      - 5
      - 6
      - 7
    monitored_conditions:
      - icon
      - summary
      - nearest_storm_distance
      - nearest_storm_bearing
      - humidity
      - temperature
      - temperature_high
      - temperature_low
      - apparent_temperature
      - apparent_temperature_high
      - apparent_temperature_low
      - wind_speed
      - wind_bearing
      - precip_type
      - precip_probability
      - precip_accumulation
      - precip_intensity
      - precip_intensity_max
      - uv_index
      - daily_summary
      - pressure
      - visibility
      - dew_point
      - wind_gust
      - cloud_cover
      - ozone
      - minutely_summary
      - hourly_summary
      - moon_phase
      - sunrise_time
      - sunset_time
    scan_interval:
      minutes: 5

  - platform: season
    type: astronomical

  - platform: template
    sensors:
      forecast_0:
        entity_id:
          - sensor.darksky_weather_daytime_high_temperature_0d
          - sensor.darksky_weather_overnight_low_temperature_0d
          - sensor.darksky_weather_precip_probability_0d
        friendly_name: "Today"
        value_template: >
          {{states.sensor.darksky_weather_daytime_high_temperature_0d.state|round(0)}}°/{{states.sensor.darksky_weather_overnight_low_temperature_0d.state|round(0)}}°/{{states.sensor.darksky_weather_precip_probability_0d.state|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/dark_sky/' ~ states.sensor.darksky_weather_icon_0d.state ~ '.png'}}

      forecast_1:
        entity_id:
          - sensor.darksky_weather_daytime_high_temperature_1d
          - sensor.darksky_weather_overnight_low_temperature_1d
          - sensor.darksky_weather_precip_probability_1d
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (1 * 86400 ) -%}
          {{ date | timestamp_custom("Tomorrow (%d/%m)") | replace("(0", "(") | replace("/0", "/") }}
        value_template: >
          {{states.sensor.darksky_weather_daytime_high_temperature_1d.state|round(0)}}°/{{states.sensor.darksky_weather_overnight_low_temperature_1d.state|round(0)}}°/{{states.sensor.darksky_weather_precip_probability_1d.state|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/dark_sky/' ~ states.sensor.darksky_weather_icon_1d.state ~ '.png'}}

      forecast_2:
        entity_id:
          - sensor.darksky_weather_daytime_high_temperature_2d
          - sensor.darksky_weather_overnight_low_temperature_2d
          - sensor.darksky_weather_precip_probability_2d
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (2 * 86400 ) -%}
          {{ date | timestamp_custom("%A (%d/%m)") | replace("(0", "(") | replace("/0", "/") }}
        value_template: >
          {{states.sensor.darksky_weather_daytime_high_temperature_2d.state|round(0)}}°/{{states.sensor.darksky_weather_overnight_low_temperature_2d.state|round(0)}}°/{{states.sensor.darksky_weather_precip_probability_2d.state|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/dark_sky/' ~ states.sensor.darksky_weather_icon_2d.state ~ '.png'}}

      forecast_3:
        entity_id:
          - sensor.darksky_weather_daytime_high_temperature_3d
          - sensor.darksky_weather_overnight_low_temperature_3d
          - sensor.darksky_weather_precip_probability_3d
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (3 * 86400 ) -%}
          {{ date | timestamp_custom("%A (%d/%m)") | replace("(0", "(") | replace("/0", "/") }}
        value_template: >
          {{states.sensor.darksky_weather_daytime_high_temperature_3d.state|round(0)}}°/{{states.sensor.darksky_weather_overnight_low_temperature_3d.state|round(0)}}°/{{states.sensor.darksky_weather_precip_probability_3d.state|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/dark_sky/' ~ states.sensor.darksky_weather_icon_3d.state ~ '.png'}}

      forecast_4:
        entity_id:
          - sensor.darksky_weather_daytime_high_temperature_4d
          - sensor.darksky_weather_overnight_low_temperature_4d
          - sensor.darksky_weather_precip_probability_4d
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (4 * 86400 ) -%}
          {{ date | timestamp_custom("%A (%d/%m)") | replace("(0", "(") | replace("/0", "/") }}
        value_template: >
          {{states.sensor.darksky_weather_daytime_high_temperature_4d.state|round(0)}}°/{{states.sensor.darksky_weather_overnight_low_temperature_4d.state|round(0)}}°/{{states.sensor.darksky_weather_precip_probability_4d.state|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/dark_sky/' ~ states.sensor.darksky_weather_icon_4d.state ~ '.png'}}

      forecast_5:
        entity_id:
          - sensor.darksky_weather_daytime_high_temperature_5d
          - sensor.darksky_weather_overnight_low_temperature_5d
          - sensor.darksky_weather_precip_probability_5d
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (5 * 86400 ) -%}
          {{ date | timestamp_custom("%A (%d/%m)") | replace("(0", "(") | replace("/0", "/") }}
        value_template: >
          {{states.sensor.darksky_weather_daytime_high_temperature_5d.state|round(0)}}°/{{states.sensor.darksky_weather_overnight_low_temperature_5d.state|round(0)}}°/{{states.sensor.darksky_weather_precip_probability_5d.state|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/dark_sky/' ~ states.sensor.darksky_weather_icon_5d.state ~ '.png'}}

      forecast_6:
        entity_id:
          - sensor.darksky_weather_daytime_high_temperature_6d
          - sensor.darksky_weather_overnight_low_temperature_6d
          - sensor.darksky_weather_precip_probability_6d
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (6 * 86400 ) -%}
          {{ date | timestamp_custom("%A (%d/%m)") | replace("(0", "(") | replace("/0", "/") }}
        value_template: >
            {{states.sensor.darksky_weather_daytime_high_temperature_6d.state|round(0)}}°/{{states.sensor.darksky_weather_overnight_low_temperature_6d.state|round(0)}}°/{{states.sensor.darksky_weather_precip_probability_6d.state|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/dark_sky/' ~ states.sensor.darksky_weather_icon_6d.state ~ '.png'}}

      forecast_7:
        entity_id:
          - sensor.darksky_weather_daytime_high_temperature_7d
          - sensor.darksky_weather_overnight_low_temperature_7d
          - sensor.darksky_weather_precip_probability_7d
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (7 * 86400 ) -%}
          {{ date | timestamp_custom("%A (%d/%m)") | replace("(0", "(") | replace("/0", "/") }}
        value_template: >
            {{states.sensor.darksky_weather_daytime_high_temperature_7d.state|round(0)}}°/{{states.sensor.darksky_weather_overnight_low_temperature_7d.state|round(0)}}°/{{states.sensor.darksky_weather_precip_probability_7d.state|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/dark_sky/' ~ states.sensor.darksky_weather_icon_7d.state ~ '.png'}}

      darksky_weather_current_text:
        value_template: '{% if is_state("sensor.darksky_weather_icon","clear-day") %} Clear 
                         {% elif is_state("sensor.darksky_weather_icon","clear-night") %} Clear 
                         {% elif is_state("sensor.darksky_weather_icon","rain") %} Rain
                         {% elif is_state("sensor.darksky_weather_icon","snow") %} Snowy
                         {% elif is_state("sensor.darksky_weather_icon","fog") %} Foggy
                         {% elif is_state("sensor.darksky_weather_icon","sleet") %} Sleet
                         {% elif is_state("sensor.darksky_weather_icon","wind") %} Windy
                         {% elif is_state("sensor.darksky_weather_icon","cloudy") %} Cloudy
                         {% elif is_state("sensor.darksky_weather_icon","partly-cloudy-day") %} Partly Cloudy
                         {% elif is_state("sensor.darksky_weather_icon","partly-cloudy-night") %} Partly Cloudy
                         {% elif is_state("sensor.darksky_weather_icon","hail") %} Hailing
                         {% elif is_state("sensor.darksky_weather_icon","lightning") %} Lightning
                         {% elif is_state("sensor.darksky_weather_icon","thunderstorm") %} Thunderstorm
                         {% endif %}'

Forecast 6 & 7 seem to have different spacing for the value_template is all I can see that looks wrong but I doubt that would be the problem.

Ok I will try that since Yaml is unforgiving at times in spacing

I’ve just gone through and revamped ALL my packages to use states(‘sensor’) etc rather than states.sensor.state etc… so maybe grab the latest package as well?

gdreelin

2h

Yeah I saw that. I did fix the spacing but no joy there. I will check out the packages again.

Also out of curiosity I saw a few sensors you use in your configurations but not sure how you got them?

sensor.sunrisesunset
sensor.systemuptime
updates.yaml has a bunch but it seems that it is missing custom configs for a reason? I did like how you did that to check the config if they are updated.
lastboot.sh - I see some of your shell scripts being used but this one and uptimemeas.sh don’t seem to be running?
Lastly I see your new file of suntimes.sh and suncomponent.py which seems to be an update to your Tide package? but I did not understant this part below:

Home Assistant Config

creds=$(cat abbusage/abbcreds.json)

creds=$(cat /usr/share/hassio/homeassistant/abbusage/abbcreds.json)

server=$(echo “$creds” | jq -r ‘.server’)
token=$(echo “$creds” | jq -r ‘.token’)

Well you are digging deep!!
sensor.sunrisesunset is created by the suntimes.sh & suncomponent.py. It reads the secrets.yaml and expects to fine my_latitude, my_longitude, my_elevation and my_timezone. It gets the sun info for the sensor.sunrisesunset But it also uses another file I create in a different script that gets my ISP usage data, config/abbusage/abbusage_ha.sh but there’s a json file with my credentials and also contains my home assistant server IP address and also a long term access token so I can write to the sensor. You could just write those values in the script. (There is a abbusage directory containing the abbcreds.sh script that creates the creds file…) I’d just hard code them in the suntimes.sh.

not sure what you mean there?

lastboot.sh - I don’t use that anymore as it’s included in the systemmonitor platform I call in sysmonitor.yaml package. Similarly I calculate the uptime in that package as well so I don’t use the uptimemeas.sh script either.

Hope that explains what I am doing and why.

Note there is a new sun2 custom component that you could use for the sun stuff. With the recent updates to the core component sun.sun, I got the sense that the dev of the custom component wasn’t tnthusiastic to update his custom one for all the new functions so that’s why I did the scripts for that as I wanted the day lengths as well as sunset/sunrise times. Turns out Phil wrote a new custom component sun2 to get that info so I coutd use that too.

It’s all a good learning experience.

Ah got it now… So I removed the abbusage part since my ISP does not have a way to get usage data yet they are new in the fiber business. So to get this right if I run the shell suntimes.sh it uses the .py file to gather information so it has to be in same directory? I did see the change from the sun to sun2.

Check on the lastboot.sh and uptimemeas.sh I figured that since I couldn’t see where you used them and the sysmonitor.yaml worked with some tweaking.

The last part was getting the information on the updates of HASSIO in the updates.yaml. You have the below:

sensor.hass_installed_version:
  <<: *customize
  friendly_name: 'Hass.io Installed Version'
  icon: mdi:check-decagram

I was not sure what the “<<: *customize” was if that was some custom stuff you had that you did not want people to see. I was not 100% sure how you had that Yaml package working. Sorry for digging deep I just liked some of you dashboard setups for information. It is very clean and provides useful information. Love your weather page the most. I wish we had the fire level here in the US since that is important where I live in the mountains. Thank you a bunch for all the help.

Most of that system updates inc the stuff you quoted was in something I copied from someone else - theres nothing more or hidden that isn’t in there. In fact the only thing I hide in my whole github is my secrets file and the json files with mt credentials and tokens and the .storage folder of course but everything else there is exactly as it is in my files.

Oh ok awesome again thanks for the help

FWIW I just switched my templates in the package to use sun2…

David, I have been able to work out most of the kinks but this one on a card. It was the card titled Season, Sun & Moon Phase. I did it line by line and this line keeps coming out with that information instead of the way yours shows in the second picture. I am still not getting the readings to work right but getting close each time. I am not sure if anything has to do with being in the US verses being in Australia. If the sun.sun get the elevation based on HA configs it should work. In the weather.yaml and tide.yaml besides the one where you have to change from S to N for northern hemisphere are there any other settings that need to change?

entity: sun.sun
name: “${‘Sun Elevation:’ + ‘_’.repeat(2) + states[‘sun.sun’].attributes[‘elevation’] + ‘°’ }”

Thanks a bunch for all your help.

did you load the config-template custom card?
Also I changed my weather and the time & tides packages so you are seeing blanks for the daylengths as well. The weather package fixes the ywthr as well. I also did switch to sun2 custom component.

Yeah the card is loading. I did make correction from your new packages and to the sun2 component. I will go through it line by line again.