Page 4 sur 4

Re: probleme conso virtuel

Publié : 18 janv. 2016, 18:34
par thier
voici la copie des logs
LUA: conso: 0 ; 0
2016-01-18 18:32:00.568 LUA: ########## string.match avec parametres
2016-01-18 18:32:00.568 Error: EventSystem: ...ticz/scripts/lua/script_time_calcul_chauffage_salon5.lua:19: attempt to concatenate global 'energy1' (a nil value)

pour le nom du script c'est bon, script_time_calcul_chauffage_salon5.lua

Re: probleme conso virtuel

Publié : 18 janv. 2016, 21:05
par AlexElectro
Tu as bien redémarré ton RPI et domoticz?

Re: probleme conso virtuel

Publié : 18 janv. 2016, 21:19
par thier
j'ai redémarré plusieurs fois sans amélioration.

Re: probleme conso virtuel

Publié : 18 janv. 2016, 21:32
par thier
je viens de recréer depuis le départ un compteur et voici le log que j'obtiens. ça progresse. je test de nouveau le script de AlexElectro.

1:22:00.418 LUA: conso: 0;0.0
2016-01-18 21:22:00.418 LUA: ########## string.match avec parametres
2016-01-18 21:22:00.418 LUA: energy1=0.0
2016-01-18 21:22:00.418 LUA: npower1=0
2016-01-18 21:22:00.418 LUA: tonumber energy1=0
2016-01-18 21:22:00.419 LUA: tonumber npower1=0

Re: probleme conso virtuel

Publié : 18 janv. 2016, 21:33
par thier
Tout fonctionne...
A force de faire des essais j'ai peut être mis le bazar dans mon compteur.
Merci du coup de main.

Re: probleme conso virtuel

Publié : 18 janv. 2016, 21:42
par AlexElectro
Super si ça marche!

Bon, on sait pas pourquoi mais c'est pas grave !! :lol:

Re: probleme conso virtuel

Publié : 19 janv. 2016, 23:49
par alexbi
j'ai fais un petit ajout sur mon script avec un compteur TOTAL si ça intéresse quelqu'un je le copie la.

PS : après avoiir créée un nouveau compteur virtuel j'ai du redémarrer Domoticz sinon j'ai eu l'erreur comme tout le monde je pense du bad argument blablabla, mais après redémarrage tout va bien donc pensez y !!!

Code : Tout sélectionner

---------- consommation virtuel radiateurs  -------

-- a editer en script_time_xxxxxxxx.lua


-- radiateur

local radiateurSalon = 'radiateur salon'       -- Nom de l'interrupteur de chauffage
local puissance1 = 1000               -- puissance du chauffage en watt
local conso1 = 'radiateur_salon_conso'            -- nom du capteur virtuel de consommation électrique (type= instant + counter)
local conso_id1 = 130                  -- idx du capteur virtuel de consommation électrique

local radiateurChambre = 'radiateur chambre'       -- Nom de l'interrupteur de chauffage
local puissance2 = 500               -- puissance du chauffage en watt
local conso2 = 'radiateur_chambre_conso'            -- nom du capteur virtuel de consommation électrique (type= instant + counter)
local conso_id2 = 132                  -- idx du capteur virtuel de consommation électrique

local radiateurCuisine = 'radiateur cuisine'       -- Nom de l'interrupteur de chauffage
local puissance3 = 700               -- puissance du chauffage en watt
local conso3 = 'radiateur_cuisine_conso'            -- nom du capteur virtuel de consommation électrique (type= instant + counter)
local conso_id3 = 131                  -- idx du capteur virtuel de consommation électrique

local radiateurSDB = 'radiateur SDB'       -- Nom de l'interrupteur de chauffage
local puissance4 = 1200               -- puissance du chauffage en watt
local conso4 = 'radiateur_SDB'            -- nom du capteur virtuel de consommation électrique (type= instant + counter)
local conso_id4 = 162                  -- idx du capteur virtuel de consommation électrique

local consoTOTAL = 'compteur TOTAL'   -- nom du capteur virtuel de consommation électrique TOTAL (type= instant + counter)
local conso_idTOTAL = 158

commandArray = {}


------- salon --------- 

if (otherdevices[radiateurSalon] == 'On') then
-- envoie de la conso dans le capteur virtuel d'énergie
npower1, energy1 = string.match(otherdevices_svalues[conso1], "(%d+%.*%d*);(%d+%.*%d*)")
energy1 = tonumber(energy1) + (puissance1 / 60)
npower1 = tonumber(npower1)
commandArray[1]={['UpdateDevice'] = conso_id1 .. '|0|' .. puissance1 .. ';' .. energy1}

end

if (otherdevices[radiateurSalon] == 'Off') then 
-- envoie de la conso dans le capteur virtuel d'énergie
npower1, energy1 = string.match(otherdevices_svalues[conso1], "(%d+%.*%d*);(%d+%.*%d*)")
energy1 = tonumber(energy1)
npower1 = tonumber(npower1)
commandArray[2]={['UpdateDevice'] = conso_id1 .. '|0|' .. 0 .. ';' .. energy1}

