j'ai un domoticz qui gère un logement et l'un des scripts ne fonctionne plus,
je vous mets mon scripts
Code : Tout sélectionner
-- Fonction traite la réception des plaques immatriculation et ouvre le/les portails
--local debug = true
local Plaquecam1 = "Plaque"
local Portail406 = "portail total"
local inter_acces = "controle acces portail"
domoticzIP = '127.0.0.1' --'127.0.0.1'
domoticzPORT = '9982'
domoticzUSER = 'xxxxn' -- nom d'utilisateur
domoticzPSWD = 'xxxxxn' -- mot de pass
domoticzPASSCODE = '' -- pour interrupteur protégés
domoticzURL = 'http://'..domoticzIP..':'..domoticzPORT
IDX = 3042 --récupéération info plaque texte
local Florian, Plaque1 = uservariables['FlorianClio']:match("([^;]+);([^;]+)")
commandArray = {}
if (devicechanged["Plaque"]) and otherdevices[inter_acces]=='On' then
if (package.config:sub(1,1) == '/') then
-- system linux
luaDir = debug.getinfo(1).source:match("@?(.*/)")
curl = '/usr/bin/curl -m 15 ' -- ne pas oublier l'espace à la fin
else
-- system windows
luaDir = string.gsub(debug.getinfo(1).source:match("@?(.*\\)"),'\\','\\\\')
-- download curl : https://bintray.com/vszakats/generic/download_file?file_path=curl-7.54.0-win32-mingw.7z
curl = 'c:\\Programs\\Curl\\curl.exe ' -- ne pas oublier l'espace à la fin
end
-- décrypte les information json/domoticz rid
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- For Linux
--ancienne API JSON
--local config=assert(io.popen(curl..'-u '..domoticzUSER..':'..domoticzPSWD..' "'..domoticzURL..'/json.htm?type=devices&rid='..IDX..'" &'))
-- nouveau API JSON
local config=assert(io.popen(curl..'-u '..domoticzUSER..':'..domoticzPSWD..' "'..domoticzURL..'/json.htm?type=command¶m=getdevices&rid='..IDX..'" &'))
local blocjson = config:read('*all ')
config:close()
-- print (blocjson)
local jsonValeur = json:decode(blocjson)
data=(jsonValeur.result[1].Data)
name=(jsonValeur.result[1].Name)
--fin
print ('####################')
print ('####################')
print ('passer plaque ' .. name .. ' N° ' .. data)
print ('####################')
print ('####################')
if (data == Plaque1) then
--commandArray[portail406]='On'
print ('ouverture portail 406 pour ' .. Florian .. ' plaque n°' .. Plaque1 .. '')
--commandArray['SendNotification']='ouverure portail Pour Clio#ouverure portail Pour Clio#0#sound#extradata#subsystem'
end
end
return commandArrayalors mon soucis et qu'il décrypte sans les lignes result
celui du blocjson
Code : Tout sélectionner
2023-07-23 16:17:24.197 Status: LUA: {
2023-07-23 16:17:24.197 "ActTime" : 1690121844,
2023-07-23 16:17:24.197 "AstrTwilightEnd" : "23:50",
2023-07-23 16:17:24.197 "AstrTwilightStart" : "04:32",
2023-07-23 16:17:24.197 "CivTwilightEnd" : "22:14",
2023-07-23 16:17:24.197 "CivTwilightStart" : "06:08",
2023-07-23 16:17:24.197 "DayLength" : "14:58",
2023-07-23 16:17:24.197 "NautTwilightEnd" : "22:58",
2023-07-23 16:17:24.197 "NautTwilightStart" : "05:24",
2023-07-23 16:17:24.197 "ServerTime" : "2023-07-23 16:17:24",
2023-07-23 16:17:24.197 "SunAtSouth" : "14:11",
2023-07-23 16:17:24.197 "Sunrise" : "06:42",
2023-07-23 16:17:24.197 "Sunset" : "21:40",
2023-07-23 16:17:24.197 "app_version" : "2023.2",
2023-07-23 16:17:24.197 "status" : "OK",
2023-07-23 16:17:24.197 "title" : "Devices"
2023-07-23 16:17:24.197 }
Code : Tout sélectionner
{
"ActTime" : 1690126900,
"AstrTwilightEnd" : "23:50",
"AstrTwilightStart" : "04:32",
"CivTwilightEnd" : "22:14",
"CivTwilightStart" : "06:08",
"DayLength" : "14:58",
"NautTwilightEnd" : "22:58",
"NautTwilightStart" : "05:24",
"ServerTime" : "2023-07-23 17:41:40",
"SunAtSouth" : "14:11",
"Sunrise" : "06:42",
"Sunset" : "21:40",
"app_version" : "2022.2",
"result" :
[
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"CustomImage" : 0,
"Data" : "Hello World",
"Description" : "",
"Favorite" : 0,
"HardwareDisabled" : false,
"HardwareID" : 22,
"HardwareName" : "dummy",
"HardwareType" : "Dummy (Does nothing, use for virtual switches only)",
"HardwareTypeVal" : 15,
"HaveTimeout" : false,
"ID" : "00084260",
"LastUpdate" : "2022-09-08 17:00:56",
"Name" : "INFO Domo",
"Notifications" : "false",
"PlanID" : "0",
"PlanIDs" :
[
0
],
"Protected" : false,
"ShowNotifications" : false,
"SignalLevel" : "-",
"SubType" : "Text",
"Timers" : "false",
"Type" : "General",
"TypeImg" : "text",
"Unit" : 1,
"Used" : 1,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "2260"
}
],
"status" : "OK",
"title" : "Devices"
}