Lua Chauffage Dalle beton exterieur

Forum dédié aux problématiques concernant les scripts pour DomoticZ.
Entourez votre code et les logs avec les balises nommées code grâce au bouton <\>.
QcVictor
Messages : 79
Inscription : 17 janv. 2015, 14:52

Lua Chauffage Dalle beton exterieur

Message par QcVictor »

j’essaie d’automatisée un peu plus mon petit script qui fonctionne pour l'instant mais auxquelles il manque une variable et n'arrive a rien.

Code : Tout sélectionner

--
-- Domoticz passes information to scripts through a number of global tables
-- https://www.iot4.eu/wiki/index.php/Domoticz_smart_thermostat

local heating_probe = 'TempSlabTest'            --Nom de la sonde temperature Dalle Beton
local thermostat_setpoint = 'Thermostat Slab'   --Nom de l'Thermostat virtuel Temperature Dalle Beton
local heating_unit = 'Relay Slab Beton'         --Nom de l'inter virtuel de Relay On/off Dz/Relais espeasy
local OnOff = 'Slab Heating'                    --Nom de l'inter virtuel de Marche Arret Automatique 
local heating_probe_geo = 'TempGeoDummy'        --Nom de la sonde temperature Geo Out 
-- Use when a combined sensor (e.g. temperature and humidity) is used
-- Replace in "otherdevices[heating_probe]" to "otherdevices[heating_probe]" by "temp_only" (in the 2nd "if" and in the "elseif".
-- Remove the -- in the next two lines: 

--local naartekst = (tostring (otherdevices[heating_probe]))
--local temp_only = (string.sub(naartekst,1,4)) -- the digits (1,4) do point out what characters of the string are needed.


local hysteresis = 0.5

commandArray = {}

if (otherdevices[OnOff]=='On') then
    
-- loop through all the devices
for deviceName,deviceValue in pairs(otherdevices) do
        if (deviceName== thermostat_setpoint ) then

            if tonumber(deviceValue) < tonumber(otherdevices[heating_probe]-hysteresis) then
        
                if (otherdevices[heating_unit] == "On") then
                --   commandArray['SendNotification']='Heating is off'
                commandArray[heating_unit]='Off'
                print("Heating is Off")
                end
            
            elseif tonumber(deviceValue) > tonumber(otherdevices[heating_probe]+hysteresis) then
                if (otherdevices[heating_unit] == "Off") then
                commandArray[heating_unit]='On'
                --    commandArray['SendNotification']='Heating is on'
                print("Heating is On")
                end
            end
        end
    end

-- loop through all the variables
for variableName,variableValue in pairs(uservariables) do

end
end
return commandArray
Je voudrai ajouter un On/Off pour que le script fonctionne ou pas et comme autre variable la température de la sonde de ma géothermie qui si elle arrive en dessous d'un seuil xx stop/pause le script jusqu’à ce quette température remonte a un seuil YY pour redémarrer la chauffe, toutes aide sera apprécier merci

Edit: pour le on/off j'ai ajouter un
if (otherdevices[OnOff]=='On') then
en dessous du commandArray et end a la fin, ça fonctionne excepter que si la consigne de chauffage est en marche et j’arrête mon script (off) la chauffe continue, comment je fait pour re-evalué ou ..... pour que ça marche.
QcVictor
Messages : 79
Inscription : 17 janv. 2015, 14:52

Re: Lua Chauffage Dalle beton exterieur

Message par QcVictor »

Ok pour mon Off faudrait que j'ajoute quelque chose comme cela

Code : Tout sélectionner

elseif (devicechanged[OnOff]=='Off') and (otherdevices[heating_unit]=='On') then
    commandArray[heating_unit]='Off'
    print ('chauffage extinction')
    end
J'ai essayer de coller cela en dessous de l'autre elseif........ , ça ne fonctionne pas...


Edit: ok commence a comprendre ....
Coller a la fin ça marche a l'exception des print qui n’apparaisse pas dans le log, ce qui donne :
--
-- Domoticz passes information to scripts through a number of global tables
-- https://www.iot4.eu/wiki/index.php/Domo ... thermostat
-- nom de zone
local zone = 'slab temp' --Nom de la zone pour affichage dans les logs et alerte mail
local heating_probe = 'TempSlabTest' --Nom de la sonde temperature Dalle Beton
local thermostat_setpoint = 'Thermostat Slab' --Nom de l'Thermostat virtuel Temperature Dalle Beton
local heating_unit = 'Relay Slab Beton' --Nom de l'inter virtuel de Relay On/off Dz/Relais espeasy
local OnOff = 'Slab Heating' --Nom de l'inter virtuel de Marche Arret Automatique
local heating_probe_geo = 'TempGeoDummy' --Nom de la sonde temperature Geo Out
-- Use when a combined sensor (e.g. temperature and humidity) is used
-- Replace in "otherdevices[heating_probe]" to "otherdevices[heating_probe]" by "temp_only" (in the 2nd "if" and in the "elseif".
-- Remove the -- in the next two lines:

--local naartekst = (tostring (otherdevices[heating_probe]))
--local temp_only = (string.sub(naartekst,1,4)) -- the digits (1,4) do point out what characters of the string are needed.

-- email
local mail = 'xxxx@gmail.com' -- pour réception alerte sonde muette (chauffage coupé)
local hysteresis = 0.5

commandArray = {}

if (otherdevices[OnOff]=='On') then

-- loop through all the devices
for deviceName,deviceValue in pairs(otherdevices) do
if (deviceName== thermostat_setpoint ) then

if tonumber(deviceValue) < tonumber(otherdevices[heating_probe]-hysteresis) then

if (otherdevices[heating_unit] == "On") then
-- commandArray['SendNotification']='Heating is off'
commandArray[heating_unit]='Off'
print("Heating is Off")
end

elseif tonumber(deviceValue) > tonumber(otherdevices[heating_probe]+hysteresis) then
if (otherdevices[heating_unit] == "Off") then
commandArray[heating_unit]='On'
-- commandArray['SendNotification']='Heating is on'
print("Heating is On")
end


end
end
end

-- loop through all the variables
for variableName,variableValue in pairs(uservariables) do

end
elseif (devicechanged[OnOff]=='Off') and (otherdevices[heating_unit]=='On') then
commandArray[heating_unit]='Off'
print ('chauffage extinction')
end

return commandArray
Pour l'arret/pause du script avec la variable de température de la sonde, serait preneur pour un peu d'aide...
QcVictor
Messages : 79
Inscription : 17 janv. 2015, 14:52

Re: Lua Chauffage Dalle beton exterieur

Message par QcVictor »

J'avance, petit soucis lorsque j'ajoute la configuration pour prendre en compte la consigne de température minimum

Code : Tout sélectionner

if tonumber(deviceValue) < tonumber(otherdevices[heating_probe_geo]) then
        
                if (otherdevices[heating_unit] == "On") then
                --   commandArray['SendNotification']='Heating is off'
                commandArray[heating_unit]='Off'
                print("Heating is Off")
                end

je rentre dans une boucle .......
Ça donne cela maintenant:
----------------------------------------------
------ Configuration ------
----------------------------------------------
-- Nom de Zone
local zone = 'slab temp' --Nom de la zone pour affichage dans les logs et alerte mail
local heating_probe = 'TempSlabTest' --Nom de la sonde temperature Dalle Beton
local thermostat_setpoint = 'Thermostat Slab' --Nom de l'Thermostat virtuel Temperature Dalle Beton
local heating_unit = 'Relay Slab Beton' --Nom de l'inter virtuel de Relay On/off Dz/Relais espeasy
local OnOff = 'Slab Heating' --Nom de l'inter virtuel de Marche Arret Automatique
local heating_probe_geo = 'TempGeoDummy' --Nom de la sonde temperature Geo Out
local heating_probe_geo_consigne = 20 --Seuil Temperature Geo minimum
-- email
local mail = 'xxxxx@gmail.com' -- pour réception alerte sonde muette (chauffage coupé)
-- email hysteresis
local hysteresis = 0.5
----------------------------------------------
-- Fin de la partie configuration --
----------------------------------------------
commandArray = {}

if (otherdevices[OnOff]=='On') then

-- loop through all the devices
for deviceName,deviceValue in pairs(otherdevices) do
if (deviceName== thermostat_setpoint ) then

if tonumber(deviceValue) < tonumber(otherdevices[heating_probe]-hysteresis) then

if (otherdevices[heating_unit] == "On") then
-- commandArray['SendNotification']='Heating is off'
commandArray[heating_unit]='Off'
print("Heating is Off")
end

elseif tonumber(deviceValue) > tonumber(otherdevices[heating_probe]+hysteresis) then
if (otherdevices[heating_unit] == "Off") then
commandArray[heating_unit]='On'
-- commandArray['SendNotification']='Heating is on'
print("Heating is On")

end
if tonumber(deviceValue) < tonumber(otherdevices[heating_probe_geo]) then

if (otherdevices[heating_unit] == "On") then
-- commandArray['SendNotification']='Heating is off'
commandArray[heating_unit]='Off'
print("Heating is Off")
end

end
end
end

-- loop through all the variables
for variableName,variableValue in pairs(uservariables) do
end
end
elseif (devicechanged[OnOff]=='Off') and (otherdevices[heating_unit]=='On') then
commandArray[heating_unit]='Off'
print ('chauffage extinction')
end

return commandArray
vil1driver
Messages : 5661
Inscription : 30 janv. 2015, 11:07
Localisation : Rennes (35)

Re: Lua Chauffage Dalle beton exterieur

Message par vil1driver »

Salut,

Tes boucles ne sont pas utiles,
Ça ne sert à rien de te taper tous tes dispositifs pour obtenir la valeur d'un seul.
Autant directement utiliser sa valeur.. (thermostat)
Comme tu le fais avec tes autres dispositifs

Autrement l'hysteresis ça s'ajoute/se retranche à la consigne et non à la mesure

Sinon pas simple de comprendre le but du script
2 thermostat ?
MAJ = VIDER LE CACHE(<-Clicable)
/!\Les mises à jour de Domoticz sont souvent sources de difficultés, ne sautez pas dessus
modules.lua

Un ex domoticzien
QcVictor
Messages : 79
Inscription : 17 janv. 2015, 14:52

Re: Lua Chauffage Dalle beton exterieur

Message par QcVictor »

Salut vil1driver

En réel j'ai 2 sondes de température (ds1820b):
local heating_probe = 'TempSlabTest' et local heating_probe_geo = 'TempGeoDummy' qui pour mon test son remplacer par des thermostat virtuel pour pouvoir simuler le fonctionnement avant de mettre cela en place.

local heating_probe = 'TempSlabTest' --Sonde température Dalle Béton (remplacer par un thermostat virtuel pour simuler la température pour les test)
local thermostat_setpoint = 'Thermostat Slab' --Thermostat virtuel pour la consigne de Température Dalle Béton
local heating_unit = 'Relay Slab Beton' --Inter virtuel du Relay On/off pour démarré le chauffage(Dz/Relais espeasy)
local OnOff = 'Slab Heating' --Nom de l'inter virtuel de Marche Arrêt Automatique
local heating_probe_geo = 'TempGeoDummy' --Sonde température de la sortie de la Géothermie (remplacer par un thermostat virtuel pour simuler la température pour les test)
local heating_probe_geo_consigne = 20 --Seuil Température minimum Geo

L’hystérésis ça fonctionne bien comme cela, a ce que tu semble dire c'est pas dans les règle de l'art ce calcul?
A date, ça fonctionne excepté que je n'arrive pas a implanter la variable du "Seuil Température minimum Geo" qui doit stopper/mettre en pause le script jusque ce que la température remonte de xx degré, d"ailleurs ça devrait me prendre une autre variable pour cela ou il y a moyen de dire entre XX degré et YY ou XX degré et +, bref ..... me manque quelque connaissance..

J'avais essayer avec ton script https://easydomoticz.com/forum/viewtopic.php?t=3861 mais un peu loin de ce que je voulais au final...
QcVictor
Messages : 79
Inscription : 17 janv. 2015, 14:52

Re: Lua Chauffage Dalle beton exterieur

Message par QcVictor »

J'ai essayer en ajoutant un condition ou Threshold est ma valeur minimum a ne pas franchir mais rien ne se passe....

local Threshold = 30
if (deviceName== Threshold ) then
if tonumber(deviceValue) < tonumber(otherdevices[heating_probe_geo]) then
print ('Device value:' .. tonumber(otherdevices['heating_probe_geo']))
if (deviceName== thermostat_setpoint ) then
if tonumber(deviceValue) < tonumber(otherdevices[heating_probe]-hysteresis) then
QcVictor
Messages : 79
Inscription : 17 janv. 2015, 14:52

Re: Lua Chauffage Dalle beton exterieur

Message par QcVictor »

J'arrive a 2 scripts un par un, ça fonctionne mais il me faudrait les fusionner, je n'arrive pas a intégré le double "if" si la consigne du thermostat avec le si la température de la geo est entre X et Y

Code : Tout sélectionner

-- Device_Heating_Slab--
--------------------------------
------ Variables à éditer ------
--------------------------------
local consigne = tonumber(otherdevices_svalues['Thermostat Slab'])  --Température de consigne
local hysteresis = 0.5 --Valeur seuil pour éviter que le relai ne cesse de commuter dans les 2 sens
local sonde = 'Dalle Beton Garage Ext' --Nom de la sonde de température
local sondegeo = 'GeoOutTemp'        --Nom de la sonde temperature Geo Out 
local thermostat = 'Dalle Entre Garage On Off' --Nom de l'interrupteur virtuel du thermostat
local radiateur = 'Relay Slab Beton' --Nom du radiateur à allumer/éteindre
local geo_consigne_low = 20       --Seuil Temperature Geo minimum
local geo_consigne_high = 25      --Seuil Temperature Geo Max
--------------------------------
-- Fin des variables à éditer --
--------------------------------

commandArray = {}


if (devicechanged[sondegeo]) then
   local temperaturegeo = devicechanged[string.format('%s_Temperature', sondegeo)] --Temp Geothermal Unit Out
     --On n'agit que si le "Thermostat" est actif
    if (otherdevices[thermostat]=='On') then
        print('-- Heating Control DriveWay On --')

       if (temperaturegeo > geo_consigne_high and otherdevices[radiateur]=='Off') then
            print('Heating Slab On')
            commandArray[radiateur]='On'
           
       elseif (temperaturegeo < geo_consigne_low and otherdevices[radiateur]=='On') then
           print('Heating Slab Off')
            commandArray[radiateur]='Off'

       end
    end
end
--end
--end
if (devicechanged[thermostat]=='Off') then
    commandArray[radiateur]='Off'
    print('-- Heating Control DriveWay Off --')
end


return commandArray
Dans celui si c'est le thermostat avec le précédent script que j’essaie d’intégré...

Code : Tout sélectionner

-- Device_Heating_Slab--
--------------------------------
------ Variables à éditer ------
--------------------------------
local consigne = tonumber(otherdevices_svalues['Thermostat Slab'])  --Température de consigne
local hysteresis = 0.5 --Valeur seuil pour éviter que le relai ne cesse de commuter dans les 2 sens
local sonde = 'Dalle Beton Garage Ext' --Nom de la sonde de température
local sondegeo = 'GeoOutTemp'        --Nom de la sonde temperature Geo Out 
local thermostat = 'Dalle Entre Garage On Off' --Nom de l'interrupteur virtuel du thermostat
local radiateur = 'Relay Slab Beton' --Nom du radiateur à allumer/éteindre
local geo_consigne_low = 20       --Seuil Temperature Geo minimum
local geo_consigne_high = 25      --Seuil Temperature Geo Max
--------------------------------
-- Fin des variables à éditer --
--------------------------------

commandArray = {}


--if (devicechanged[sondegeo]) then
   --local temperaturegeo = devicechanged[string.format('%s_Temperature', sondegeo)] --Temperature Geothermal Unit Out
    if (devicechanged[sonde]) then
   local temperature = devicechanged[string.format('%s_Temperature', sonde)] --Temperature Slab
     --On n'agit que si le "Thermostat" est actif
    if (otherdevices[thermostat]=='On') then
        print('-- Heating Control DriveWay On --')

       --if (temperaturegeo > geo_consigne_high and otherdevices[radiateur]=='Off') then
            --print('Heating Slab On')
            --commandArray[radiateur]='On'
        if (temperature < (consigne - hysteresis) and otherdevices[radiateur]=='Off') then
            print('Start Heating_Slab')
            commandArray[radiateur]='On'
           
       elseif (temperature > (consigne + hysteresis) and otherdevices[radiateur]=='On') then
           print('Stop Heating_Slab')
            commandArray[radiateur]='Off'
            
       --elseif (temperaturegeo < geo_consigne_low and otherdevices[radiateur]=='On') then
           --print('Heating Slab Off')
            --commandArray[radiateur]='Off'

       end
    end
end
--end
--end
if (devicechanged[thermostat]=='Off') then
    commandArray[radiateur]='Off'
    print('-- Heating Control DriveWay Off --')
end

--end
return commandArray
QcVictor
Messages : 79
Inscription : 17 janv. 2015, 14:52

Re: Lua Chauffage Dalle beton exterieur

Message par QcVictor »

Je suis arriver a quelques chose de fonctionnel yeah....
J’essaye d’intégré "l'alerte de sonde muette" ca fonctionne mais lorsque je teste je reçois 9x l'alerte ! il y a moyen de le recevoir une fois au 24h par exemple ?

Code : Tout sélectionner

-- Device_Heating_Slab_Snow Melt--
--------------------------------
------ Variables à éditer ------
--------------------------------
local zone = 'Snow Melt'
local consigne = tonumber(otherdevices_svalues['Thermostat Slab'])  --Température de consigne
local hysteresis = 0.5                                            --Valeur seuil pour éviter que le relai ne cesse de commuter dans les 2 sens
local sonde = 'Dalle Beton Garage Ext'                   --Nom de la sonde de température
local sondegeo = 'GeoOut'                                     --Nom de la sonde temperature Geo Out 
local thermostat = 'Dalle Entre Garage On Off'       --Nom de l'interrupteur virtuel du thermostat
local radiateur = 'Relay Slab Beton'                        --Nom du radiateur à allumer/éteindre
local geo_ok = 'GeoOk'                                          --Switch On/Off "Ok" de la Geo 
local geo_consigne_low = 40                                 --Seuil Temperature Geo minimum
local geo_consigne_high = 48                                --Seuil Temperature Geo Max
local mail = 'xxxxxx@gmail.com'                            --Mail réception alerte sonde muette
--------------------------------
-- Fin des variables à éditer --
--------------------------------
time = os.date("*t")  


function timedifference(d)
   s = otherdevices_lastupdate[d]
   year = string.sub(s, 1, 4)
   month = string.sub(s, 6, 7)
   day = string.sub(s, 9, 10)
   hour = string.sub(s, 12, 13)
   minutes = string.sub(s, 15, 16)
   seconds = string.sub(s, 18, 19)
   t1 = os.time()
   t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
   difference = os.difftime (t1, t2)
   return difference
end

local lastSeen = timedifference(sondegeo)   -- on regarde de quand date la dernière relève de température sonde geo
local lastSeen1 = timedifference(sonde)      -- on regarde de quand date la dernière relève de température sonde slab


commandArray = {}
 
if(lastSeen >= 1800 and lastSeen < 1860) then
    -- envoi d'un mail si la sonde reste muette (1800 secondes = 30 minutes)
--commandArray['SendEmail']='Domoticz Alerte#Alerte sonde ' ..zone ..' muette#' ..mail
print('<font color="red">------Sonde Geo Muette------</font>')
commandArray['SendNotification'] = 'Domoticz#Alerte sonde Geo' ..zone ..' muette#'
end
if(lastSeen1 >= 1800 and lastSeen < 1860) then
    -- envoi d'un mail si la sonde reste muette (1800 secondes = 30 minutes)
--commandArray['SendEmail']='Domoticz Alerte#Alerte sonde ' ..zone ..' muette#' ..mail
print('<font color="red">------Sonde Slab Muette------</font>')
commandArray['SendNotification'] = 'Domoticz#Alerte sonde Slab' ..zone ..' muette#'
end

if (otherdevices[thermostat]=='On') and (devicechanged[sondegeo]) then  --On n'agit que si le "Thermostat" est actif
        print('<font color="orange">-- Heating Control DriveWay On --</font>')
       

   local temperaturegeo = devicechanged[string.format('%s_Temperature', sondegeo)] --Temperature Geothermal Unit Out
       if (temperaturegeo > geo_consigne_high and otherdevices[geo_ok]=='Off') then
            print('<font color="red">Geo Temp Ok</font>')
            print ('<font color="blue">Température Geo Out:'.. temperaturegeo..'º</font>')
            commandArray[geo_ok]='On'
           
       elseif (temperaturegeo < geo_consigne_low and otherdevices[geo_ok]=='On') then
           print('<font color="red">Geo Temp Not Reached</font>')
           print ('<font color="red">Température Geo Out:'.. temperaturegeo..'º</font>')
           commandArray[geo_ok]='Off'

       end
    end

if (devicechanged[thermostat]=='Off') then
    print('<font color="orange">-- Heating Control DriveWay Off --</font>')
    commandArray[geo_ok]='Off'
    
end

if (otherdevices[geo_ok]=='On') and (devicechanged[sonde]) then 
    local temperature = devicechanged[string.format('%s_Temperature', sonde)] --Temperature Dalle Beton
               
       if (temperature < (consigne - hysteresis) and otherdevices[radiateur]=='Off') then
            print('<font color="blue">-- Start Heating Slab --</font>')
            print('<font color="blue">Thermostat Consigne:' ..consigne.. 'º</font>')	
            print('<font color="blue">Température Exterieur:'.. temperature..'º</font>')
            print('<font color="blue">Hysteresis:' .. hysteresis..'º</font>')
            commandArray[radiateur]='On'
        
       elseif (temperature > (consigne + hysteresis) and otherdevices[radiateur]=='On') then
           print('<font color="blue">-- Stop Heating Slab --</font>')
           print('<font color="blue">-- Heating Slab Temp Reached--</font>')
            commandArray[radiateur]='Off'

       end
    end

if (devicechanged[geo_ok]=='Off') then
    commandArray[radiateur]='Off'
    print('<font color="orange">-- Heating Control DriveWay Off --</font>')
end


return commandArray
Dernière modification par QcVictor le 17 févr. 2018, 23:30, modifié 1 fois.
thier
Messages : 807
Inscription : 26 sept. 2015, 10:32
Localisation : charente

Re: Lua Chauffage Dalle beton exterieur

Message par thier »

Tu utilises une variable que tu mets à 1 quand tu as ta première alerte. Dans ton code qui envoi le mail tu ajoutes comme condition que ta variable dois être à 0. Comme ça tu n'as l'alerte qu'une fois. Pense à coder la mise à 0 de la variable quand tu récupères le signal de la sonde.
PI3+, Buster, Domoticz V2020.2, rflink, zwave, chauffage piloté par qubino, sondes oregon et Vil1d, boite aux lettres détection passage facteur, volets roulants qubino fibaro.
QcVictor
Messages : 79
Inscription : 17 janv. 2015, 14:52

Re: Lua Chauffage Dalle beton exterieur

Message par QcVictor »

thier a écrit :Tu utilises une variable que tu mets à 1 quand tu as ta première alerte. Dans ton code qui envoi le mail tu ajoutes comme condition que ta variable dois être à 0. Comme ça tu n'as l'alerte qu'une fois. Pense à coder la mise à 0 de la variable quand tu récupères le signal de la sonde.
Ok comprend le principe, as tu un exemple concret dont je pourrais m’inspiré ?
Répondre