end  



------- Chambre --------

if (otherdevices[radiateurChambre] == 'On') then
-- envoie de la conso dans le capteur virtuel d'énergie
npower2, energy2 = string.match(otherdevices_svalues[conso2], "(%d+%.*%d*);(%d+%.*%d*)")
energy2 = tonumber(energy2) + (puissance2 / 60)
npower2 = tonumber(npower2)
commandArray[3]={['UpdateDevice'] = conso_id2 .. '|0|' .. puissance2 .. ';' .. energy2}

end

if (otherdevices[radiateurChambre] == 'Off') then 
-- envoie de la conso dans le capteur virtuel d'énergie
npower2, energy2 = string.match(otherdevices_svalues[conso2], "(%d+%.*%d*);(%d+%.*%d*)")
energy2 = tonumber(energy2)
npower2 = tonumber(npower2)
commandArray[4]={['UpdateDevice'] = conso_id2 .. '|0|' .. 0 .. ';' .. energy2}

end  



------- Cuisine --------

if (otherdevices[radiateurCuisine] == 'On') then
-- envoie de la conso dans le capteur virtuel d'énergie
npower3, energy3 = string.match(otherdevices_svalues[conso3], "(%d+%.*%d*);(%d+%.*%d*)")
energy3 = tonumber(energy3) + (puissance3 / 60)
npower3 = tonumber(npower3)
commandArray[5]={['UpdateDevice'] = conso_id3 .. '|0|' .. puissance3 .. ';' .. energy3}

end

if (otherdevices[radiateurCuisine] == 'Off') then 
-- envoie de la conso dans le capteur virtuel d'énergie
npower3, energy3 = string.match(otherdevices_svalues[conso3], "(%d+%.*%d*);(%d+%.*%d*)")
energy3 = tonumber(energy3)
npower3 = tonumber(npower3)
commandArray[6]={['UpdateDevice'] = conso_id3 .. '|0|' .. 0 .. ';' .. energy3}

end  

-------- Salle de Bain -----

if (otherdevices[radiateurSDB] == 'On') then
-- envoie de la conso dans le capteur virtuel d'énergie
npower4, energy4 = string.match(otherdevices_svalues[conso4], "(%d+%.*%d*);(%d+%.*%d*)")
energy4 = tonumber(energy4) + (puissance4 / 60)
npower4 = tonumber(npower4)
commandArray[7]={['UpdateDevice'] = conso_id4 .. '|0|' .. puissance4 .. ';' .. energy4}

end

if (otherdevices[radiateurSDB] == 'Off') then 
-- envoie de la conso dans le capteur virtuel d'énergie
npower4, energy4 = string.match(otherdevices_svalues[conso4], "(%d+%.*%d*);(%d+%.*%d*)")
energy4 = tonumber(energy4)
npower4 = tonumber(npower4)
commandArray[8]={['UpdateDevice'] = conso_id4 .. '|0|' .. 0 .. ';' .. energy4}

end  


------ Conso Wall Plug -------
instant1, total1 = otherdevices_svalues['chauffe eau kWh Meter']:match("([^;]+);([^;]+)")
conso_chauffe_eau_instant = tonumber(instant1)



------ Conso chauffe eau -----
instant2, total2 = otherdevices_svalues['wall plug kWh Meter']:match("([^;]+);([^;]+)")
conso_wall_plug_instant = tonumber(instant2)


------ virtuel conso salon ----
instant3, total3 = otherdevices_svalues[conso1]:match("([^;]+);([^;]+)")
conso_virtuel_salon = tonumber(instant3)

------ virtuel conso chambre ----
instant4, total4 = otherdevices_svalues[conso2]:match("([^;]+);([^;]+)")
conso_virtuel_chambre = tonumber(instant4)


------ virtuel conso cusine ----
instant5, total5 = otherdevices_svalues[conso3]:match("([^;]+);([^;]+)")
conso_virtuel_cusisne = tonumber(instant5)

------ virtuel conso SDB ----
instant6, total6 = otherdevices_svalues[conso4]:match("([^;]+);([^;]+)")
conso_virtuel_SDB = tonumber(instant6)



------ Conso TOTAL -------
npowerTOTAL, energyTOTAL = string.match(otherdevices_svalues[consoTOTAL], "(%d+%.*%d*);(%d+%.*%d*)")
conso_instant_TOTAL = (conso_virtuel_SDB + conso_virtuel_salon + conso_virtuel_cusisne + conso_virtuel_chambre + conso_chauffe_eau_instant + conso_wall_plug_instant)
energyTOTAL = tonumber(energyTOTAL) + (conso_instant_TOTAL / 60)
npowerTOTAL = tonumber(npowerTOTAL)
commandArray[9]={['UpdateDevice'] = conso_idTOTAL .. '|0|' .. conso_instant_TOTAL .. ';' .. energyTOTAL}


return commandArray