OpenWeatherMap daily forecast using the free API

Sorry… I have other updates in the script that need to be pushed. The issue is that I had renamed the addOWMItems function to add_owm_items, so it choked on the logging. I have updated my other post.

Edit: I’ve pushed the update, so just grab the latest.

Hi, it works.

You are realy great. Thank very much. How can i donate your help.
:smiley:

You are very welcome!

Check the Sponsor link at the top of the helper library repository or my signature. THANK YOU :slightly_smiling_face:!

Sorry i was to hasty.
In Paper UI i can see the Values of the forecast, but in Basic UI not.
Also the log shows some errors from the script.
β€˜β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™
2020-06-19 08:56:59.153 [DEBUG] [.AutomationResourceBundlesEventQueue] - Process bundle event 2, for automation bundle β€˜org.openhab.core.automation’

2020-06-19 08:56:59.165 [DEBUG] [.AutomationResourceBundlesEventQueue] - Process bundle event 32, for automation bundle β€˜org.openhab.core.automation.module.script.rulesupport’

2020-06-19 08:56:59.181 [DEBUG] [vider.AbstractResourceBundleProvider] - Parse rules from bundle β€˜org.openhab.core.automation’

2020-06-19 08:56:59.184 [DEBUG] [vider.AbstractResourceBundleProvider] - Parse rules from bundle β€˜org.openhab.core.automation.module.script.rulesupport’

2020-06-19 08:56:59.587 [DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added CoreModuleHandlerFactory

2020-06-19 08:56:59.624 [DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added EphemerisModuleHandlerFactory

2020-06-19 08:56:59.646 [DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added TimerModuleHandlerFactory

2020-06-19 08:56:59.656 [DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added AnnotatedActionModuleTypeProvider

2020-06-19 08:56:59.735 [DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added AnnotatedThingActionModuleTypeProvider

2020-06-19 08:56:59.786 [DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added MediaModuleHandlerFactory

2020-06-19 08:56:59.877 [TRACE] [ipt.internal.ScriptEngineManagerImpl] - GenericScriptEngineFactory.getScriptTypes(): [py, text/python, application/python, text/x-python, application/x-python, js, application/javascript, application/ecmascript, text/javascript, text/ecmascript]

2020-06-19 08:57:04.697 [INFO ] [ternal.dhcp.DHCPPacketListenerServer] - DHCP request packet listener online

2020-06-19 08:57:06.250 [INFO ] [rk.internal.handler.SpeedTestHandler] - Speedtests starts in 5 minutes, then refreshes every 20 minutes

2020-06-19 08:57:06.666 [INFO ] [marthome.model.script.D1MINI2 Switch] - Status is: NULL

2020-06-19 08:57:06.666 [INFO ] [marthome.model.script.D1MINI2 Switch] - Status is: NULL

2020-06-19 08:57:07.531 [INFO ] [o.internal.handler.AstroThingHandler] - Scheduled Positional job astro:sun:local every 300 seconds

2020-06-19 08:57:07.723 [INFO ] [o.internal.handler.AstroThingHandler] - Scheduled Positional job astro:sun:local every 300 seconds

2020-06-19 08:57:07.826 [INFO ] [o.internal.handler.AstroThingHandler] - Scheduled Positional job astro:moon:local every 300 seconds

2020-06-19 08:57:07.886 [INFO ] [o.internal.handler.AstroThingHandler] - Scheduled Positional job astro:moon:local every 300 seconds

2020-06-19 08:57:12.143 [WARN ] [nce.extensions.PersistenceExtensions] - There is no queryable persistence service registered with the id β€˜rrd4j’

2020-06-19 08:57:12.144 [WARN ] [nce.extensions.PersistenceExtensions] - There is no queryable persistence service registered with the id β€˜rrd4j’

2020-06-19 08:57:14.325 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Initialized a generic ScriptEngineFactory for jython (2.7.0): supports python (2.7) with file extensions [py], names [python, jython], and mimetypes [text/python, application/python, text/x-python, application/x-python]

2020-06-19 08:57:14.326 [TRACE] [ipt.internal.ScriptEngineManagerImpl] - NashornScriptEngineFactory.getScriptTypes(): [js, application/javascript, application/ecmascript, text/javascript, text/ecmascript]

2020-06-19 08:57:15.441 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Initialized a custom ScriptEngineFactory for Oracle Nashorn (1.8.0_232-b18): supports ECMAScript (ECMA - 262 Edition 5.1) with file extensions [js], names [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], and mimetypes [application/javascript, application/ecmascript, text/javascript, text/ecmascript]

2020-06-19 08:57:15.453 [TRACE] [ipt.internal.ScriptEngineManagerImpl] - GenericScriptEngineFactory.getScriptTypes(): [py, text/python, application/python, text/x-python, application/x-python, js, application/javascript, application/ecmascript, text/javascript, text/ecmascript]

2020-06-19 08:57:15.455 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Removed GenericScriptEngineFactory

2020-06-19 08:57:15.456 [TRACE] [ipt.internal.ScriptEngineManagerImpl] - NashornScriptEngineFactory.getScriptTypes(): [js, application/javascript, application/ecmascript, text/javascript, text/ecmascript]

2020-06-19 08:57:15.457 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Removed NashornScriptEngineFactory

2020-06-19 08:57:15.502 [TRACE] [ipt.internal.ScriptEngineManagerImpl] - GenericScriptEngineFactory.getScriptTypes(): [py, text/python, application/python, text/x-python, application/x-python, js, application/javascript, application/ecmascript, text/javascript, text/ecmascript]

2020-06-19 08:57:15.504 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Initialized a generic ScriptEngineFactory for jython (2.7.0): supports python (2.7) with file extensions [py], names [python, jython], and mimetypes [text/python, application/python, text/x-python, application/x-python]

2020-06-19 08:57:15.506 [TRACE] [ipt.internal.ScriptEngineManagerImpl] - NashornScriptEngineFactory.getScriptTypes(): [js, application/javascript, application/ecmascript, text/javascript, text/ecmascript]

2020-06-19 08:57:15.529 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Initialized a custom ScriptEngineFactory for Oracle Nashorn (1.8.0_232-b18): supports ECMAScript (ECMA - 262 Edition 5.1) with file extensions [js], names [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript], and mimetypes [application/javascript, application/ecmascript, text/javascript, text/ecmascript]

2020-06-19 08:57:15.534 [DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added ScriptModuleHandlerFactory

2020-06-19 08:57:15.546 [TRACE] [al.provider.ScriptModuleTypeProvider] - ParameterOptions: {application/python=Python (2.7)}

2020-06-19 08:57:15.565 [TRACE] [al.provider.ScriptModuleTypeProvider] - ParameterOptions: {application/javascript=ECMAScript (ECMA - 262 Edition 5.1), application/python=Python (2.7)}

2020-06-19 08:57:15.585 [DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added ScriptedCustomModuleHandlerFactory

2020-06-19 08:57:15.594 [DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added ScriptedPrivateModuleHandlerFactory

2020-06-19 08:57:16.055 [INFO ] [roker.internal.EmbeddedBrokerService] - Broker persistence file: mqttembedded.bin

2020-06-19 08:57:16.450 [WARN ] [roker.internal.EmbeddedBrokerService] - persistence corrupt: Could not deserialize [-84, -19, 0, 5, 115, 114, 0, 45, 105, 111, 46, 109, 111, 113, 117, 101, 116, 116, 101, 46, 98, 114, 111, 107, 101, 114, 46, 115, 117, 98, 115, 99, 114, 105, 112, 116, 105, 111, 110, 115, 46, 83, 117, 98, 115, 99, 114, 105, 112, 116, 105, 111, 110, -47, 11, -117, 54, 80, -6, 26, -58, 2, 0, 3, 76, 0, 8, 99, 108, 105, 101, 110, 116, 73, 100, 116, 0, 18, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 83, 116, 114, 105, 110, 103, 59, 76, 0, 12, 114, 101, 113, 117, 101, 115, 116, 101, 100, 81, 111, 115, 116, 0, 37, 76, 105, 111, 47, 110, 101, 116, 116, 121, 47, 104, 97, 110, 100, 108, 101, 114, 47, 99, 111, 100, 101, 99, 47, 109, 113, 116, 116, 47, 77, 113, 116, 116, 81, 111, 83, 59, 76, 0, 11, 116, 111, 112, 105, 99, 70, 105, 108, 116, 101, 114, 116, 0, 40, 76, 105, 111, 47, 109, 111, 113, 117, 101, 116, 116, 101, 47, 98, 114, 111, 107, 101, 114, 47, 115, 117, 98, 115, 99, 114, 105, 112, 116, 105, 111, 110, 115, 47, 84, 111, 112, 105, 99, 59, 120, 112, 116, 0, 22, 109, 113, 116, 116, 45,… [1.4.199/0], deleting /openhab/userdata/mqttembedded.bin

2020-06-19 08:57:18.333 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to β€˜localhost’ with clientid embedded-mqtt-broker

2020-06-19 08:57:18.587 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to β€˜192.168.10.24’ with clientid 37036d2f-e3bd-4a44-b855-086dc2e17217

2020-06-19 08:57:20.282 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel

2020-06-19 08:57:20.418 [INFO ] [ebuilder.internal.HomeBuilderServlet] - Started Home Builder at /homebuilder

2020-06-19 08:57:20.528 [INFO ] [openhab.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui

2020-06-19 08:57:40.635 [INFO ] [me.core.service.AbstractWatchService] - Loading script β€˜python/core/000_startup.py’

2020-06-19 08:57:40.640 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language β€˜py’ with identifier: file:/openhab/conf/automation/jsr223/python/core/000_startup.py

2020-06-19 08:57:46.963 [TRACE] [ipt.internal.ScriptEngineManagerImpl] - scriptLoaded() is not defined in the script: file:/openhab/conf/automation/jsr223/python/core/000_startup.py

2020-06-19 08:57:46.966 [INFO ] [me.core.service.AbstractWatchService] - Loading script β€˜python/core/components/100_DirectoryTrigger.py’

2020-06-19 08:57:46.967 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language β€˜py’ with identifier: file:/openhab/conf/automation/jsr223/python/core/components/100_DirectoryTrigger.py

2020-06-19 08:57:47.206 [INFO ] [23.jython.core.DirectoryEventTrigger] - TriggerHandler added [jsr223.DirectoryTrigger]

2020-06-19 08:57:47.211 [INFO ] [23.jython.core.DirectoryEventTrigger] - TriggerType added [jsr223.DirectoryTrigger]

2020-06-19 08:57:47.214 [INFO ] [me.core.service.AbstractWatchService] - Loading script β€˜python/core/components/100_OsgiEventTrigger.py’

2020-06-19 08:57:47.215 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language β€˜py’ with identifier: file:/openhab/conf/automation/jsr223/python/core/components/100_OsgiEventTrigger.py

2020-06-19 08:57:47.778 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script β€˜file:/openhab/conf/automation/jsr223/python/core/components/100_OsgiEventTrigger.py’: ImportError: cannot import name bundle_context in at line number 8

2020-06-19 08:57:47.781 [INFO ] [me.core.service.AbstractWatchService] - Loading script β€˜python/core/components/100_StartupTrigger.py’

2020-06-19 08:57:47.784 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language β€˜py’ with identifier: file:/openhab/conf/automation/jsr223/python/core/components/100_StartupTrigger.py

2020-06-19 08:57:47.827 [INFO ] [jsr223.jython.core.StartupTrigger ] - TriggerHandler added [jsr223.StartupTrigger]

2020-06-19 08:57:47.831 [INFO ] [jsr223.jython.core.StartupTrigger ] - TriggerType added [jsr223.StartupTrigger]

2020-06-19 08:57:47.834 [INFO ] [me.core.service.AbstractWatchService] - Loading script β€˜python/core/components/200_JythonBindingInfoProvider.py’

2020-06-19 08:57:47.836 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language β€˜py’ with identifier: file:/openhab/conf/automation/jsr223/python/core/components/200_JythonBindingInfoProvider.py

2020-06-19 08:57:47.919 [DEBUG] [thonBindingInfoProvider.scriptLoaded] - Registered service

2020-06-19 08:57:47.928 [INFO ] [me.core.service.AbstractWatchService] - Loading script β€˜python/core/components/200_JythonExtensionProvider.py’

2020-06-19 08:57:47.930 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language β€˜py’ with identifier: file:/openhab/conf/automation/jsr223/python/core/components/200_JythonExtensionProvider.py

2020-06-19 08:57:48.001 [DEBUG] [JythonExtensionProvider.scriptLoaded] - Added JythonExtensionProvider

2020-06-19 08:57:48.004 [INFO ] [me.core.service.AbstractWatchService] - Loading script β€˜python/core/components/200_JythonItemChannelLinkProvider.py’

2020-06-19 08:57:48.006 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language β€˜py’ with identifier: file:/openhab/conf/automation/jsr223/python/core/components/200_JythonItemChannelLinkProvider.py

2020-06-19 08:57:48.081 [DEBUG] [ItemChannelLinkProvider.scriptLoaded] - Registered service

2020-06-19 08:57:48.083 [INFO ] [me.core.service.AbstractWatchService] - Loading script β€˜python/core/components/200_JythonItemProvider.py’

2020-06-19 08:57:48.085 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language β€˜py’ with identifier: file:/openhab/conf/automation/jsr223/python/core/components/200_JythonItemProvider.py

2020-06-19 08:57:48.141 [DEBUG] [core.JythonItemProvider.scriptLoaded] - Registered service

2020-06-19 08:57:48.144 [INFO ] [me.core.service.AbstractWatchService] - Loading script β€˜python/core/components/200_JythonThingProvider.py’

2020-06-19 08:57:48.147 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language β€˜py’ with identifier: file:/openhab/conf/automation/jsr223/python/core/components/200_JythonThingProvider.py

2020-06-19 08:57:48.252 [DEBUG] [ore.JythonThingProvider.scriptLoaded] - Registered service

2020-06-19 08:57:48.261 [INFO ] [me.core.service.AbstractWatchService] - Loading script β€˜python/core/components/200_JythonThingTypeProvider.py’

2020-06-19 08:57:48.266 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language β€˜py’ with identifier: file:/openhab/conf/automation/jsr223/python/core/components/200_JythonThingTypeProvider.py

2020-06-19 08:57:48.377 [DEBUG] [JythonThingTypeProvider.scriptLoaded] - Registered service

2020-06-19 08:57:48.379 [INFO ] [me.core.service.AbstractWatchService] - Loading script β€˜python/core/components/200_JythonTransform.py’

2020-06-19 08:57:48.381 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language β€˜py’ with identifier: file:/openhab/conf/automation/jsr223/python/core/components/200_JythonTransform.py

2020-06-19 08:57:48.436 [DEBUG] [onTransformationService.scriptLoaded] - Registered service

2020-06-19 08:57:48.438 [INFO ] [me.core.service.AbstractWatchService] - Loading script β€˜python/community/openweathermap/owm_daily_forecast.py’

2020-06-19 08:57:48.441 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language β€˜py’ with identifier: file:/openhab/conf/automation/jsr223/python/community/openweathermap/owm_daily_forecast.py

2020-06-19 08:57:49.033 [DEBUG] [jsr223.jython.add_owm_items ] - owm_thing_uid set to β€˜openweathermap:weather-and-forecast:55c3cb8e:local’

2020-06-19 08:57:49.775 [DEBUG] [jsr223.jython.add_owm_items ] - Scale transformation service is already installed

2020-06-19 08:57:53.560 [ERROR] [jsr223.jython.add_owm_items ] - Traceback (most recent call last):

File β€œβ€, line 354, in add_owm_items

File β€œ/openhab/conf/automation/lib/python/core/triggers.py”, line 37, in

from core.osgi.events import OsgiEventTrigger

File β€œ/openhab/conf/automation/lib/python/core/osgi/events.py”, line 29, in

from core.osgi import bundle_context

ImportError: cannot import name bundle_context
β€˜β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™

Just three backticks ```, before and after. Or read this.

This would not be a problem with the script. What do you have in your sitemap? This should be all you need…

Group item=gOpenWeatherMap

quote=β€œj67, post:126, topic:62579”]
ImportError: cannot import name bundle_context
[/quote]

I thought you were using the beta Jython addon. If not, please download the latest libraries and scripts.

Hi, i had failure in my Sitemap file, and i made everything new with openhelper libaries,scripts and jython addon.
Now it seems to work.

Thank you

1 Like

@5iver -First of all, I’d say that the script you did is just great ! works like a charm. However, when I started playing I found I’m missing ability to give item names in my local language, especially for day of the week. I played with the calendar but there were other difficulties with unicode strings in jython. Besides that I wanted to slightly customize the way how forecast days are displayed - not as name of the days, but instead like β€œTomorrow”, β€œThe day after tomorrow”, etc. (of course in my local language). So I end up with using Map transformation service and it lead me to the solution that allows to localise all the Item labels. If you interested to add it to the scripters respository, I created a corresponding PR: https://github.com/openhab-scripters/openhab-helper-libraries/pull/357. However to have it fully functional, another PR is requried to enable unicode characters treatment at least in core/lib/items: https://github.com/openhab-scripters/openhab-helper-libraries/pull/356

Hi,

does this work in OH3?

EDIT:
Nevermind, I found what I needed in the OpenWeatherMap Binding

Sorry, i have the same question.
Is ist possible to migrate the Open Weather Scripts f with jython to OH3?

It’s possible but no longer necessary. The new One Call API OWM provides now gives all the information so there is no longer a need to compile today’s forecast using the hourly forecast.

1 Like