Aller au contenu
Gazous

Eco-Devices Live & Day Reporter (Hp/hc)

Recommended Posts

c'est bien ce que je me disais, merci.

 

J'ai visiblement un bug au bout d'un certain temps (environ 10h je dirais) la mise à jour de mes affichages du Virtual Device ne se fait plus, pourtant les données sont toujours interrogées et j'ai l'impression qu'elles sont bien stockées pour les calculs mais l'icône et les consoles en temps réel ne changent plus... bizarre ça.

En faisant changer icône et en re-selectionnant la première, ça ré-initialise le module virtuel et les chiffres live apparaissent ainsi que l'historique de la journée (calcul de consommation journalière).

Les Debug ne me renvoient rien.

 

J'ai peut être loupé une étape, une idée ?

Partager ce message


Lien à poster
Partager sur d’autres sites

J'ai essayé de changer dans la scène la "Récurrence de rafraichissement des stats en secondes" :

local checkEvery = 5

j'ai mis 5 secondes au lieu de 3s comme c'était mis de base, peut-être que ça surchargeait la box...?

 

J'ai aussi le Max running instances de la scène à 10 en me disant qu'une fois était peut être limitant mais à mon avis ça n'a rien à voir...

 

Bref, un peu bloqué, en ce moment ça me dérange pas de réinitialiser tous les jours mais à partir du 11 mai ça va devenir difficile :7:

Partager ce message


Lien à poster
Partager sur d’autres sites

salut,

 

en max.running instances j'ai mis 2 et la scène/mv ronronnent à l'unisson ;) 

 

Stef

Modifié par couillerot

Partager ce message


Lien à poster
Partager sur d’autres sites
il y a 15 minutes, couillerot a dit :

salut,

 

en max.running instances j'ai mis 2 et la scène/mv ronronnent à l'unisson ;) 

 

Stef

Que veux tu dire par la « scène/mv »?

Tu as laissé 3 secondes ?

Partager ce message


Lien à poster
Partager sur d’autres sites

Oui 3s ça marche. Moi aussi ça plantait quand l'ecodevice remontait une chaine vide. J'ai donc un peu adapté le code pour éviter celà.

Partager ce message


Lien à poster
Partager sur d’autres sites
il y a 20 minutes, BenjyNet a dit :

Oui 3s ça marche. Moi aussi ça plantait quand l'ecodevice remontait une chaine vide. J'ai donc un peu adapté le code pour éviter celà.

Cool, qu’as tu modifié ?

Partager ce message


Lien à poster
Partager sur d’autres sites

Je te dirai demain, j'ai pas le code sous la main.

Partager ce message


Lien à poster
Partager sur d’autres sites

Tiens voilà la partie modifiée, je te laisse faire la comparaison avec ton code, parce que je sais plus bien ce que j'ai fait !

  -- Ajout du if pour les index vides
  if (hcIndex ~= nil or hpIndex ~= nil) then
	hcIndexStr = "HC : "..string.format("%.3f", hcIndex/1000)
	hpIndexStr = "HP : "..string.format("%.3f", hpIndex/1000)
    
	fibaro:log("Tarif : "..tarif.." - Conso : "..conso.." VA".." - "..hcIndexStr.." - "..hpIndexStr)
    
	iconId = baseIconId
	if tarif == "HP" then
		activeIndex = hpIndexStr
		inactiveIndex = hcIndexStr
		iconId = iconId + 9
	else
		activeIndex = hcIndexStr
		inactiveIndex = hpIndexStr
	end
    
	-- Mise à jour des Labels
	setDevicePropertyValue(deviceId, "labelTarif", tarif)
	setDevicePropertyValue(deviceId, "labelConso", conso.." VA")
	setDevicePropertyValue(deviceId, "labelActiveIndex", activeIndex.." kW")
	setDevicePropertyValue(deviceId, "labelInactiveIndex", inactiveIndex.." kW")
	setFakeDevice(FakedeviceId, conso)
    
	-- Mise à jour de l'icône
	conso = ecoDevicesStats[teleInfoNB.."_PAPP"]
	if conso >= 1000 then
		if conso < 9000 then
			iconId = iconId + tonumber(string.format("%.1s", conso))
		else
			iconId = iconId + 8
		end
	end
	fibaro:call(deviceId, "setProperty", "currentIcon", iconId)
  else
	debug("index HP/HC vides - pas de MAJ", "red")
  end

Et là aussi il me semble :

function refreshDayStats()
  if (hcIndex ~= nil or hpIndex ~= nil) then 
	day_HC_Conso = hcIndex - day_HC_Index
	day_HP_Conso = hpIndex - day_HP_Index
  else
    debug("Pas de calcul des stats", "orange")
  end
  day_HC_ConsoStr = "HC : "..day_HC_Conso.." W"
  day_HP_ConsoStr = "HP : "..day_HP_Conso.." W"
  if tarif == "HP" then
    activeDayIndex = day_HP_ConsoStr
    inactiveDayIndex = day_HC_ConsoStr
  else
    activeDayIndex = day_HC_ConsoStr
    inactiveDayIndex = day_HP_ConsoStr
  end
  	
  -- Calcul du coût en €
  dayCost = ((day_HP_Conso * hpCost) + (day_HC_Conso * hcCost)) / 1000
  dayCost = dayCost + (dayCost * 0.2)
  dayCostStr = "Coût : "..string.format("%.2f", dayCost).." €"
  
  setDevicePropertyValue(deviceId, "labelActiveDayIndex", activeDayIndex)
  setDevicePropertyValue(deviceId, "labelInactiveDayIndex", inactiveDayIndex)
  setDevicePropertyValue(deviceId, "labelToday", dayCostStr)
end

 

Partager ce message


Lien à poster
Partager sur d’autres sites

Merci @BenjyNet, en effet tu as remplacé cette 1ère partie dans la Boucle principale du VD :

  -- Mise à jour des Labels
  setDevicePropertyValue(deviceId, "labelTarif", tarif)
  setDevicePropertyValue(deviceId, "labelConso", conso.." VA")
  setDevicePropertyValue(deviceId, "labelActiveIndex", activeIndex.." kW")
  setDevicePropertyValue(deviceId, "labelInactiveIndex", inactiveIndex.." kW")
    
  -- Mise à jour de l'icône
  conso = ecoDevicesStats[teleInfoNB.."_PAPP"]
  if conso >= 1000 then
    if conso < 9000 then
      iconId = iconId + tonumber(string.format("%.1s", conso))
    else
      iconId = iconId + 8
    end
  end
  fibaro:call(deviceId, "setProperty", "currentIcon", iconId)
  return true
end

...en ajoutant la partie avec "Ajout du if pour les index vides" juste avant.

 

Pour le 2ème qui est juste après dans la Boucle principale, en effet tu as remplacé cette partie :

function refreshDayStats()
  day_HC_Conso = hcIndex - day_HC_Index
  day_HP_Conso = hpIndex - day_HP_Index
  day_HC_ConsoStr = "HC : "..day_HC_Conso.." W"
  day_HP_ConsoStr = "HP : "..day_HP_Conso.." W"
  if tarif == "HP" then
    activeDayIndex = day_HP_ConsoStr
    inactiveDayIndex = day_HC_ConsoStr
  else
    activeDayIndex = day_HC_ConsoStr
    inactiveDayIndex = day_HP_ConsoStr
  end

juste avant le "-- calcul du coût en €", la partie "calcul du coût" est restée la même

 

Je teste de suite, j'espère que ça fonctionnera chez moi aussi :17:

Partager ce message


Lien à poster
Partager sur d’autres sites

Il doit manquer un "end" quelque part car le début de la Boucle principale me donne :

[ERROR] 13:37:16: line 201: 'end' expected (to close 'while' at line 1) near ''

@BenjyNet tu pourrais m'envoyer l'intégralité de ta boucle principale ?

Modifié par Tomy34

Partager ce message


Lien à poster
Partager sur d’autres sites
--------------------------------------------------------
--        Eco-Devices Live & Day Reporter v0.2        --
--------------------------------------------------------
--           Auteur : Brice Cassagnabère              --
--------------------------------------------------------
-- Changelog :                                        --
--                                                    --
--  v0.1 : Version initiale                           --
--  v0.2 : Gestion des etiquettes vides				  --
--------------------------------------------------------
--        Plus d'infos :  http://is.gd/tMgWdy         --
--------------------------------------------------------

-- Renseignez ici le numéro de téléinfo à prendre en compte, T1 ou T2
teleInfoNB = "T1"
-- Renseignez ici le numéro de la première icône de jauge (HC_0.png)
baseIconId = 1043
-- Renseignez ici les id Utilistaurs à qui transmettre le rapport
userIdsToNotify = {2}
-- Si vous utilisez la scène associée pour la MAJ, passer cette variable à true
useSceneToRefresh = true
-- Heure à laquelle vous souhaitez générer le rapport journalier
reportTime = "23:59"
-- Tarifs des kWh 2020 HT
hcCost = 0.0696
hpCost = 0.1022
-- ID fake device power PAPP
FakedeviceId = 375

deviceId = fibaro:getSelfId()

--- Usefull Functions ---
function setFakeDevice(idDevice, Value)
	local HC2 = Net.FHttp("127.0.0.1", 11111)
	local response, status, errorCode = HC2:PUT("/api/devices/"..idDevice, '{"properties":{"power":' .. Value .. '}}')
	HC2 = nil
end

function debug(text, color)
  color = color or "white"
  fibaro:debug(string.format('<%s style="color:%s;">%s</%s>', "span", color, text, "span"))
end

function setDevicePropertyValue(id, label, value)
  fibaro:call(id, "setProperty", "ui."..label..".value", value)
end

function getDevicePropertyValue(vDeviceid, propertyName)
  return fibaro:getValue(vDeviceid, "ui."..propertyName..".value")
end

function createGlobalIfNotExists(varName, defaultValue)
  if fibaro:getGlobal(varName) == "" then
    debug("Création de la variable "..varName.." avec comme valeur par défaut "..defaultValue)
    newVar = {}
    newVar.name = varName
    newVar.value = defaultValue
    HC2 = Net.FHttp("127.0.0.1", 11111)
    HC2:POST("/api/globalVariables", json.encode(newVar))
  end
end

function refreshEcoDevicesStats()
  if not useSceneToRefresh then
    fibaro:call(deviceId, "pressButton", 5)
    fibaro:sleep(1000)
  end
  
  jsonStats = fibaro:getGlobalValue("ecoDevicesStats")
  
  if not string.find(jsonStats, '{"product":"Eco-') then
    debug("An error occured -> "..jsonStats, "red")
    debug("No stats found, please check documentation and configuration", "orange")
    return false
  end
  	
  ecoDevicesStats = json.decode(jsonStats)  
  
  tarif = string.format("%.2s", ecoDevicesStats[teleInfoNB.."_PTEC"])
  conso = ecoDevicesStats[teleInfoNB.."_PAPP"]
  hcIndex = ecoDevicesStats[teleInfoNB.."_HCHC"]  
  hpIndex = ecoDevicesStats[teleInfoNB.."_HCHP"]
  
  -- Ajout du if pour les index vides
  if (hcIndex ~= nil or hpIndex ~= nil) then
	hcIndexStr = "HC : "..string.format("%.3f", hcIndex/1000)
	hpIndexStr = "HP : "..string.format("%.3f", hpIndex/1000)
    
	fibaro:log("Tarif : "..tarif.." - Conso : "..conso.." VA".." - "..hcIndexStr.." - "..hpIndexStr)
    
	iconId = baseIconId
	if tarif == "HP" then
		activeIndex = hpIndexStr
		inactiveIndex = hcIndexStr
		iconId = iconId + 9
	else
		activeIndex = hcIndexStr
		inactiveIndex = hpIndexStr
	end
    
	-- Mise à jour des Labels
	setDevicePropertyValue(deviceId, "labelTarif", tarif)
	setDevicePropertyValue(deviceId, "labelConso", conso.." VA")
	setDevicePropertyValue(deviceId, "labelActiveIndex", activeIndex.." kW")
	setDevicePropertyValue(deviceId, "labelInactiveIndex", inactiveIndex.." kW")
	setFakeDevice(FakedeviceId, conso)
    
	-- Mise à jour de l'icône
	conso = ecoDevicesStats[teleInfoNB.."_PAPP"]
	if conso >= 1000 then
		if conso < 9000 then
			iconId = iconId + tonumber(string.format("%.1s", conso))
		else
			iconId = iconId + 8
		end
	end
	fibaro:call(deviceId, "setProperty", "currentIcon", iconId)
  else
	debug("index HP/HC vides - pas de MAJ", "red")
  end
  return true
