Lua script hangs waiting for Curl / help needed

Moderator: leecollings

Post Reply
SiggeStardust
Posts: 2
Joined: Tuesday 03 January 2017 10:34
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: Sweden
Contact:

Lua script hangs waiting for Curl / help needed

Post by SiggeStardust »

Hi

I have a couple of LUA scripts that sometimes dont get respons and then just waiting and hangs my system.
I want to have a set timeout that if i dont get respons within X seconds then terminate the script optional terminate and give a pushnotice.
below is my Script anyone that can assist me ?
/Peter



local switch_door = 'EntreDörr'

commandArray = {}

json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()

local config=assert(io.popen('curl "http://192.168.x.x:8180/api/states/lock.entren"'))


local s = config:read('*all')
config:close()
local JsonData = json:decode(s)


if JsonData.state == "locked" then
commandArray[switch_door]='On'
else
commandArray[switch_door]='Off'
end

return commandArray
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Lua script hangs waiting for Curl / help needed

Post by waaren »

SiggeStardust wrote: Monday 17 December 2018 16:47 I have a couple of LUA scripts that sometimes dont get respons and then just waiting and hangs my system.
Have a look at dzVents async HTTP It's designed to overcome this type of delays and hanging systems.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest