Hmm, what am I doing differently? You have a completely stock OH 2.5.2 other than the one add-on you mention?
Does this match your jython engine?
203 x Active x 80 x 2.5.0.202001221001 x openHAB Core :: Bundles :: Jython ScriptEngineFactory
-rw-r--r-- 1 openhab openhab 37403148 Mar 22 16:26 /usr/share/openhab2/addons/org.openhab.core.automation.module.script.scriptenginefactory.jython-2.5.0-SNAPSHOT.jar
What bundle is your change in? Since 2.5.0 came out before your change was checked in, it must be in an add-on patch bundle? Core bundles are not updated in the 2.5.x patches.
The script is below. Yours is just like this?
"""
TankUtility Jython Rule
"""
from core.rules import rule
from core.triggers import when
from core.actions import HTTP
@rule("TankUtility", description="Picks up propane tank values from Tank Utility servers", tags=[])
@when("Time cron 0 4 9 * * ?")
def tankUtilityDataCollection(event):
tankUtilityDataCollection.log.info("TankUtility script is running")
# leaving commented lines as blank so line numbers match the log below
#
#
#
headers="{Authorization=Basic XXXXYYYY}"
TokenResponse = HTTP.sendHttpGetRequest("https://data.tankutility.com/api/getToken", headers, 10000)
The log:
2020-04-01 09:04:00.312 [INFO ] [jsr223.jython.TankUtility ] - TankUtility script is running
2020-04-01 09:04:00.318 [ERROR] [jsr223.jython.TankUtility ] - Traceback (most recent call last):
File "/etc/openhab2/automation/lib/python/core/log.py", line 51, in wrapper
return fn(*args, **kwargs)
File "<script>", line 20, in tankUtilityDataCollection
TypeError: sendHttpGetRequest(): expected 1-2 args; got 3
2020-04-01 09:04:00.320 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule '9d3c7542-2a9f-4ea8-8dc8-9ab9ac820829': Fail to execute action: 1
2020-04-01 09:04:00.320 [DEBUG] [e.automation.internal.RuleEngineImpl] -
java.lang.RuntimeException: Fail to execute action: 1
at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1197) ~[bundleFile:?]
2.5.4 isnβt released yet - at least I donβt see it for an apt upgrade. Iβm running 2.5.3 and this doesnβt appear to be there. Is it one of these bundles or something else?
172 x Active x 80 x 2.5.0 x openHAB Core :: Bundles :: Model Script
173 x Active x 80 x 2.5.0 x openHAB Core :: Bundles :: Model Script IDE
174 x Active x 80 x 2.5.0 x openHAB Core :: Bundles :: Model Script Runtime
Yes, sorry. There are 2.5.4 snapshot releases, but the latest stable release is 2.5.3.
But it looks like I stuck my foot into something here and now I need to clean it up! I just tried using sendHttpGetRequest with headers on 2.5.4 S79 and I get the same error. @JimT, since you wrote and presumably tested the PR, maybe you are running a custom bundle?
Sorry to have sent you on a wild goose chase! I had compiled my own org.openhab.core.model.script-2.5.0-SNAPSHOT.jar and mounted it into my docker to replace the OHC jar.
I must defer to a more knowledgeable person who knows when my PR actually got included into OHC.
There has not been an update recently, but there is one coming soon. But again, this issue has nothing to do with Jython, the helper libraries, or the beta Jython bundle.
Mystery solved! OHC is frozen in OH 2.5, so your update wonβt be available until the OH 3.0 stable release, although itβll be in the snapshots too. However, I predict that the core actions will be moved to another OHC package or incorporated into an addon.
These two bundles have nothing in common. Use the console to view the installed bundles. This will filter them so that you can see Jimβsβ¦
bundle:list -s | grep model
You probably have two org.openhab.core.model.script-2.5.0-SNAPSHOT.jar and need to uninstall one of them. My guess is that you just copied it to addons. You can also replace the file in runtime, but you need to clear the cache to pick up the new one.
Other than these log messages, what is not working?
Now that I reread your post, I am wondering why you are trying to do this. Is there a reason to try to convert the parameters into headers? I found some info while searching this. Possibly you may need to encode when using as a header. But Iβm back to wondering why you want to do this if your parameters are working? What does it solve? (Not saying you wouldnβt want to do this - I am curious about the reason.)
You made the point. Parameters are not headers. Too much easter eggs in my Brain. Coming from Python requests where parameters are stored in a dictionary (Map) going to openHAB2 Action which is java i only saw the datatype and not the purpose.
This is probably redundant but a while ago I spent quite a bit of time trying to get a spotify api script running in jython. One of the big problems was requests. There may be better solutions with updated jython bundles and stuff but here are my notes on the issues.
Jython is old and only supports http, requests only supports https. Downgrade requests to a version that supports http for spotify api to run on it
pip install requests==2.5.3