end

function refreshDayStats()
  if (hcIndex ~= nil or hpIndex ~= nil) then 
	day_HC_Conso = hcIndex - day_HC_Index
	day_HP_Conso = hpIndex - day_HP_Index
  else
    debug("Pas de calcul des stats", "orange")
  end
  day_HC_ConsoStr = "HC : "..day_HC_Conso.." W"
  day_HP_ConsoStr = "HP : "..day_HP_Conso.." W"
  if tarif == "HP" then
    activeDayIndex = day_HP_ConsoStr
    inactiveDayIndex = day_HC_ConsoStr
  else
    activeDayIndex = day_HC_ConsoStr
    inactiveDayIndex = day_HP_ConsoStr
  end
  	
  -- Calcul du coût en €
  dayCost = ((day_HP_Conso * hpCost) + (day_HC_Conso * hcCost)) / 1000
  dayCost = dayCost + (dayCost * 0.2)
  dayCostStr = "Coût : "..string.format("%.2f", dayCost).." €"
  
  setDevicePropertyValue(deviceId, "labelActiveDayIndex", activeDayIndex)
  setDevicePropertyValue(deviceId, "labelInactiveDayIndex", inactiveDayIndex)
  setDevicePropertyValue(deviceId, "labelToday", dayCostStr)
end

function reportDayStats()
  message = "HC : "..day_HC_Conso.." Watts\nHP : "..day_HP_Conso.." Watts\n"..dayCostStr
  for k,v in pairs(userIdsToNotify) do
    fibaro:call(v, "sendEmail", "Consommation électrique du "..os.date("%d/%m/%Y"), message)
  end
end

function checkCptRaz()
  -- Tous les jours à minuit, je stockera valeur de l'index en cours
  if tostring(os.date("%H:%M")) == reportTime or day_HC_Index == 0 or ecoDevicesStats.raz then
    debug("Initialisation du compteur journalier", "green")
    if tostring(os.date("%H:%M")) == reportTime then reportDayStats() end
    day_HC_Index = hcIndex
    day_HP_Index = hpIndex
  	fibaro:setGlobal("day_HC_Index", day_HC_Index)
    fibaro:setGlobal("day_HP_Index", day_HP_Index)
    while tostring(os.date("%H:%M")) == reportTime do
      fibaro:sleep(1000)
    end
  end
end

-- Création automatique des variable globales
createGlobalIfNotExists("ecoDevicesStats", "0")
createGlobalIfNotExists("day_HC_Index", "0")
createGlobalIfNotExists("day_HP_Index", "0")

-- Je rafraichis les stats une première fois pour initialiser mes variables locales
if not refreshEcoDevicesStats() then return end

day_HC_Index = tonumber(fibaro:getGlobalValue("day_HC_Index"))
day_HP_Index = tonumber(fibaro:getGlobalValue("day_HP_Index"))

-- Boucle principale
while true do
  -- ## Pensez à bien choisir votre méthode de mise à jour des stats
  -- ## Méthode 1 (useSceneToRefresh = true) ## : Vous utilisez la Scene de Mise à jour des stats qui évite
  -- le changement d'icône indésirable
  -- ## Méthode 2 (useSceneToRefresh = false) ## : Pas besoin de créer la scene mais entrainera un court changement
  -- de l'icône durant le reresh contrairement à la précédente
  if not refreshEcoDevicesStats() then return end
  refreshDayStats()
  checkCptRaz() 
  fibaro:sleep(2000)
end

 

  • Like 1

Partager ce message


Lien à poster
Partager sur d’autres sites

ok, ça a l'air de fonctionner, j'ai juste enlevé les références à la fonction "setFakeDevice" que tu as rajouté, ne sachant pas trop à quoi elle sert.

Je verrai demain si je dois encore réinitialiser le VD ou pas :17:

--------------------------------------------------------
--        Eco-Devices Live & Day Reporter v0.2        --
--------------------------------------------------------
--           Auteur : Brice Cassagnabère              --
--------------------------------------------------------
-- Changelog :                                        --
--                                                    --
--  v0.1 : Version initiale                           --
--  v0.2 : Gestion des etiquettes vides				  --
--------------------------------------------------------
--        Plus d'infos :  http://is.gd/tMgWdy         --
--------------------------------------------------------

-- Renseignez ici le numéro de téléinfo à prendre en compte, T1 ou T2
teleInfoNB = "T1"
-- Renseignez ici le numéro de la première icône de jauge (HC_0.png)
baseIconId = 1011
-- Renseignez ici les id Utilistaurs à qui transmettre le rapport
userIdsToNotify = {2}
-- Si vous utilisez la scène associée pour la MAJ, passer cette variable à true
useSceneToRefresh = true
-- Heure à laquelle vous souhaitez générer le rapport journalier
reportTime = "23:59"
-- Tarifs des kWh 2020 HT
hcCost = 0.0653
hpCost = 0.0925
-- ID fake device power PAPP
--FakedeviceId = 375

deviceId = fibaro:getSelfId()

--- Usefull Functions ---
--function setFakeDevice(idDevice, Value)
	--local HC2 = Net.FHttp("127.0.0.1", 11111)
	--local response, status, errorCode = HC2:PUT("/api/devices/"..idDevice, '{"properties":{"power":' .. Value .. '}}')
	--HC2 = nil
--end

function debug(text, color)
  color = color or "white"
  fibaro:debug(string.format('<%s style="color:%s;">%s</%s>', "span", color, text, "span"))
end

function setDevicePropertyValue(id, label, value)
  fibaro:call(id, "setProperty", "ui."..label..".value", value)
end

function getDevicePropertyValue(vDeviceid, propertyName)
  return fibaro:getValue(vDeviceid, "ui."..propertyName..".value")
end

function createGlobalIfNotExists(varName, defaultValue)
  if fibaro:getGlobal(varName) == "" then
    debug("Création de la variable "..varName.." avec comme valeur par défaut "..defaultValue)
    newVar = {}
    newVar.name = varName
    newVar.value = defaultValue
    HC2 = Net.FHttp("127.0.0.1", 11111)
    HC2:POST("/api/globalVariables", json.encode(newVar))
  end
end

