Announcing OpenWeatherMap binding for Eclipse SmartHome / openHAB

Tags: #<Tag:0x00007fc8fb912550> #<Tag:0x00007fc8fb912488>

Thanks! You are right! After I removed the entry from the .thing file the current temp values are coming in.

Bridge openweathermap:weather-api:api "OpenWeatherMap API" [apikey="xxx", refreshInterval=10, language="de", hourlyForecast=false, dailyForecast=false] {
    Thing weather local "Local weather" [location="47.xx,15.xx"]
    //Thing daily-forecast local "Local forecast" [location="47.xx,15.xx"]
}
  • OpenWeatherMap is offering a 3-hourly (free) forecast for the next 5 days but the binding is only providing data for the next 24 hours.
  • Openweathermap is offering a daily (paid) forecast for the next 16 days but the binding is only providing data for the next 5 days.

So if you have a free API key you can (should) only activate the 3-hourly forecast.
Then it works fine… :wink:

@itbeyond @benschi11 Is everything clear right now? Does @ordonot s answer clarify your questions?

I have tweaked the ONLINE/OFFLINE behavior for the things a little bit. It will be better if only the service goes OFFLINE which is not available for the given API key and not everything.

@ordonot I have implemented a new channel for icons as well.

Unfortunately it is currently not possible to upload a new test version for you, because it depends on two fixes in the ESH framework. We have to wait for a new snapshot version based on the next ESH build.

Be in touch.

Hi

I added a transformation map to get the wind direction output in plain text, if someone interested.

Item File

Number:Angle owmCurrentWindDirection "Current wind direction [SCALE(wind.scale):%s]" <wind> 	{ channel="openweathermap:weather:api:local:current#wind-direction" }

wind.scale

[0..22] = North
[23..45] = NorthNorthEast
[46..67] = NorthEast
[68..90] = EastNorthEast
[91..112] = East
[113..135] = EastSouthEast
[136..157] = SouthEast
[158..180] = SouthSouthEast
[181..202] = South
[203..225] = SouthSouthWest
[226..247] = SouthWest
[248..270] = WestSouthWest
[271..292] = West
[293..315] = WestNorthWest
[316..338] = NorthWest
[339..360] = NorthNorthWest
2 Likes

@cweitkamp - thanks for your response yes I have the system working now and understand the 5day only showing 24hrs and 16 days paid subscription. My main issue you seem to indicate has been looked at which was the whole API and all services go offline of you make the daily subscription on a free account.

Thank you very much @Nanna_Agesen. I have done something similar. But my scale transformation looks a little bit different (rotated by 11.25° counterclockwise). Why? In your case 181° - 202° will be transformed to South. But from my point of view South should be valid for 180° ± 11.25°.

windDirection.scale:

[0..11.25[ = N
[11.25..33.75[ = NNE
[33.75..56.25[ = NE
[56.25..78.75[ = ENE
[78.75..101.25[ = E
[101.25..123.75[ = ESE
[123.75..146.25[ = SE
[146.25..168.75[ = SSE
[168.75..191.25[ = S
[191.25..213.75[ = SSW
[213.75..236.25[ = SW
[236.25..258.75[ = WSW
[258.75..281.25[ = W
[281.25..303.75[ = WNW
[303.75..326.25[ = NW
[326.25..348.75[ = NNW
[348.75..360] = N
3 Likes

I can second that (I used to be a navigator on a maritime airplane!). I’ll never forget the "2 Strich achterlicher als querab":wink:

I have made a node-red node that does the same like a windrose indicator. You can also adjust the accuracy so you can have it with the 4 cardinal points WENS or 8, N,NE,E…
or 16 like nana’s for 32 or even 64 and 128…
I’ll dig it up and adapt it for a JS transform. (On my list do do now…)

1 Like

You are absolute right, I had misread my windrose picture :slight_smile:

Tried it out I get this error though?

Trying to transform value 270

10:01:09.516 [ERROR] [.ui.internal.items.ItemUIRegistryImpl] - transformation throws exception [transformation=org.eclipse.smarthome.transform.javascript.internal.JavaScriptTransformationService@346f388e, value=270]
org.eclipse.smarthome.core.transform.TransformationException: An error occurred while executing script.
	at org.eclipse.smarthome.transform.javascript.internal.JavaScriptTransformationService.transform(JavaScriptTransformationService.java:87) [217:org.eclipse.smarthome.transform.javascript:0.10.0.201807081340]

I just adapted the code, I actually didn’t test it,
Let me check it out

1 Like

my item:

Number windrosetest "windrose [JS(windrose.js):%s]"

The script

/**
 * Windrose
 *
 * Based loosely on the code by:
 * @author rogeriopvl <http://github.com/rogeriopvl>
 * @license MIT
 *
 * the depth parameter will determine the definition of the windrose
 * depth = 0 : 4 points (N, E, S, W)
 * depth = 1 : 8 points (eg: N, SW, NE...)
 * depth = 2 : 16 points (eg: N, SSW, NNE...)
 * depth = 3 : 32 points (eg: N, NbE, Sbw, NNE...)
 * depth = 4 : 64 points (Unused)
 * depth = 5 : 128 points (eg: N¾E, NEbN½N...)
 *
 * the valueReturned parameter will affect the value returned abbreviation or full sentence:
 * valueReturned = symbol : "SE"
 * valueReturned = name: "South East"
 */


(function(i) {
    var DEPTH_AREA = [ 90, 45, 22.5, 11.25, 5.625, 2.8125 ];
    var COMPASS_POINTS = [
        { symbol: 'N', name: 'North', depth: 0 },
        { symbol: 'N¼E', name: 'North quarter East', depth: 5 },
        { symbol: 'N½E', name: 'North half East', depth: 4 },
        { symbol: 'N¾E', name: 'North three quarters East', depth: 5 },
        { symbol: 'NbE', name: 'North by East', depth: 3 },
        { symbol: 'NbE¼E', name: 'North by East quarter East', depth: 5 },
        { symbol: 'NbE½E', name: 'North by East half East', depth: 4 },
        { symbol: 'NbE¾E', name: 'North by East three quarters East', depth: 5 },
        { symbol: 'NNE', name: 'North North East', depth: 2 },
        { symbol: 'NNE¼E', name: 'North North East quarter East', depth: 5 },
        { symbol: 'NNE½E', name: 'North North East half East', depth: 4 },
        { symbol: 'NNE¾E', name: 'North North East three quarters East', depth: 5 },
        { symbol: 'NEbN', name: 'North East by North', depth: 3 },
        { symbol: 'NEbN¾N', name: 'North East by North three quarters North', depth: 5 },
        { symbol: 'NEbN½N', name: 'North East ny North half North', depth: 4 },
        { symbol: 'NEbN¼N', name: 'North East by North quarter North', depth: 5 },
        { symbol: 'NE', name: 'North East', depth: 1 },
        { symbol: 'NE¼E', name: 'North East quarter East', depth: 5 },
        { symbol: 'NE½E', name: 'North East half East', depth: 4 },
        { symbol: 'NE¾E', name: 'North East three quarters East', depth: 5 },
        { symbol: 'NEbE', name: 'North East by East', depth: 3 },
        { symbol: 'NEbE¼E', name: 'North East by East quarter East', depth: 5 },
        { symbol: 'NEbE½E', name: 'North East by East half East', depth: 4 },
        { symbol: 'NEbE¾E', name: 'North East by East three quarters East', depth: 5 },
        { symbol: 'ENE', name: 'East North East', depth: 2 },
        { symbol: 'ENE¼E', name: 'East North East quarter East', depth: 5 },
        { symbol: 'ENE½E', name: 'East North East half East', depth: 4 },
        { symbol: 'ENE¾E', name: 'East North East three quarter East', depth: 5 },
        { symbol: 'EbN', name: 'East by North', depth: 3 },
        { symbol: 'E¾N', name: 'East three quarters North', depth: 5 },
        { symbol: 'E½N', name: 'East half North', depth: 4 },
        { symbol: 'E¼N', name: 'East quarter North', depth: 5 },
        { symbol: 'E', name: 'East', depth: 0 },
        { symbol: 'E¼S', name: 'East quarter South', depth: 5 },
        { symbol: 'E½S', name: 'East half South', depth: 4 },
        { symbol: 'E¾S', name: 'East three quarters South', depth: 5 },
        { symbol: 'EbS', name: 'East by South', depth: 3 },
        { symbol: 'ESE¾E', name: 'East South East three quarters East', depth: 5 },
        { symbol: 'ESE½E', name: 'East South East half East', depth: 4 },
        { symbol: 'ESE¼E', name: 'East South East quarter East', depth: 5 },
        { symbol: 'ESE', name: 'East South East', depth: 2 },
        { symbol: 'SEbE¾E', name: 'South East by East three quarters East', depth: 5 },
        { symbol: 'SEbE½E', name: 'South East by East half East', depth: 4 },
        { symbol: 'SEbE¼E', name: 'South East by East quarter East', depth: 5 },
        { symbol: 'SEbE', name: 'South East by East', depth: 3 },
        { symbol: 'SE¾E', name: 'South East three quarters East', depth: 5 },
        { symbol: 'SE½E', name: 'South East half East', depth: 4 },
        { symbol: 'SE¼E', name: 'South East quarter East', depth: 5 },
        { symbol: 'SE', name: 'South East', depth: 1 },
        { symbol: 'SE¼S', name: 'South East quarter South', depth: 5 },
        { symbol: 'SE½S', name: 'South East half South', depth: 4 },
        { symbol: 'SE¾S', name: 'South East three quartersSouth', depth: 5 },
        { symbol: 'SEbS', name: 'South East by South', depth: 3 },
        { symbol: 'SSE¾E', name: 'South South East three quarters East', depth: 5 },
        { symbol: 'SSE½E', name: 'South South East half East', depth: 4 },
        { symbol: 'SSE¼E', name: 'South South East quarter East', depth: 5 },
        { symbol: 'SSE', name: 'South South East', depth: 2 },
        { symbol: 'SbE¾E', name: 'South by East three quarters East', depth: 5 },
        { symbol: 'SbE½E', name: 'South by East half East', depth: 4 },
        { symbol: 'SbE¼E', name: 'South by East quarter East', depth: 5 },
        { symbol: 'SbE', name: 'South by East', depth: 3 },
        { symbol: 'S¾E', name: 'South three quarters East', depth: 5 },
        { symbol: 'S½E', name: 'South half East', depth: 4 },
        { symbol: 'S¼E', name: 'South quarter East', depth: 5 },
        { symbol: 'S', name: 'South', depth: 0 },
        { symbol: 'S¼W', name: 'South quarter West', depth: 5 },
        { symbol: 'S½W', name: 'South half West', depth: 4 },
        { symbol: 'S¾W', name: 'South three quarters West', depth: 5 },
        { symbol: 'SbW', name: 'South by West', depth: 3 },
        { symbol: 'SbW¼W', name: 'South by West quarter West', depth: 5 },
        { symbol: 'SbW½W', name: 'South by West half West', depth: 4 },
        { symbol: 'SbW¾W', name: 'South by West three quarters West', depth: 5 },
        { symbol: 'SSW', name: 'South South West', depth: 2 },
        { symbol: 'SSW¼W', name: 'South South West quarter West', depth: 5 },
        { symbol: 'SSW½W', name: 'South South West half West', depth: 4 },
        { symbol: 'SSW¾W', name: 'South South West three quarters West', depth: 5 },
        { symbol: 'SWbS', name: 'South West by South', depth: 3 },
        { symbol: 'SW¾S', name: 'South West three quarters South', depth: 5 },
        { symbol: 'SW½S', name: 'South West half South', depth: 4 },
        { symbol: 'SW¼S', name: 'South West quarter South', depth: 5 },
        { symbol: 'SW', name: 'South West', depth: 1 },
        { symbol: 'SW¼W', name: 'South West quarter West', depth: 5 },
        { symbol: 'SW½W', name: 'South West half West', depth: 4 },
        { symbol: 'SW¾W', name: 'South West three quarters West', depth: 5 },
        { symbol: 'SWbW', name: 'South West by West', depth: 3 },
        { symbol: 'SWbW¼W', name: 'South West by West quarter West', depth: 5 },
        { symbol: 'SWbW½W', name: 'South West by West half West', depth: 4 },
        { symbol: 'SWbW¾W', name: 'South West by West three quarters West', depth: 5 },
        { symbol: 'WSW', name: 'West South West', depth: 2 },
        { symbol: 'WSW¼W', name: 'West South West quarter West', depth: 5 },
        { symbol: 'WSW½W', name: 'West South West half West', depth: 4 },
        { symbol: 'WSW¾W', name: 'West South West three quarters West', depth: 5 },
        { symbol: 'WbS', name: 'West by South', depth: 3 },
        { symbol: 'W¾S', name: 'West three quarters South', depth: 5 },
        { symbol: 'W½S', name: 'West half South', depth: 4 },
        { symbol: 'W¼S', name: 'West quarter South', depth: 5 },
        { symbol: 'W', name: 'West', depth: 0 },
        { symbol: 'W¼N', name: 'West quarter North', depth: 5 },
        { symbol: 'W½N', name: 'West half North', depth: 4 },
        { symbol: 'W¾N', name: 'West three quarters North', depth: 5 },
        { symbol: 'WbN', name: 'West by North', depth: 3 },
        { symbol: 'WNW¾W', name: 'West North West three quarters West', depth: 5 },
        { symbol: 'WNW½W', name: 'West North West half West', depth: 4 },
        { symbol: 'WNW¼W', name: 'West North West quarter West', depth: 5 },
        { symbol: 'WNW', name: 'West North West', depth: 2 },
        { symbol: 'NWbW¾W', name: 'North West by West three quarters West', depth: 5 },
        { symbol: 'NWbW½W', name: 'North West by West half West', depth: 4 },
        { symbol: 'NWbW¼W', name: 'North West by West quarter West', depth: 5 },
        { symbol: 'NWbW', name: 'North West by West', depth: 3 },
        { symbol: 'NW¾W', name: 'North West three quarters West', depth: 5 },
        { symbol: 'NW½W', name: 'North West half West', depth: 4 },
        { symbol: 'NW¼W', name: 'North West quarter West', depth: 5 },
        { symbol: 'NW', name: 'North West', depth: 1 },
        { symbol: 'NW¼N', name: 'North West quarter North', depth: 5 },
        { symbol: 'NW½N', name: 'North West half North', depth: 4 },
        { symbol: 'NW¾N', name: 'North West three quarters North', depth: 5 },
        { symbol: 'NWbN', name: 'North West by North', depth: 3 },
        { symbol: 'NNW¾W', name: 'North North West three quarters West', depth: 5 },
        { symbol: 'NNW½W', name: 'North North West half West', depth: 4 },
        { symbol: 'NNW¼W', name: 'North North West quarter West', depth: 5 },
        { symbol: 'NNW', name: 'North North West', depth: 2 },
        { symbol: 'NbW¾W', name: 'North by West three quarters West', depth: 5 },
        { symbol: 'NbW½W', name: 'North by West half West', depth: 4 },
        { symbol: 'NbW¼W', name: 'North by West quarter West', depth: 5 },
        { symbol: 'NbW', name: 'North by West', depth: 3 },
        { symbol: 'N¾W', name: 'North three quarters West', depth: 5 },
        { symbol: 'N½W', name: 'North half West', depth: 4 },
        { symbol: 'N¼W', name: 'North quarter West', depth: 5 }
    ];
    var depth = 3; //Enter desired depth here
    var valueReturned = "symbol"; //Enter returned value here (symbol or name)
    var degrees = parseInt(i);
    var step = DEPTH_AREA[depth];
    var response = "";

    var compass_points = COMPASS_POINTS.filter(function (pt) {
        return pt.depth <= depth;
    });

    degrees = degrees + (step / 2);
    if (degrees > 360) (degrees = degrees - 360);

    var point = Math.floor(degrees / step);

    response = compass_points[point][valueReturned]

    return response;
}) (input)

That works for me: depth = 5, input = 96, output = E½S

1 Like

Thanks - it works for me now :slight_smile:

Had the script copyed wrong :frowning:

@Nanna_Agesen
I have changed the code above slightly at the bottom, more efficient
And corrected a bug

1 Like

It works perfect - thanks :slight_smile:

That was a good opportunity to migrate my code into OH.
Thanks @Nanna_Agesen

1 Like

Dear all,

A new ESH snapshot build (281) has been released. And a new OH2 snapshot build (1316) based on it.

You can download a new Testversion of the OWM binding here (requires ESH build 281 or higher and / or OH2 build 1316 or higher). I will not update the marketplace version immediately.

New changes:

  • Removed max-outdoor-temperature and min-outdoor-temperature channels from current weather
  • Request hourly or daily forecast data only if enabled in API configuration
  • Reviewed labels and descriptions of all entities and added German translations
  • Added channel for icon
  • Changed channel-types to new default system channel-types
  • Moved error and thing status handling to thing handler
  • Added channels for weather station data

Have fun & good luck

Christoph

Hi Christophe. I’ve downloaded the latest jar ‘org.eclipse.smarthome.binding.openweathermap-0.10.0-SNAPSHOT.jar’, but I don’t see the icon channel.

Hi Nigel, please try to recreate your Things. New Channels are not added automatically to an existing Thing.

Hi Christophe, Spot on! Thanks for such a swift reply :slight_smile: