IO 'read' returns nil

Moderator: leecollings

Post Reply
GSV3Miac
Posts: 24
Joined: Sunday 05 February 2017 12:00
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Shropshire UK
Contact:

IO 'read' returns nil

Post by GSV3Miac »

Been trying to sort out the SolarSensor LUA script, but both the 'read(*all') statements (Wunderground and OGIMet) are resulting in 'nil' instead of the strings. If I paste the called URLs into a browser, I get to the right data, but the program doesn't seem to 'read' the IO device correctly. Anyone got any suggestions? I see the latest LUA spec (5.1) says the correct option for read is '*a' rather than '*all', but I doubt that is the cause.

code:

cmd='curl "http://www.ogimet.com/cgi-bin/getsynop? ... gin='..UTC..'"'
if( DEBUG == 1) then print(cmd) end
local ogimet=assert(io.popen(cmd))
local synop =ogimet:read('*all')
ogimet:close()
if( DEBUG == 1) then print('ogimet:'..synop) end

log:

2017-02-05 11:20:00.242 LUA: curl "http://www.ogimet.com/cgi-bin/getsynop? ... 1702051000"
2017-02-05 11:20:00.289 LUA: ogimet:
2017-02-05 11:20:00.289 Error: EventSystem: in C:\Program Files (x86)\Domoticz\scripts\lua\script_time_SolarSensor.lua: ...s (x86)\Domoticz\scripts\lua\script_time_SolarSensor.lua:135: bad argument #1 to 'gsub' (string expected, got nil).

TIA
(Windows7, 64 bit, fwiw)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest