[Plugin]DarkSky Weather

OK. But you are using tlsv1_2. I’m suggesting you try plain tlsv1 (no _2 at the end). Have you tried that?

This plugin used to use that, but it stopped working a few months back (see further up in this thread).
Seemed that Darksky swithced to tlsv1.2 exclusively (not excepting older versions anymore.)
That’s why I’m trying to get it to work on the vera3. But as I searched the forums, it seems the vera3 is just to old :frowning:

1 Like

One of the ways I get SiteSensor to work around this problem is by having the option to use curl to do the API queries. A few firmwares ago on the Plus I figured out the build of curl used a newer libssl/libopenssl than LuaSec was using.

I suspect given your success with OpenSSL on the command line, that curl would also work.

Hey @reneboer, do you think the option to use curl rather than LuaSec would be a difficult patch for this plugin?

1 Like

Yes, curl does work from the command line :slight_smile:

I found the DS_GetData function and the line that does the https call. but if anyone knows how to replace this with a call using curl I could probably figure out the rest myself.
line: local wdata, retcode, headers, res = HttpsGet(url)

Maybe @reneboer can give a pointer as you suggested :slight_smile:

It would look something like this:

local p = io.popen( "curl -s -m 15 -o - '" .. url .. "'" )
local wdata = p:read( "*a" )
p:close
-- Simulate the other return values
local retcode, headers, res = 200, {}, "HTTP/1.1 200 OK"

I’m not sure about the simulated res value (the third value on the last line). Since you don’t show what comes after the get, it’s hard for me to guess without pulling the code. If the HttpGet() call is just a wrapper for the usual request method, though, it’s likely just as shown.

1 Like

Hi,
Thanks for the curl suggestion. I tried this one on a Lite, can you try it?

L_DarkSkyWeather.zip (8.9 KB)

Cheers Rene

2 Likes

It works! :smiley:

So, I don’t know if the updates that i performed (described in my previous posts) were also needed to get the new version to work, but it works now on my Vera 3!

Thanks! :smiley:

1 Like

Hi BlueFlame,

For the older Vera firmwares it no longer uses Lua code to fetch the data, so the Lua Socket and Sec versions are not that important. For it to work with the LuaSec https request you would need LuaSec version 0.7 at a minimum.

Glad it works. I’ll update the app stores.

Cheers Rene

2 Likes

On another note, you require cjson in your lua file.
I always get the following error on reloading lua on my vera3:
01 05/18/20 12:04:31.209 luup_require can’t find cjson <0x2bd83680>

Plugin works great without it, so I don’t mind, but just for your information.

1 Like

Hi BlueFlame,

I think it all still works right? The cjson is used on openLuup as it is about 10 time faster than dkjson, and there is quite a bit of data to process.

Cheers Rene

2 Likes

Yes, like I said, it still works :slight_smile:

1 Like

Is there any way to have a native child device for dewpoint? I don’t see that as an option on the create child device list.

Ty for this great app

Hi @resq93,

Added in V1.8. Should be in Mios App market Monday. On ALTUI App Store now.

This version also works again on the Vera 3 and Lite.

Cheers Rene

2 Likes

reneboer

I was looking into a problem I was having elsewhere but came across this at line 629 in the plugin:

		res, err = json.decode(res)
		if not (err == 225) then
			extractloop(res)
			-- Update display for ALTUI
			displayLine(1)
			displayLine(2)
		else 
			log.Error("DarkSky API json decode error = %s", tostring(err)) 
		end

According to the dkjson info, if an error occurs, then in the above ‘res’ will be nil, ‘err’ will be the position where the error occurred and there is also a third variable that contains the error message. So not to sure what the test for ‘225’ is about. Looks like the code needs a couple of corrections? eg just test for a nil object?

reneboer

Thank you for your efforts on this plugin.

I now have it functioning but came across another query. In function HttpsGet() at line 450:

if (utils.GetUI() ~= utils.IsOpenLuup) and (not luup.model) then

It looks like luup.model should be luup.modelID as per:

modelID information

I tried both properties on a Vera 3 using firmware version: 1.7.919 (latest version is 1.7.1040) and they both returned nil. Which I believe, is as expected.

Regardless the plugin is running on the very latest version of openLuup (2020.07.04b) and I had to force the plugin to use the curl method. The https.request method returned “invalid protocol (any)”.

Upgrade your LuaSec. That’s a symptom of a really old version

Yep - it’s version 0.5 - came with the RasPi distribution two or three years ago. Any idea what the magic incarnations to upgrade it for Raspbian without blowing up anything else? I’m no Linux expert - that’s for sure.

Two or three years - that’s so ancient. The humble light switch has probably been in use for a hundred years or more; rarely needs an upgrade and nearly always works. And most people know how to work them, although it seems in some countries, they insist on installing them upside down on a regular basis.

Hi @a-lurker,

Use the following to keep your Pi up to date. It should install a proper LuaSec as well.

sudo apt-get update
sudo apt-get upgrade
sudo reboot

Cheers Rene

1 Like

Hello @reneboer

Sometime ago I thought the below would do the job as well (running Jessie on a Pi 3).

sudo apt update
sudo apt full-upgrade
sudo reboot

I started with WinSCP, which allows you to execute commands in a terminal window. Except they don’t always work. “sudo apt update” did but “sudo apt full-upgrade” didn’t. A few other commands didn’t seem to work either and you end up with a (useless) error message along the lines of:

"Host is not communicating for more than 15 seconds...Try...'Optimise connection buffer size'"

All a bit fishy till you read the manual on WinSCP, which says “you cannot execute commands that require terminal emulation or user input”.

So I had a go with PuTTY and it all worked OK straight away.

Except LuaSec was untouched. That’s assuming this is the file of interest:

/usr/share/lua/5.1/ssl.lua

I thought the command “luarocks list” may help. It says:

Installed rocks:
dkjson 2.5-2 (installed) - /usr/local/lib/luarocks/rocks
luafilesystem 1.6.3-2 (installed) - /usr/local/lib/luarocks/rocks

And this: luarocks show luasec

Error: cannot find package luasec
Use 'list' to find installed rocks.

I thought I could do: sudo luarocks install luasec

But if it doesn’t know anything about the existing luasec, I though it might screw things up and I wasn’t game to try it out :nauseated_face:

So not too sure how to proceed.

Hi @a-lurker,

The luarocks list will only show packages you explicitly installed (updated) via luarocks. To see what you have installed use apt list.

apt list | grep lua-sec

I see that the default luasec should now is 0.6-3

I have not seen any issues with the 0.9 version installed from luarocks.

Cheers Rene