Whoa there dude. It’s @BrendanMoran’s first go at this and he’s done way more than I ever could. For which a lot of us here are very grateful as the scraper we were using has started to be blocked. He’s still working on this custom component too.
In regards to your templates, I get ‘None’, ‘None’ and and 'Error rendering template: UndefinedError: ‘None’ has no attribute ‘attributes’ respectively.
I reckon we give Brendan a bit of time to have a look at it.
Edit: scratch that. The last two templates work. I forgot to put my location in [location].
My mistake, but if the attributes had the correct name format (no capitals and underscores) when referenced you wouldn’t be having these issues. Using spaces in the names doesn’t allow you to use it as an object unless the scraper formats and changes it to remove capitals and add underscores. But if that were also the case, when accessing the attributes, i’d expect the keys to reflect that change. Just my 2 cents, because it adds confusion.
I guess my goal with the friendly mode was to make it as user friendly and aesthetically pleasing as possible, which is my reasoning for using capitalisation and spaces for attributes. But you are right, that is quite a non-standard way to do things when compared to all other components and will create confusion down the track.
No offence taken Tom.
Petro, I understand you didn’t know the background of this discussion but calling a contributor an ass is a horrible default stance to take. We should be lifting each other up by default, work together, ya know?
I didn’t mean to call you an ass. I assumed this was a standard component and didn’t realize this was in a custom component thread. I’ve had run in’s with the dev’s. Any change I have made has always been met with an insane amount of criticism from the dev’s. I assumed that this went through that process and they made this conscious decision to have a miss matching attribute system. TLDR: I’m salty with ‘some’ dev’s and I’m sorry for directing that at you.
And just a further reinforcement that I’m very thankful to @BrendanMoran for his excellent work on this. I don’t know any python, but I’m inspired to have a crack at something too having seen what is possible with some determination. Nice one.
@petro really rocks and he is absolutely awesome with templates and stuff. Can’t speak too highly of him. Misunderstandings abound. Group hug guys!
Awesome work here too Brendan. I’m not blocked on BOM and I changed the scan interval to a couple of hours just in case but if I do get blocked I’ll be using this then. Thanks.
So here’s my final script for telling me the weekends weather forecast, thanks to help from the above posts.
Because I have my friendly format set up like this in my config
friendly: True
friendly_state_format: '{min} to {max} degrees. {chance_of_rain} chance of rain. {summary}'
Then I just put this script in my rising/sleep routines to get a weekend forecast from Wed to Fri.
forecast_this_weekend:
sequence:
- condition:
condition: template
value_template: "{{now().weekday() > 1 and now().weekday() < 5}}"
- service: notify.google_assistant
data_template:
message: On Saturday, the weather summary is {{ states.sensor['bom_forecast_melbourne_{}'.format(5 - now().weekday())].state }} On Sunday, the weather summary is {{ states.sensor['bom_forecast_melbourne_{}'.format(6 - now().weekday())].state }}
I’ve only done some basic testing, coz I’m and in a bit of a rush + testing is a little harder on the weekend, but it seems to be doing the job of announcing the weather over my Google Home (via Google Assistant Webserver).
Hey, I’m starting to tinker with Lovelace UI, and the weather cards are pretty nice. From what I understand your source needs to be be a “weather component” rather than “sensors”. Any thoughts on feasibility/effort/demand/value of changing or forking this as a weather component? I really dunno how that all works, just testing the waters… Lovelace UI Weather Forecast
Edit: Maybe I need to read some of the other threads on the topic a bit more carefully, I think there may be a way… I’ll look closer later, but will leave the post for thought fodder.
Another edit: It didn’t look so straight forward, so I’ve given up on it for the moment.
I’m flat out with work and family for the next 2 months or so (moving house, plus a baby and a toddler running around) so I am going to have to put updates to this custom component on hold for a while.
Hi Brendan, just FYI, my log is being flooded with these errors:
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 312, in async_update_ha_state
self.entity_id, state, attr, self.force_update, self._context)
File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 903, in async_set
context)
File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 673, in __init__
"State max length is 255 characters.").format(entity_id))
homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity id: sensor.bom_hobart_tomorrow_detailed_summary_1. State max length is 255 characters.
Might have to limit the length of the scraped data when you get a chance to have a look at this again.
Firstly, a huge kudos to @BrendanMoran for developing this sensor. I’d started something like this a couple of months ago but couldn’t have achieved what Brendan has (as I have no prior Python experience) so thanks for all of your efforts Brendan.
One of the main things I wanted to achieve was to see if there was rainfall predicted in the next few days so that I could prevent my HA controlled sprinklers from coming on.
When I first tried Brendan’s sensor, it allows a great display with the friendly sensors but to use the min_max sensor to get the highest level of predicted rainfall, I needed easy access to the chance_of_rain value which is difficult as an attribute. So I made a mod to this sensor to allow both the friendly and separate sensors to be created at the same time rather than having one or the other.
If it is of use to anyone else, I’ll try and figure out how to submit the change to GitHub for inclusion in Brendan’s sensor.