I’ve stripped out a lot of the if statements, i’m just working on printing the day names in the forecast. Right now I have “tomorrow”,“second”,“third” etc. Either way, I was able to reduce the lines of code by about 30%. Also got rid of the dependency of having weekday_number and weekday sensors. Hopefully I can wrap up the changes soon and repost for you. I’ve also turned this into a package
That’s great! Thanks. I knew somebody could improve on this.
Alright, here’s how far I got tonight. It’s all in a package, and the names have comments for the template that would produce the correct rolling name. I haven’t figured out how to template the names yet. This may not be perfect, but it’s a start.
Very cool, I’m going to try out some of your modifications. Yes, templating the friendly names is one of the big issues I ran into. I don’t think I was ever able to get it working.
One comment, under forecast_fourth, the icon template sensor names still say “thursday” where they should say “fourth” (lines 163-181).
Woops, youre right! should be fixed now. Haven’t had time to look at the names more, but i’m sure there is a way.
Looks like some icons are not updated in HA. I cannot see partly-cloudy-night
and clear-day
.
That’s weird, they should be showing up. The code has those two icon states and their corresponding mdi icons.
I simplified everything to use entity_picture_template
. Instead of using mdi icons, which are not exactly similar to the dark_sky icons, I am not using the dark_sky icons directly.
The updated code is available here. I am still not entirely happy with the structure and will update it soon.
I updated the whole code to use python_scripts
that update the friendly names automatically. Here’s how it looks:
The python_script is here.
The weather package is available here.
This is fantastic! I would really like to incorporate this into my setup but I have a couple of questions.
-
I am not that familiar with including python_scripts, is that just an additional folder in my configuration setup? I saw that you have a line “python_script:” in your config file. I guess this doesn’t need an "!include . . " statement?
-
I also see you are referencing weather icons under your local folders. What icons are you using? Any chance you have a url to where you got them from?
Nice work to everyone on this.
Thanks!
so in configuration.yaml I need to include the weather.yaml file? Where do I put the python script? I’m running hassio…
thanks - looks great.
Under homeassistant:
in your configuration.yaml file, put packages: !include_dir_named packages
then create a folder called packages in your main configuration folder, and place weather.yaml in there.
For python scripts, add python_script:
to your configuration.yaml file, create a folder called python_scripts in your main configuration folder, and place dark_sky_friendly_names.py in there.
@arsaboo The python script to update the friendly names is great, nice work. One question: how do I make it so that it only updates the friendly name and leaves the icon alone? I tried commenting out lines 29 and 37, but it’s still not working, the icon is just the default eyeball. I want it to use the icon template I specify in the template sensor.
EDIT: I got it to work by replacing 'entity_picture'
with 'icon'
in lines 29 and 37. Not sure if there’s a better way to do it.
I’ve updated the original post to reflect the improvements to the code. Note I’ve made a few tweaks to make it work with the mdi icons as I originally wanted. Thanks @mconway @arsaboo for your improvements.
Guys…just realized that the code has some bugs that need to be fixed. I will try to fix them and, may be, create a new thread will all the necessary details.
What are the bugs? Seems to be working fine for me. Keep the updated code in this post if possible so it’s not the same information in multiple places. I’ll update the OP with any improvements.
EDIT: Ah I found one, the friendly names change back to “second”, “third”, etc. when the state gets updated. Should just need to add a trigger to the automation to run the name update script after any state change.
The friendly_name
is not retained during updates. I have updated the entire script to use triggers. I am not sure this is the final version, so instead of copying the code in the OP, please just link to this post so that readers can access the most recent version of the code.
Please the following script under python_scripts
You will also need the weather.yaml package.
https://github.com/arsaboo/homeassistant-config/blob/master/packages/weather.yaml
Thanks @arsaboo! I’ll update my configuration with this as well. I still prefer the MDI over the dark sky icons, but I’ll play with both and see which works best.
I have provided the link in the package.