Problème comparaison valeurs
Publié : 27 déc. 2016, 22:17
Bonsoir,
J'ai créé, en piochant à droite et gauche, un script pour gérer mon chauffage mais j'ai une erreur:
Je comprends l'erreur: il semblerait que je tente de comparer du texte avec du numérique.
En tâtonnant je pense avoir trouvé où se situe l'erreur: la valeur "hysteresis".
Ceci dit impossible de trouver/comprendre comment résoudre ça car ... ça me semble pourtant bon
Voici le script:
Les "consignes" sont des "dummy thermostats" et les temp_(rdc/etage/maison) sont des "dummy temperature".
Si une âme charitable pouvait m'indiquer (et surtout m'expliquer) d'où vient le problème de string / nombre
Merci.
J'ai créé, en piochant à droite et gauche, un script pour gérer mon chauffage mais j'ai une erreur:
Code : Tout sélectionner
"Error: EventSystem: in /home/pi/dev-domoticz/scripts/lua/script_time_chauffage_chaudiere.lua: ...domoticz/scripts/lua/script_time_chauffage_chaudiere.lua:20: attempt to compare string with number"
En tâtonnant je pense avoir trouvé où se situe l'erreur: la valeur "hysteresis".
Ceci dit impossible de trouver/comprendre comment résoudre ça car ... ça me semble pourtant bon
Voici le script:
Code : Tout sélectionner
local consigne_confort = string.match(otherdevices_svalues['Consigne_Confort'], "(%d+%.*%d*)")
local consigne_eco = string.match(otherdevices_svalues['Consigne_Eco'], "(%d+%.*%d*)")
local consigne_absent = string.match(otherdevices_svalues['Consigne_Absent'], "(%d+%.*%d*)")
local hysteresis = 0.5
local temp_rdc = otherdevices_svalues['Moyenne_RDC']:match("([^;]+)")
local temp_etage = otherdevices_svalues['Moyenne_Etage']:match("([^;]+)")
local temp_maison = otherdevices_svalues['Moyenne_Maison']:match("([^;]+)")
commandArray = {}
t1 = os.date("%H:%M")
if (otherdevices['Mode_Confort'] == 'On')
then
if (otherdevices['Chaudiere'] == 'Off')
then
if (temp_rdc < (consigne_confort - hysteresis))
then
commandArray['Chaudiere']='On'
end
elseif (otherdevices['Chaudiere'] == 'On')
then
if (temp_rdc > (consigne_confort + hysteresis))
then
commandArray['Chaudiere']='Off'
end
end
elseif (otherdevices['Mode_Eco'] == 'On')
then
if ((t1>=uservariables["CHAUFFAGE_STOP2"]) and (t1<uservariables["CHAUFFAGE_START2"]))
then
if (otherdevices['Chaudiere'] == 'Off')
then
if (temp_etage < (consigne_eco - hysteresis))
then
commandArray['Chaudiere']='On'
end
elseif (otherdevices['Chaudiere'] == 'On')
then
if (temp_etage > (consigne_eco + hysteresis))
then
commandArray['Chaudiere']='Off'
end
end
elseif ((t1>=uservariables["CHAUFFAGE_STOP1"]) and (t1<uservariables["CHAUFFAGE_START4"]))
then
if (otherdevices['Chaudiere'] == 'Off')
then
if (temp_rdc < (consigne_eco - hysteresis))
then
commandArray['Chaudiere']='On'
elseif (otherdevices['Chaudiere'] == 'Off')
then
if (temp_rdc > (consigne_eco + hysteresis))
then
commandArray['Chaudiere']='Off'
end
end
end
end
end
return commandArray
Si une âme charitable pouvait m'indiquer (et surtout m'expliquer) d'où vient le problème de string / nombre
Merci.