Customising the BOM Weather and lovelace - now in HACS

I believe it was removed in 0.115.0. You can just remove it. Template sensors no longer need to be told which entities to track… they can work that out themselves. The docs for the card and sample templates have been updated to reflect this.

So if it’s not one thing, it’s another. The Core BOM integration is now removed in Home Assistant because it uses web scraping.
For now, I’m going to make it a custom component and I’ll put it in HACS as well but probably not make it a default repo. I think part of the ‘objections’ apart from it violating ADR-14 is that it’s the radar component that is causing the issue. Not sure why the observations also include the radar but there you have it and we have @theRat for radar now anyway.

I am just going to do some testing that I haven’t broken anything… then I will give you the repo to add to HACS etc…

Add this custom repo in hacs with this URL


https://github.com/DavidFW1960/bom_core_replacement

I’ve been running dev or 0.117 for a while and saw the card wasn’t working again but at least this is a simpler fix this time…

1 Like

The BOM core component is being removed in 0.117 due to the use of web scraping. In the spirit of Hacktoberfest I am going to work on rebuilding the BoM integration without the use of web scraping with the short term goal of having it released on HACS and then long term hopefully home assistant core.

3 Likes

That is awesome Brendan… I thought eventually someone would do that. Excellent.

FYI: working well for me.

1 Like

Are you aware that there is a new way to get weather data from the BoM that returns data as JSON? For example to get the observations from the closest weather station to a location use:

https://api.weather.bom.gov.au/v1/locations/r3dnb6/observations

The weird number is a geohash of Lat/Lon. This website will calculate it for you. Make sure to set the precision to 6.

http://geohash.co/

Unfortunately the observations don’t include any air pressure data. :frowning:
There are other endpoints for warnings, daily forecast, 3 hourly forecast. To see all there have a look at

https://weather.bom.gov.au/

Unfortunately you still have to poll regularly for the data as the BoM still hasn’t caught up with modern technology. I am not sure if this is still considered web-scarping or not, but it is more efficient that what is currently being done.

1 Like

I suggested that to Brendan on his Repo yesterday… I think we chatted about this recently didn’t we?

Regarding AirPressure I think it does publish them for SOME stations but not all.

I think it got mentioned in some emails.

The Air Pressure data is not included in the this json data. They normally only have it for stations based at airports. But I just double checked the data provided for Canberra Airport (station 070351) and it is not included.

I just checked Sydney too and you’re right. Brendan said he’s going to use FTP anyway.

The JSON API seems pretty awesome, and it’s much better to only download the data for your specific station rather than a 300kB file each time. I’m just hesitant because it’s an undocumented API, which could change without consultation or warning. I’m leaning towards using this API for ease of use.

I doubt the json will change any time soon. It was implemented for the new version of the BoM mobile app. I have checked it uses the same thing as I rooted my phone and mitm decoded the https. But it does lack pressure info.

I will keep using my mqtt version of the sensors most likely anyway for observations. I have been tempted to ask the BoM why they don’t publish data on mqtt so that everyone wasn’t constantly polling. The desktop and mobilie versions of the new website download warning data every minute and everything else ever 5 minutes. For data that doesn’t change that often this is crazy.

2 Likes

Another thing to consider is the difference between observations and forecasts.

Forecasts exist for every location in Australia by coordinates. They are generated by a super computer running multiple models. So you can get a forecast for your suburb which will differ from that of the nearest observations station.

Observations are only available for fixed locations where the BoM has hardware to measure. Interestingly not all of these are in the ftp data. For example there is a weather station at Mangrove Mountain (id: 061375) that is not included in the ftp data.

2 Likes

the current BOM integration actually uses the JSON content for some of the calls:

    def _build_url(self):
        """Build the URL for the requests."""
        url = (
            f"http://www.bom.gov.au/fwo/{self._zone_id}"
            f"/{self._zone_id}.{self._wmo_id}.json"

and ftp:

def _get_bom_stations():
    """Return {CONF_STATION: (lat, lon)} for all stations, for auto-config.

    This function does several MB of internet requests, so please use the
    caching version to minimize latency and hit-count.
    """
    latlon = {}
    with io.BytesIO() as file_obj:
        with ftplib.FTP("ftp.bom.gov.au") as ftp:
            ftp.login()
            ftp.cwd("anon2/home/ncc/metadata/sitelists")
            ftp.retrbinary("RETR stations.zip", file_obj.write)

and scraping:

    for state in ("nsw", "vic", "qld", "wa", "tas", "nt"):
        url = f"http://www.bom.gov.au/{state}/observations/{state}all.shtml"
        for zone_id, wmo_id in re.findall(pattern, requests.get(url).text):
            zones[wmo_id] = zone_id

Hey all, I have created a custom component which pulls data from the new API, work in progress but I would love for you guys to test it. Works for me so far :slight_smile:

2 Likes

Well I didn’t see that coming… lol… this won’t co-exist with the current BOM Sensor at all… But otherwise working ok.
You know you could add the forecast information as well and that would then mean we don’t need the old FTP component either… That would be really cool as the old FTP component doesn’t support a lot of places but the new API does and it would also mean a lot of the issues people have with the card would go away as well…
I assume the dewpt and delta_t are not available? (I didn’t check) Otherwise same info as old core component.

Love this anyway…
Need to make some edits to my package and entities passing to the card…

Yes, I used the integration name “bom” which will overwrite the existing one, which is being removed anyway, but I guess that makes it hard to test.
I am planning to expand it to include all information offered by the new API, seems like it even does radar.

So far I haven’t seen dewpt and delta_t on the new API, not sure who would use these anyway.

1 Like

Yeah I’m removing the old one now… lol
This will be awesome when it includes all the forecast stuff as well…

So the old component used to say when it was last updated… is that attribute available? It used to be an attribute of the temperature

I wonder how it does that?

It took a bit to go through all my templates etc in my weather package and also had to remove the old ‘camera’ image provided by the old core component but I switched to a zoomed out version provided by Simon anyway. Just a PITA to have to rename and miss stuff so it took a while but that’s once off pain so hopefully people won’t be too upset. Once this is all done I’ll update the docs for the card… fun times.

The radar stuff is what I am using. It requires the use of leafletjs to pull the data from various sources. The bom only host the actual radar tiles (maps and overlays come from other sources).