Generating derived weather calculations with the Weather Calculations Binding

(Bill Welliver) #1

Hi All,

During the course of writing a binding for the WeatherFlow SmartWeather series of weather stations, it occurred to me that some of the data presented by weather stations is derived from actual observations, and thus isn’t specific to any one product. Hoping to make life easier for other folks who have weather stations that are (or might be) supported by OpenHAB in the future, I created a binding that generates these derived values.

This binding is called Weather Calculations and you can find the source code and latest binary jar here:

The binding works by listening to channels that provide temperature, humidity and pressure, then creating channels for data points that are derived from those observations.

Some of the derived data include:

  • sea level pressure
  • feels like temperature
  • heat index
  • humindex


To use it, install the jar in your addons folder and then add an instance of a Weather Calculations thing. In the configuration for your new thing, you specify things like station altitude and the names of the channels that provide the various observations used (you will need to copy and paste the channel names as OpenHAB doesn’t provide a way for me to create a dropbox for them).

The binding expects SI values (temp in C, pressure in mbar), and is smart enough to change values only when an observation that it uses changes.

I’ve got a few more calculations in the works including pressure trend and prevailing wind so I will post back here when I’ve got meaningful new versions of this binding.

As always, comments and suggestions are welcome!


Calculate atmospherical pressure trend
[SOLVED] Calculating windchill
Formulas for temperatures in rules
Weatherflow Smart Weather Station binding
Announcing OpenWeatherMap binding for Eclipse SmartHome / openHAB
OpenWeatherMap condition icon
(Jürgen Baginski) #2

Why didn’t you publish your new binding through the channels supported by OH? That way your binding would be checked by admins and could end up as an official binding (and being installable via PaperUI).
Of course you could end up with a reply like: " We already have such a binding"

In case you haven’t seen: Contributing guidelines

(Bill Welliver) #3

I’m not opposed to contributing this binding (or any of the other bindings I’ve put together, for that matter). Because making changes is probably complicated by contributing it, it probably makes sense to wait until I get the features I need personally completed.

The limiting factor is that my time is pretty limited so if the process of getting it included is too onerous, it’s probably a better use of my time (for me personally) to keep the repository separate.

I did look at adding it to the IOT marketplace but I didn’t really get too far before running into trouble.

I’d also be happy to donate the code and let someone else attempt to integrate it to one or the other.

Possible crazy idea: Perhaps there’s an opportunity for some sort of loose organization that works to get tested versions of addons from willing contributors into the marketplace or openhab-addons or whatever. I’ve had conversations with a number of people who would like to help but aren’t java developers. Perhaps this is a way to get them involved.

(Jürgen Baginski) #4

For me personally it was some effort to get the binding accepted. However, I learned a lot during the process! To get something “working” can be totally diferent to make something work like it should work (that way other are able to take-over afterwards).
As for the marketplace, your binding could be used by others the same way as you posted without even publishing it on the marketplace. When you publish your (intermediate) work on github and file a pull request (PR), other can see the code and take the .jar from there.

As for your crazy idea: This “some sort of loose organization” is the open source community, which works only if people are wiling to contribute, no one “makes” them do it. If YOU decide to contribute, YOU do, if not…

(Bill Welliver) #5


It is certainly to be expected that there’s always room for code improvement, especially when it involves a project as complicated as OpenHAB. My primary concern is good stewardship of my limited time: I don’t want to go down a potentially endless tunnel trying to contribute something officially and have it end up going nowhere. I’ve been there before and it’s pretty unsatisfying. It’s certainly fair to argue that I may have too many irons in the fire, as the saying goes, but it’s the unfortunate reality I inhabit.

It’s possible the roadblock I ran into when submitting things to the IOT marketplace was easily resolved, but I just haven’t gotten back to it. I think that the market place is a good middle ground: making things visible and easily install-able without having the potential overhead (or hassle if you are a cynic) of contributing it directly to openhab/esh. It would be especially nice if there were a maven plugin that could facilitate publishing once a new version was validated…

My crazy idea was really about suggesting an opportunity for division of labor… especially if there are people who want to help but who don’t consider themselves coders. I’ve written a bunch of code that others may or do find helpful and have made it easily available, which I think is a meaningful contribution. I’m not not sure it makes sense for me personally to spend the time required from taking these bindings from “drop it in your addons folder” to showing up in the IOT marketplace or having it incorporated as part of the openhab or esh distribution.

I hope that this doesn’t sound like I’m not interested in participating in the openhab community; far from it. I’m just trying to find the balance that works for me (so that I don’t ignore the others that I contribute to). :slight_smile:

(Rich Koshak) #6

The only thing I will add to opus’s comments is if you release a binding to the IoT Marketplace you probably drop your audience of potential users down to 10-20% of all OH users. If you distribute it yourself like this the audience of potential users probably drops below 1%.

If you want this binding to actually be used and useful for the wider OH community, it will need to be at least made available in the IoT Marketplace.

If you are worried about whether or not the binding would be accepted create a new issue, mark it as WIP and discuss it there.

This is admittedly an unusual binding and the ESH folks may already have an alternative way to integrate capabilities like this that do not involve bindings.

For me, there are not enough docs and examples here or at Bitbucket to test it out.

(Bill Welliver) #7

