je tente d ecrire un script Lua avec une erreur que je n arrive pas a corriger :
Code : Tout sélectionner
----------------------------------------------
------ Configuration ------
----------------------------------------------
local C1 = "HC"
local C2 = "HP"
local RAZ = 'RAZ'
--local C3 = "Linky"
----------------------------------------------
-- Fin de la partie configuration --
----------------------------------------------
commandArray={}
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- For Linux
local config=assert(io.popen('curl "http://192.168.1.46/data.json"'))
local location = config:read('*all')
config:close()
local jsonLocation = json:decode(location)
local conso_hc=jsonLocation.conso_hc
local conso_hp=jsonLocation.conso_hp
print(conso_hc)
print(conso_hp)
p1 = string.match(otherdevices_svalues[C1], "(%d+%.*%d*)")
p1 = tonumber(conso_hc)
commandArray[1] = { ['UpdateDevice']= 87 .. '|0|' .. p1 }
p2 = string.match(otherdevices_svalues[C2], "(%d+%.*%d*)")
p2 = tonumber(conso_hp)
commandArray[2] = { ['UpdateDevice']= 88 .. '|0|' .. p2 }
commandArray[3] = { ['UpdateDevice']= 89 ..'|0|'.. p2 .. ";" .. p1 .. ";" .. "0" .. ";" .. "0" .. ";" .. "0" .. ";" .. "0" }
print('**************** compteur ************')
print(p1)
print(p2)
print('****************')
return commandArray
Code : Tout sélectionner
2019-12-17 20:54:00.507 Error: EventSystem: in linky test2: /home/pi/domoticz/scripts/lua/JSON.lua:1009: /home/pi/domoticz/scripts/lua/JSON.lua:660: expected comma or '}' at char 112 of:
2019-12-17 20:54:00.507 {
2019-12-17 20:54:00.507 "option_tarifaire" : 1,
2019-12-17 20:54:00.507 "tarif_courant" : 2,
2019-12-17 20:54:00.507 "isousc" : 30,
2019-12-17 20:54:00.507
2019-12-17 20:54:00.507 "conso_base" : 0,
2019-12-17 20:54:00.507 "conso_hc" : 001228559,
2019-12-17 20:54:00.507 "conso_hp" : 003887776,
2019-12-17 20:54:00.507 "conso_hc_b" : 0,
2019-12-17 20:54:00.507 "conso_hp_b" : 0,
2019-12-17 20:54:00.507 "conso_hc_w" : 0,
2019-12-17 20:54:00.507 "conso_hp_w" : 0,
2019-12-17 20:54:00.507 "conso_hc_r" : 0,
2019-12-17 20:54:00.507 "conso_hp_r" : 0,
2019-12-17 20:54:00.507
2019-12-17 20:54:00.507 "type_imp_0" : 1,
2019-12-17 20:54:00.507 "type_imp_1" : 1,
2019-12-17 20:54:00.507 "type_imp_2" : 0,
2019-12-17 20:54:00.507 "type_imp_3" : 1,
2019-12-17 20:54:00.507 "type_imp_4" : 1,
2019-12-17 20:54:00.507 "type_imp_5" : 1,
2019-12-17 20:54:00.507
2019-12-17 20:54:00.507 "label_entree1" : "Lumieres 1 ",
2019-12-17 20:54:00.507 "label_entree2" : "Lumieres 2 ",
2019-12-17 20:54:00.507 "label_entree3" : "Lumieres 3 ",
2019-12-17 20:54:00.507 "label_entree4" : "Prises de Courant",
2019-12-17 20:54:00.507 "label_entree5" : "Prises de Courant",
2019-12-17 20:54:00.507
2019-12-17 20:54:00.507 "label_entree_imp0" : "Eau",
2019-12-17 20:54:00.507 "label_entree_imp1" : "Gaz",
2019-12-17 20:54:00.507 "label_entree_imp2" : "Gaz",
2019-12-17 20:54:00.507 "label_entree_imp3" : "Eau",
2019-12-17 20:54:00.507 "label_entree_imp4" : "Eau",
2019-12-17 20:54:00.507 "label_entree_imp5" : "Eau",
2019-12-17 20:54:00.507
2019-12-17 20:54:00.507 "entree_imp0_disabled" : 0,
2019-12-17 20:54:00.507 "entree_imp1_disabled" : 0,
2019-12-17 20:54:00.507 "entree_imp2_disabled" : 1,
2019-12-17 20:54:00.507 "entree_imp3_disabled" : 1,
2019-12-17 20:54:00.507 "entree_imp4_disabled" : 1,
2019-12-17 20:54:00.507 "entree_imp5_disabled" : 1
2019-12-17 20:54:00.507 }