function refreshEcoDevicesStats()
  if not useSceneToRefresh then
    fibaro:call(deviceId, "pressButton", 5)
    fibaro:sleep(1000)
  end
  
  jsonStats = fibaro:getGlobalValue("ecoDevicesStats")
  
  if not string.find(jsonStats, '{"product":"Eco-') then
    debug("An error occured -> "..jsonStats, "red")
    debug("No stats found, please check documentation and configuration", "orange")
    return false
  end
  	
  ecoDevicesStats = json.decode(jsonStats)  
  
  tarif = string.format("%.2s", ecoDevicesStats[teleInfoNB.."_PTEC"])
  conso = ecoDevicesStats[teleInfoNB.."_PAPP"]
  hcIndex = ecoDevicesStats[teleInfoNB.."_HCHC"]  
  hpIndex = ecoDevicesStats[teleInfoNB.."_HCHP"]
  
  -- Ajout du if pour les index vides
  if (hcIndex ~= nil or hpIndex ~= nil) then
	hcIndexStr = "HC : "..string.format("%.3f", hcIndex/1000)
	hpIndexStr = "HP : "..string.format("%.3f", hpIndex/1000)
    
	fibaro:log("Tarif : "..tarif.." - Conso : "..conso.." VA".." - "..hcIndexStr.." - "..hpIndexStr)
    
	iconId = baseIconId
	if tarif == "HP" then
		activeIndex = hpIndexStr
		inactiveIndex = hcIndexStr
		iconId = iconId + 9
	else
		activeIndex = hcIndexStr
		inactiveIndex = hpIndexStr
	end
    
	-- Mise à jour des Labels
	setDevicePropertyValue(deviceId, "labelTarif", tarif)
	setDevicePropertyValue(deviceId, "labelConso", conso.." VA")
	setDevicePropertyValue(deviceId, "labelActiveIndex", activeIndex.." kW")
	setDevicePropertyValue(deviceId, "labelInactiveIndex", inactiveIndex.." kW")
	--setFakeDevice(FakedeviceId, conso)
    
	-- Mise à jour de l'icône
	conso = ecoDevicesStats[teleInfoNB.."_PAPP"]
	if conso >= 1000 then
		if conso < 9000 then
			iconId = iconId + tonumber(string.format("%.1s", conso))
		else
			iconId = iconId + 8
		end
	end
	fibaro:call(deviceId, "setProperty", "currentIcon", iconId)
  else
	debug("index HP/HC vides - pas de MAJ", "red")
  end
  return true
end

function refreshDayStats()
  if (hcIndex ~= nil or hpIndex ~= nil) then 
	day_HC_Conso = hcIndex - day_HC_Index
	day_HP_Conso = hpIndex - day_HP_Index
  else
    debug("Pas de calcul des stats", "orange")
  end
  day_HC_ConsoStr = "HC : "..day_HC_Conso.." W"
  day_HP_ConsoStr = "HP : "..day_HP_Conso.." W"
  if tarif == "HP" then
    activeDayIndex = day_HP_ConsoStr
    inactiveDayIndex = day_HC_ConsoStr
  else
    activeDayIndex = day_HC_ConsoStr
    inactiveDayIndex = day_HP_ConsoStr
  end
  	
  -- Calcul du coût en €
  dayCost = ((day_HP_Conso * hpCost) + (day_HC_Conso * hcCost)) / 1000
  dayCost = dayCost + (dayCost * 0.2)
  dayCostStr = "Coût : "..string.format("%.2f", dayCost).." "
  
  setDevicePropertyValue(deviceId, "labelActiveDayIndex", activeDayIndex)
  setDevicePropertyValue(deviceId, "labelInactiveDayIndex", inactiveDayIndex)
  setDevicePropertyValue(deviceId, "labelToday", dayCostStr)
end

function reportDayStats()
  message = "HC : "..day_HC_Conso.." Watts\nHP : "..day_HP_Conso.." Watts\n"..dayCostStr
  for k,v in pairs(userIdsToNotify) do
    fibaro:call(v, "sendEmail", "Consommation électrique du "..os.date("%d/%m/%Y"), message)
  end
end

