[SOLVED] Australian Bureau of Meteorology Weather Forecast Binding

That’s why I had ADD in uppercase :slight_smile:

Now the fun part starts because to find the BOM stuff wasn’t that easy.

Also if you want to use the BOM icons then there is a whole world of pain to get the icons to show up because they have dashes in the file name which is a openhab reserved thing so I had to rename the icons and put underscores in them BUT then you have to run javascript transform on the icons.

I wrote a script to do that in bash it is a rough script but you only need to run it once:

#!/bin/bash
#This grabs the icons that can be used in OH3
//wget http://www.bom.gov.au/images/symbols/large/sunny.png

cd /etc/openhab/icons/classic/

for ICON in storm sunny clear cloudy hazy light-rain wind fog showers rain dust frost snow light-showers heavy-showers partly-cloudy light-rain 
do
sudo wget -N http://www.bom.gov.au/images/symbols/large/$ICON.png

done

#mostly-sunny is partly-cloudy so put both icons there
sudo cp partly-cloudy.png mostly_sunny.png
#wind is windy so put both icons there
sudo cp wind.png windy.png
#dust is dusty so put both icons there
sudo cp dust.png dusty.png
#light-showers is light-shower so put both icons there
sudo cp light-showers.png light-shower.png
#showers is shower so put both icons there
sudo cp showers.png shower.png

#dashes are not allowed in the sitemaps etc unless they are dynamic
#replace dashes with underscores. I have a rule that converts the dash to underscore 
#so I can use icons

sudo mv partly-cloudy.png partly_cloudy.png
sudo mv light-showers.png light_showers.png
sudo mv light-shower.png light_shower.png
sudo mv light-rain.png light_rain.png
sudo mv heavy-showers.png heavy_showers.png

sudo chown openhab:openhab *.png

Also because the dashes from the bom addon are not supported you have to use underscores.

To do this install transform javascript Restart openhab after installing the transform

Then under the transforms directory create a javascript file and call it dashreplace.js:

(function(i) {
return i.replace(/-/g,‘_’);
})(input)

save the file

The go to the BOM_Day1_ForecastIcon item and find the profile JS and then add the name dashreplace.js in there. Like below.

.

Also in the date for the BOM_Day1_ForecastDateAndTime etc you have to put in the date format you want in the metadata state description
I used %1$tA %1$tb %1$td

You will have to do the above 8 times as there are 8 forecasts and icons.

The BOM addon you need to find and replace the word default with the name of the BOM thing.
It is in the thing decsription. Something like this: bom:weather:1ecb389f21

Find default and replace with 1ecb389f21

And to save you the hassle of creating 100’s of items.
Go here:
https://raw.githubusercontent.com/tomitan100/org.openhab.binding.bom/master/doc/bom.items

Copy all the items into clipboard.

Go to OH3 go to items then press the blue + sign lower left to create an item BUT select add items from Textual Definition

Paste the clipboard in there then press add.
This will add all the items you need for the BOM thing. Then you can use the ones you want to link to the thing.

Hope that helps…

Then you will be able to do things like this:


The code for the above looks similar to this:

component: oh-label-card
config:
  title: =(items.BOM_Day2_ForecastDateAndTime.displayState)
  footer: ="Min " +" "+(items.BOM_Day2_MinimumTemperature.state) + "  Max "
    +(items.BOM_Day2_MaximumTemperature.state)
  item: BOM_Day2_ForecastDescription
  fontSize: 12px
  fontWeight: bold
  icon: ="oh:"+(items.BOM_Day2_ForecastIcon.state)
  vertical: true

Good luck.

Thanks @ubeaut. Thankfully I saved the config from my previous install so that part was was easy. The forecast list looks great - thanks for sharing.

Glad to be able to assist. It took me over a week to workout how to use the BOM icons and the naming etc. The forum helped my there.

Hope the instructions were easy to follow. They were just notes I did for myself and another person who was doing the same thing.

1 Like

@tomitan just installed OH3.1-M3 the other day, it broke the BOM binding unfortunately, here is the log entries:

