j ecris un script pour eau et gaz avec Ecocompteur Legrand pour récupérer la conso eau et gaz
Code : Tout sélectionner
Debug = "NO" -- Turn debugging on ("YES") or off ("NO")
----------------------------------------------
------ Configuration ------
----------------------------------------------
local url = 'http://192.168.1.46/inst.json'
local C1 = "eau"
local C2 = "gaz"
local RAZ = 'RAZ'
----------------------------------------------
-- Fin de la partie configuration --
----------------------------------------------
commandArray={}
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
local config=assert(io.popen("curl '"..url.."'"))
local location = config:read('*all')
config:close()
local jsonLocation = json:decode(location)
local data6=jsonLocation.data6 -- eau
local data7=jsonLocation.data7 -- gaz
local heure=jsonLocation.heure -- Heure de la mesure instantanée
local minute=jsonLocation.minute -- Minute de la mesure instantanée
p1 = string.match(otherdevices_svalues[C1], "(%d+%.*%d*);(%d+%.*%d*)")
p1 = tonumber(data6)
commandArray[1]={ ['UpdateDevice']= 87 .. '|0|' .. p1 }
p2 = string.match(otherdevices_svalues[C2], "(%d+%.*%d*);(%d+%.*%d*)")
p2 = tonumber(data7)
commandArray[2]={ ['UpdateDevice']= 88 .. '|0|' .. p2 }
print('**************** Ecocompteur ************')
print(data6)
print(data7)
print(heure)
print(minute)
print('****************')
return commandArrayhttp://192.168.1.46/inst.json reccupére des chiffres avec nombre decimales de ce type sur le log :
Code : Tout sélectionner
2019-11-28 22:10:00.244 Status: LUA: **************** Ecocompteur ************
2019-11-28 22:10:00.244 Status: LUA: 9.157001
2019-11-28 22:10:00.244 Status: LUA: 21.1
2019-11-28 22:10:00.244 Status: LUA: 22
2019-11-28 22:10:00.244 Status: LUA: 10
2019-11-28 22:10:00.244 Status: LUA: ****************je n arrive pas a trouver la cause ? une idée?