function checkCptRaz()
  -- Tous les jours à minuit, je stockera valeur de l'index en cours
  if tostring(os.date("%H:%M")) == reportTime or day_HC_Index == 0 or ecoDevicesStats.raz then
    debug("Initialisation du compteur journalier", "green")
    if tostring(os.date("%H:%M")) == reportTime then reportDayStats() end
    day_HC_Index = hcIndex
    day_HP_Index = hpIndex
  	fibaro:setGlobal("day_HC_Index", day_HC_Index)
    fibaro:setGlobal("day_HP_Index", day_HP_Index)
    while tostring(os.date("%H:%M")) == reportTime do
      fibaro:sleep(1000)
    end
  end
end

-- Création automatique des variable globales
createGlobalIfNotExists("ecoDevicesStats", "0")
createGlobalIfNotExists("day_HC_Index", "0")
createGlobalIfNotExists("day_HP_Index", "0")

-- Je rafraichis les stats une première fois pour initialiser mes variables locales
if not refreshEcoDevicesStats() then return end

day_HC_Index = tonumber(fibaro:getGlobalValue("day_HC_Index"))
day_HP_Index = tonumber(fibaro:getGlobalValue("day_HP_Index"))

-- Boucle principale
while true do
  -- ## Pensez à bien choisir votre méthode de mise à jour des stats
  -- ## Méthode 1 (useSceneToRefresh = true) ## : Vous utilisez la Scene de Mise à jour des stats qui évite
  -- le changement d'icône indésirable
  -- ## Méthode 2 (useSceneToRefresh = false) ## : Pas besoin de créer la scene mais entrainera un court changement
  -- de l'icône durant le reresh contrairement à la précédente
  if not refreshEcoDevicesStats() then return end
  refreshDayStats()
  checkCptRaz() 
  fibaro:sleep(2000)
end

 

Modifié par Tomy34

Partager ce message


Lien à poster
Partager sur d’autres sites

Oui t'as bien fait, c'est inutile pour toi.

Partager ce message


Lien à poster
Partager sur d’autres sites

Bon ça n'a pas sauté depuis hier, merci beaucoup @BenjyNet :icon1010::bravo:

J'en ai profité pour regarder comment récupérer la consommation d'eau froide potable qui est mesurée par mon Compteur d'eau froide à impulsion  (1 imp./ 1 litre), raccord 3/4" relié à mon Eco-Devices. L'index compteur est bien remonté dans la trame qui part de l'Eco-Devices sous le nom "INDEX_C1", après il me fallait juste ajouter 3 nouvelles Etiquettes spécialement pour l'eau dans le VD, créer une variable Globale nommée : "day_eau_Index" avec comme 1ère valeur mon relevé de compteur d'eau de ce matin minuit en Litres (et non en m3 -> pour se faire aller dans l'interface de l'Eco-Devices et déduire la "conso d'aujourd'hui en litres" de l'index compteur converti en Litres) et un peu de code dans la Boucle principale en suivant l'exemple de ce qui avait déjà été fait et voilà :

ConsoEau.jpg.e78ce9eef71430143a32ec0217b32e38.jpg

 

et si cela intéresse quelqu'un voici le VD Eco-Devices_v0.3.vfib

 

J'ai juste PAS réussi à ajouter ma conso en Litres dans le petit bandeau du Log du VD de l'Eco-Devices ici :

Log.jpg.d5807262357a1d9884f5d29382befcd7.jpg

 

J'ai essayé de mettre ça en Ligne 93 juste après   hpIndexStr = "HP : "..string.format("%.3f", hpIndex/1000)     :

eauIndexStr = "EAU : "..string.format("%.3f", day_eau_Conso)
    
	fibaro:log("Tarif : "..tarif.." - Conso : "..conso.." VA".." - "..hcIndexStr.." - "..hpIndexStr.." - "..eauIndexStr.." L")

Le debug me dit que c'est une erreur de format du eauIndexStr, une idée de la raison ?

 