2021-04-21 14:57:18.493 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab/addons/org.openhab.binding.bom-3.0.0-SNAPSHOT_201218.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.bom [208]
  Unresolved requirement: Import-Package: org.apache.commons.lang; version="[2.6.0,3.0.0)"

        at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi-3.12.100.jar:?]
        at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1221) [bundleFile:3.6.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:515) [bundleFile:3.6.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4]

Any thoughts greatly appreciated.

Same here. It seems org.apache.commons.lang is being removed as a dependency across Openhab in 3.1, and bindings need to be updated.

If you just want a forecast then you can use this:
https://github.com/ubeaut/openhab3-BOM-program/
It has no binding or thing. Just one item.
It just does forecast only.

1 Like

Thanks Greg. I actually use it more for the current observation - maybe I should just build myself a weather station!

Yes I have my own weather station and use weewx software. It is good.

1 Like

Tried (for ages) it but it’s geared towards using the OH3 ui and it’s internal configuration, I use basicui and text files only, so this is not an option unfortunately. Since downgraded back to 3.0.2 so the orig binding works again.

Also the get-icons.sh script doesn’t run any longer, returns 403 Error, BOM recently locked down using wget or curl to grab images, which is a pain. I used to download Radar and Sattelite images for my weewx (own weather station also) page and can no longer do that, they have a form to fill out for permissions, done that over a week ago and haven’t had a reply yet.

I have updated the get-icons script to use curl and it should work now.

you can also use the same logic to get your Radar and satellite images.

1 Like

Beautiful @ubeaut , that curl statement works great with my radar images. I used to use curl basically barebones (only url and output options, oh and a retry count), but all that Header stuff worked a treat, so at least my weewx page will be happy, LOL.

Previously I got the icons manually anyway, just went to the url and saved them from the browser.

Thanks so much for responding so quickly, if I can get it to work with text file only configuration I’ll let you know.

You should be able to get text files to work as it is just an item. I haven’t tried. I pretty much use OH3 but I do still have a site map but don’t use it much now.

OH3 is great so far. I converted all the DSL rules to javascript.

If you get it to work put up how you did it.

Glad it worked for you.

1 Like

Here is my overview page with the weather on it.
I think it is better than the site map way.

1 Like

That’s the main problem I have so far Greg, putting the rules file in the rules directory it generates errors galore, I’ve tried to edit them to lessen the errors, which has worked to a degree, but haven’t been able to eleminate them all so far.

EDIT: I might try and add them as a script and then call them from normal rules using cron to trigger the script every so often. Also trying to debug my milight lighting atm, so unfortunately my time is divided.

I’m an old bugger, always used text configs in not only OH, but everything. I detest gui helpers, sorry, but they’re just not my thing.

I am old too and I use vim and do heaps with text files but if there is an easier way to do something I will give it a go.

Hi all,

Here are version 3.0.x and 3.1.0.M3 distributions of the BOM binding.

Note that icon names with dashes have been replaced with underscores.

3.0.3-SNAPSHOT (for openHAB 3.0.x)

3.1.0.M3 (for openHAB 3.1.x)

Let me know if any issue.

Regards,
Tom

2 Likes

I don’t necessarily think it’s easier Greg, too abstract for me. And I often stop OH and delete ‘/var/lib/openhab/config, cache, jsondb & tmp’ directories before restarting again to clear out the crud. This would also delete anything I’ve created in the gui, I do keep several files aside which I copy back in place before the restart to keep some things consistent (basicui.config for example), but I don’t want to extend it much beyond that.

BTW: I tried running the rules file from a crontab in the standard rules file, but still errors I’m afraid.

Thanks for that Tom, as I mentioned to Greg I’ve reverted to OH-3.0.2, the old 3.0.0-SNAPSHOT (201218) still seems to work fine in that OH version. I’ll give the 3.0.3-SNAPSHOT a go soon and see how it goes.

Thanks Tom. I can confirm that the 3.1.0.M3 version resolves the issue I was having on OH 3.1.

1 Like