I having a hard time to successful scrape the fire risk for portugal from the “The Portuguese Institute for Sea and Atmosphere” in short IPMA (www.ipma.pt/en).
They offer a Wildfire Risk indicator on which base some things a allowed/prohibited by law (for example bbq , the use of firecrackers or smoking the bees out to get their honey ). The indicator itself has 5 different stages like this:
I just looked at the HTML code of the page itself and it appears that the data is actually stored in a lot of JavaScript code. That screenshot of the HTML structure is just what’s rendered in the web browser when you select a location.
The scrape sensor basically just downloads the HTML code and then tries to find values based on your select statements, but it doesn’t execute JavaScript to render the HTML.
Long story short: I don’t think you can use the scrape sensor on that page. And I don’t think there is any other standard integration that would help you.
All the JavaScript payload is embedded in that HTML page, so regex could be used to find the relevant data and extract it.
Absolutely agree, that would be the preference. Another option to look for is some standard format such as XML/RSS or JSON - much easier to extract data from such formats.
Good point. I actually already contacted IPMA last year and asked for a API for this data but (at this point) they didn’t have it for this particular information. The IPMA Weather Integration for Home Assistant from @dgomes makes use of this API.
I just went through all json examples but couldn’t find one fitting my use case.
If I’m looking at the json it represents all locations in whole portugal. They are unique by the identifier called “DICO”. I some how need to limit the return of the “rcm” value based by the definided “dico”.
I could do it with my hands tied behind my back in PHP.
If you have any way of hosting a PHP file then I can do it.
But I’m not yet good with yaml and all that
From here it looks like the update for the json file is daily at 09:05. Is their a way to force the update shortly after - let’s say daily at 09:10 for example?
I don’t know.
There is a service call called homeassistant.update_entity but when I use it on the entity it doesn’t do anything.
Perhaps because my force update is default (false) or because it does not work. But that is one thing you could try.
Change the force update to true on the sensor and create an automation to do this service call when time is 09:10
I got this now but it’s just the static picture. I tried with picture entity but it only allows two states. The conditonal card also can only show true and false.
Is there any lovelace card out they which can show picture 1 on value 1 - picture 2 on value 2 - picture 3 on value 3 and so on?
Been sleeping and had a thought.
Perhaps you can host those images locally and have all 5 numbered 1-5.
Then you have a sixth which is say ‘current.svg’.
In an automation when the level is changed you copy the ‘level.svg’ to ‘current.svg’.
That way you can have one picture card with static code and everything happens in the background.
I found this about copying files in HA,have never used it myself.