Well, if you consider that every weather app provides measurements derived from the basic observations, it’s not that unusual to want to save each weather station binding from having to implement them all. It’s possible that the way I chose to solve the problem is a bit unusual in the larger scope of things OpenHAB-wise, but it seems to solve the problem in a fairly elegant way. I’m not aware of another approach used elsewhere (and there is an open discussion about how to provide this sort of facility).

Size of audience isn’t really something I’m terribly concerned about; it’s nice if people find it useful and all, but if not, that’s okay, too. If someone else feels strongly enough that they want to take a role in expanding its visibility, I’m open to hearing from them.

It’s still a work in progress, so formal documentation isn’t ready yet. However, there really isn’t much to explain about its use, it’s installed and added in the standard way, and the configuration values are pretty self explanatory. The only potentially complicated thing is that you have to provide the names of the Channels that provide the data to be used in calculations. You will have to copy the channel name for temperature/pressure/etc from the appropriate thing… it will vary depending on what weather sensors you are using.

For example, my temperature item is called weatherflowsmartweather:air:HB-000XXXXX:AR-00XXXXX:temperature.

(Rich Koshak) #8

That is all I meant. And because of that there might be a different approach that the maintainers are working towards. There is in work a units conversion service (e.g. separates out conversion between C and F for example) and they might feel that is more appropriate there. That is why I recommended opening an issue labeled as WIP.

Since you have no interest in going through the effort the whole argument is moot anyway.

I don’t use PaperUI for this sort of thing. So how do I write a Thing in a .things file? I’m assuming that your “then add an instance of a Weather Calculations thing” is referring to that. There are at least five different ways to add a Thing in OH.

But again, the argument is moot. I’m just here to help out where I can. I like the idea of this binding but have no use for it personally.

But that is just my point. I think lots and lots of people would find the binding incredibly useful. But only making it available in this way cuts off that vast majority of those people from being able to benefit.

(Bill Welliver) #9

I’ve uploaded a new snapshot of the Weather Calculations module.

Some new features:

  • Supports Units of Measurement, so should be able to display data in Metric or Imperial units.
  • Includes a first attempt to provide Atmospheric Pressure Trend
  • Should be possible to specify the various data sources using Channel ID (ie the identifier visible in PaperUI with colons) or Item Name (which appear in the log files and separate components with underscores).

This version requires OpenHAB 2.3. As always, comments and suggestions are welcome!

Download available from:

Calculate atmospherical pressure trend
(Vincent Regaud) #10

Hi @hww3

I have just installed you binding,

Couple of issues…

2018-07-20 10:53:48.129 [WARN ] [s.handler.WeatherCalculationsHandler] - Got an event for an item we're not interested in: WindSpeedMph. Perhaps a bug lurks here.

WindSpeedMph is an item I put in the binding config and then changed later but it is still trying to do something with it.

And also I keep getting these:

2018-07-20 12:08:48.107 [WARN ] [s.handler.WeatherCalculationsHandler] - Item AtmosphericPressure changed to 1014.71 bar
2018-07-20 12:08:48.111 [WARN ] [s.handler.WeatherCalculationsHandler] - Item OutsideHumidity changed to 50.0 %
2018-07-20 12:08:48.145 [WARN ] [s.handler.WeatherCalculationsHandler] - Item WindSpeedMs changed to 6.84 m/s

Why is your binding posting WARN level logs for these events when they should be TRACE level?

(Bill Welliver) #11

Hi @vzorglub,

The Event warning is harmless. It’s a side effect of a feature that isn’t completely finished yet [the ability to support multiple Weather Calculation things, for multiple weather stations]. Restarting the bundle should make it go away. I’ve put a temporary Event filter clear in the code so that future test versions shouldn’t generate this message.

I’m still working on the binding, and putting those messages in TRACE would cause a lot of other messages to be generated that I don’t necessarily want to have filling the logs. When major development is finished, those messages will be set down to debug.

(Bill Welliver) #12

Hi All,

I’ve uploaded a new version of this binding… it fixes a few minor problems, adds a pick list for source Item selection, and adds support for i18n (translations), though english is the only language I have included. Translation assistance is welcome, please drop me a note if you’d like to help.

Note: It’s possible you may have to remove and re-add your Weather Calculation thing as some of the channel data has changed. Hopefully this is the last time that will happen.

The download url is listed earlier in this conversation.

(Vincent Regaud) #13

Hi Bill,

Could you remove the WARN level logging for these king off events, please?

2018-07-27 09:45:25.281 [WARN ] [s.handler.WeatherCalculationsHandler] - Item OutsideTemperature changed to 24.26 °C


(Vincent Regaud) #14


Did you manage to get through the errors and could you remove these WARNING events, please?

(Bill Welliver) #15

I have, but have not had time to make a new build: I’m out of town and will be back in about a week. If you have the JDK and Maven installed, you can produce a build; the project is designed so that these are the only things required. Just run the command “mvn clean package” from the project directory and the binding will be produced in the “target” directory.


(Vincent Regaud) #16

Thanks but I don’t have the JDK installed only the JRE and I don’t really want to add any load to the OH server right now. Still testing some bit…
I can wait for a week or so.


(Vincent Regaud) #17

Good morning,
Have you had a chance to build the new jar file?

(Bill Welliver) #18


I actually just had a few moments and have uploaded a version that (hopefully) has less logging. Please give it a try and let me know what you think. The only change in this version of the JAR should be less logging.



(Vincent Regaud) #19

Nice work…!!!
Clean logs, thanks

(Vincent Regaud) #20

I have been watching this for a while now and the pressure trend does change: