7 Day Weather Forecast

I have no done some changes. Does this look correct @DetroitEE ?

automation:
  - alias: "Update friendly names"
    initial_state: 'on'
    trigger:
      - platform: homeassistant
        event: start
      - platform: state
        entity_id:
          - sensor.forecast_1
          - sensor.forecast_2
          - sensor.forecast_3
          - sensor.forecast_4
          - sensor.forecast_5
          - sensor.forecast_6
          - sensor.forecast_7
    action:
      - service: python_script.dark_sky_friendly_names
        data_template:
          entityid: '{{trigger.entity_id}}'

All i get its this:
image

Use this file if you want custom icons:

https://github.com/arsaboo/homeassistant-config/blob/master/packages/weather.yaml

Have change my weather.yaml to the one you show.
Now iā€™m just missing the custom icons. Not sure what i am doing wrong. have followed all steps with icons and script.
image

This is the icon folder:

my icon is located at /homeassistant/www/dark_sky/****.png

and save them under /www/dark_sky/ in your configuration directory.

I see this in my python_script. is this corrcet when you have icons in www/dark_sky/ png folder?

        entity_picture_template: >-
          {{ '/local/icons/dark_sky/' ~ states.sensor.dark_sky_icon.state ~ '.png'}}

I use his share with the python_script. all png files from darksky is located /homeassistant/www/dark_sky/****.png to get its display in frontend.

After change the directory of png donā€™t forget to restart your HA

This is now my location of png files:
image

I am sorry if this is a stupid question. but what is ****. in you location?

Youā€™re right, the icons need to be in the www/icons/dark_sky/ folder.

@arsaboo It looks like you updated your code to add an icons folder in front of dark_sky. Please update the comments at the beginning of the code with the correct location for users to put the icon PNGs.

regarding from you comment:
entity_picture_template: >-
{{ ā€˜/local/icons/dark_sky/ā€™ ~ states.sensor.dark_sky_icon.state ~ ā€˜.pngā€™}}

This mean /homeassistant/www/icons/dark_sky/all_png_files_here
homeassistant directory>www folder>dark_sky folder> png files.

Got it to work! Thanks for the help :slight_smile:
If i want to change language on the weekdaysā€¦ i do that in python script?

image

Done :slight_smile:

Iā€™m having the same issues. Iā€™ve tried several times and home Assistant locks up after restarting. I can access the files in samba shares but home Assistant webpage doesnā€™t load at all.

This typically means there is an error in the code somewhere. What does the error log say?

Pardon the ignorance. Iā€™m completely new to this and have very limited experience with any programming. Really good at copy and pasting though :slight_smile:.

Iā€™m not at home now to look it right now but when I checked my config I was seeing errors referencing homeassistant.util.yaml and animations.yaml. Iā€™ll try again this evening and take a snap shot and post it.

Thanks

For those struggling with python_script, you can achieve same results using customizer. You can use the following automation to update the friendly_name.

automation:
  - id: update_friendly_names
    alias: "Update friendly names"
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id:
          - sensor.forecast_1
          - sensor.forecast_2
          - sensor.forecast_3
          - sensor.forecast_4
          - sensor.forecast_5
          - sensor.forecast_6
          - sensor.forecast_7
    action:
      - service: customizer.set_attribute
        data_template:
          entity_id: '{{trigger.entity_id}}'
          attribute: friendly_name
          value: >
            {%- set day = (as_timestamp(now()) + (trigger.entity_id.split('_')[1]|int * 86400)) | timestamp_custom("%A", True) -%}
            {%- set month = (as_timestamp(now()) + (trigger.entity_id.split('_')[1]|int * 86400)) | timestamp_custom("%-m", True) -%}
            {%- set date = (as_timestamp(now()) + (trigger.entity_id.split('_')[1]|int * 86400)) | timestamp_custom("%-d", True) -%}
            {{ day }} ({{month}}/{{date}})

You will also probably have to run something along these lines on HA start to initialize the names.

2 Likes

you mean like this?

trigger:

  • platform: homeassistant
    event: start

Yes, but the action part will have to be modified too as trigger is not an entity. Basically, you will have to write 7 actions with service: customizer.set_attribute, one each for forecast_1 to forecast_7 and instead of using trigger.entity_id.split('_')[1]|int, just manually enter the forecast day.

like this?

alias: "Update friendly names"
initial_state: 'on'
trigger:
  - platform: homeassistant
    event: start
action:
  - service: customizer.set_attribute
    data_template:
      entity_id: 'sensor.forecast_1'
      attribute: friendly_name
      value: >
        {%- set day = (as_timestamp(now()) + (trigger.entity_id.split('_')[1]|int * 86400)) | timestamp_custom("%A", True) -%}
        {%- set month = (as_timestamp(now()) + (trigger.entity_id.split('_')[1]|int * 86400)) | timestamp_custom("%-m", True) -%}
        {%- set date = (as_timestamp(now()) + (trigger.entity_id.split('_')[1]|int * 86400)) | timestamp_custom("%-d", True) -%}
        {{ day }} ({{month}}/{{date}})

Not going to lieā€¦ the real take away for me is the combining data onto one line to conserve spaceā€¦ for a tablet thatā€™s huge!

Now if thereā€™s a way to get graphing to work nicely for thatā€¦ it would be epic.

Thatā€™s exactly why I did wanted to make this in the first place. I wanted a forecast, but the thought of endless groups of sensors with a bunch of empty white space made me cringe.