ET next step : envoyer les stats vers un tableau en ligne, je crois qu'il y a des discussions sur ce forum qui en ont déjà parlé, pour le moment j'ai trouvé le tutoriel de @Lazer pour faire des graphs Domocharts sur le NAS mais ça a l'air tellement complexe que je ne sais pas trop si c'est la meilleure solution pour extraire dans des graphiques les données de ce VD ?

 

 

Modifié par Tomy34
  • Like 1

Partager ce message


Lien à poster
Partager sur d’autres sites

Ce que j'ai modifié au VD pour ajouter les relevés et calculs de débit d'eau me font sauter la mise à jour du VD régulièrement comme avant que j'implémente tes modifications @BenjyNet. J'ai donc dû louper un paramètre dans l'ajout de code.

Je pense que ça doit venir de là :

 -- Ajout du if pour les index vides
  if (hcIndex ~= nil or hpIndex ~= nil or eauIndex ~= nil) then
	hcIndexStr = "HC : "..string.format("%.3f", hcIndex/1000)
	hpIndexStr = "HP : "..string.format("%.3f", hpIndex/1000)
    eauIndexStr = "EAU : "..string.format("%.3f", eauIndex)
    
	fibaro:log("Tarif : "..tarif.." - Conso : "..conso.." VA - "..hcIndexStr.." - "..hpIndexStr.." - "..eauIndexStr)
    
	iconId = baseIconId
	if tarif == "HP" then
		activeIndex = hpIndexStr
		inactiveIndex = hcIndexStr
		iconId = iconId + 9
	else
		activeIndex = hcIndexStr
		inactiveIndex = hpIndexStr
	end

ou bien de là :

function refreshDayStats()
  if (hcIndex ~= nil or hpIndex ~= nil or eauIndex ~= nil) then 
	day_HC_Conso = hcIndex - day_HC_Index
	day_HP_Conso = hpIndex - day_HP_Index
    day_eau_Conso = eauIndex * 1000 - day_eau_Index
  else
    debug("Pas de calcul des stats", "orange")
  end
  day_HC_ConsoStr = "HC : "..day_HC_Conso.." W"
  day_HP_ConsoStr = "HP : "..day_HP_Conso.." W"
  day_eau_ConsoStr = "Volume consommé : "..day_eau_Conso.." L"
  if tarif == "HP" then
    activeDayIndex = day_HP_ConsoStr
    inactiveDayIndex = day_HC_ConsoStr
  else
    activeDayIndex = day_HC_ConsoStr
    inactiveDayIndex = day_HP_ConsoStr
  end
  	
  -- Calcul du coût en €
  dayCost = ((day_HP_Conso * hpCost) + (day_HC_Conso * hcCost)) / 1000
  --dayCost = dayCost + (dayCost * 0.2)
  dayCostStr = "Coût HT : "..string.format("%.2f", dayCost).." €"
  
  dayCostEau = day_eau_Conso * eauCost / 1000
  dayCostEauStr = "Coût TTC : "..string.format("%.2f", dayCostEau).." €"
  
  setDevicePropertyValue(deviceId, "labelActiveDayIndex", activeDayIndex)
  setDevicePropertyValue(deviceId, "labelInactiveDayIndex", inactiveDayIndex)
  setDevicePropertyValue(deviceId, "labelToday", dayCostStr)
  setDevicePropertyValue(deviceId, "labelTodayEau", dayCostEauStr)
  setDevicePropertyValue(deviceId, "labelTodayEauConso", day_eau_ConsoStr)
end

surement le problème de la valeur vide, une idée pour y remédier ?

Partager ce message


Lien à poster
Partager sur d’autres sites

Dites moi les gars il y a un VD pour ceux qui sont en tarif BASE ? J'ai modifié mon abo hier et bien sûr plus rien ne remonte et ma flemmardise aigue m'empêche de me remettre dans le code :lol:

 

Edit : Bon je suis vraiment une faignasse parce qu'il y a tout ce qu'il faut sur le forum :)

Modifié par BenjyNet
Mea Culpa

Partager ce message


Lien à poster
Partager sur d’autres sites

×