Re: Connexion CurrentCost EnviR
Publié : 21 déc. 2020, 11:40
Pour le nom ou l'IDX, ça dépend de la fonction que tu appelles, elle peut demander l'un ou l'autre. Ceci dit,il y a moyen de passer plus ou moins simplement de chaque type.
Voici un exemple de dispatch d'un compteur unique vers un compteur jour/nuit. Il y a dedans les éléments dont tu pourrait avoir besoin.
Voici un exemple de dispatch d'un compteur unique vers un compteur jour/nuit. Il y a dedans les éléments dont tu pourrait avoir besoin.
Code : Tout sélectionner
-- Gestion de la consommation chauffe eau cuisine
energy_name = '$Energie CE cuisine' -- Nom du compteur (réel) energy
p1_id = 136 -- ID du compteur (virtuel) P1 HC/HP
HP_HC_name = 'Tarif réduit Linky' -- Nom du selecteur HC/HP (0=HP)
commandArray = {}
if (devicechanged[energy_name]) then
energy_values = otherdevices_svalues[energy_name]
puissance,conso=energy_values:match("([^;]+);([^;]+)")
conso = tonumber(conso)
conso_hp = tonumber(uservariables['Energie_HP_'..tostring(p1_id)])
conso_hc = tonumber(uservariables['Energie_HC_'..tostring(p1_id)])
if (conso < conso_hp or conso < conso_hc) then
conso_hp = 0
conso_hc = 0
end
if(otherdevices[HP_HC_name]=='On') then
HC = conso_hc
HP = conso - conso_hc
commandArray['Variable:Energie_HP_'..tostring(p1_id)] = tostring(HP)
else
HC = conso - conso_hp
HP = conso_hp
commandArray['Variable:Energie_HC_'..tostring(p1_id)] = tostring(HC)
end
commandArray['UpdateDevice'] = p1_id .. "|0|" .. tonumber(HC) .. ";" .. tonumber(HP) .. ";0;0;" .. tonumber(puissance) .. ";0"
end
return commandArray