Aller au contenu
jjacques68

Panneau de chauffage fait planter la HC2

Recommended Posts

Bonjour,

 

J’utilise aussi des têtes danfoss avec une programmation via le panneau chauffage pour contrôler les différentes zones.

Et à côté j’ai un VD avec plusieurs boutons.

Un bouton automatique pour suivre le programme du panneau chauffage.

Un bouton off pour passer le panneau chauffage en mode vacances sur toutes les zones.

Un bouton réduit pour forcer la température des zones.

Un bouton confort+ pour forcer la température des zones.

 

Je n’ai pas rencontré ce problème, mais si tu as besoin pour tester un truc n'hésite pas si je peux t'aider (je ne suis pas un expert en code ^_^).

 

 

Partager ce message


Lien à poster
Partager sur d’autres sites

ben écoute je veux bien voir le code de ton VD, si tu veux bien le poster...

merci !

Partager ce message


Lien à poster
Partager sur d’autres sites

 

Bouton AUTO:

--Création d'une variable prédéfinie "Mode_chauffage" : "Auto"/"OFF"
local varMode_chauffage = "Mode_chauffage"

-- ID des zones de chauffages
local hpID = 
	{
    "Chambre", 5,
    "Bureau", 6,
    "Rez-de-chaussee", 199,
    "Chambre_Owen", 200,
    }

-- HeatingPanels actifs pour variable Chauffage Zone 1
local Zone_1 = 
	{
	"Chambre",
    "Bureau",
    "Rez-de-chaussee",
    "Chambre_Owen",
    }
fibaro:debug ("Nombre de zone = " ..#Zone_1)

local id = 
  
	{
      	CHAUFFAGE_ENTREE = 402,
       	CHAUFFAGE_SALON = 208,
		CHAUFFAGE_SALLE = 212,
  		CHAUFFAGE_CUISINE = 210,
    	CHAUFFAGE_BUREAU = 214,
  	   	CHAUFFAGE_CHAMBRE = 162,
  	   	CHAUFFAGE_CHAMBRE_OWEN = 200,
   	}
	
if ( fibaro:getGlobal(varMode_chauffage) == "OFF" or "Reduit" ) then
fibaro:setGlobal(varMode_chauffage, "Auto")
fibaro:debug("Mode chauffage = Auto")
fibaro:log("Mode chauffage = Auto")
fibaro:sleep(2000) -- 2sec
end


-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  
-- RELANCE DE CHAUFFAGE --
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  
	fibaro:call(id["CHAUFFAGE_ENTREE"],"setTime", tonumber(os.time(t)) + 1*5)
  
 	fibaro:call(id["CHAUFFAGE_SALON"],"setTime", tonumber(os.time(t)) + 1*5)
    
  	fibaro:call(id["CHAUFFAGE_SALLE"],"setTime", tonumber(os.time(t)) + 1*5)
      
	fibaro:call(id["CHAUFFAGE_CUISINE"],"setTime", tonumber(os.time(t)) + 1*5)
        
	fibaro:call(id["CHAUFFAGE_BUREAU"],"setTime", tonumber(os.time(t)) + 1*5)
                
    fibaro:call(id["CHAUFFAGE_CHAMBRE"],"setTime", tonumber(os.time(t)) + 1*5)
              
	fibaro:call(id["CHAUFFAGE_CHAMBRE_OWEN"],"setTime", tonumber(os.time(t)) + 1*5)

--[[
	fibaro:call(id["CHAUFFAGE_ENTREE"],"setTargetLevel", "4")
	fibaro:call(id["CHAUFFAGE_ENTREE"],"setTime", tonumber(os.time(t)) + 1*5)
  
    fibaro:call(id["CHAUFFAGE_SALON"],"setTargetLevel", "4")
 	fibaro:call(id["CHAUFFAGE_SALON"],"setTime", tonumber(os.time(t)) + 1*5)
    
    fibaro:call(id["CHAUFFAGE_SALLE"],"setTargetLevel", "4")
  	fibaro:call(id["CHAUFFAGE_SALLE"],"setTime", tonumber(os.time(t)) + 1*5)
      
    fibaro:call(id["CHAUFFAGE_CUISINE"],"setTargetLevel", "4")
    fibaro:call(id["CHAUFFAGE_CUISINE"],"setTime", tonumber(os.time(t)) + 1*5)
        
    fibaro:call(id["CHAUFFAGE_BUREAU"],"setTargetLevel", "4")
	fibaro:call(id["CHAUFFAGE_BUREAU"],"setTime", tonumber(os.time(t)) + 1*5)
                
    fibaro:call(id["CHAUFFAGE_CHAMBRE"],"setTargetLevel", "4")
    fibaro:call(id["CHAUFFAGE_CHAMBRE"],"setTime", tonumber(os.time(t)) + 1*5)
              
    fibaro:call(id["CHAUFFAGE_CHAMBRE_OWEN"],"setTargetLevel", "4")
	fibaro:call(id["CHAUFFAGE_CHAMBRE_OWEN"],"setTime", tonumber(os.time(t)) + 1*5)

fibaro:debug("Relance chauffage [°C + sec]")
fibaro:log("Relance chauffage [°C + sec]")
fibaro:sleep(2000) -- 2sec
]]--


-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  
-- GESTION DU PANEL DE CHAUFFAGE FIBARO --
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  

	
local tmpOff = 4 -- température pour HP Off

----------------------------------
-- DO not change bellow this line
---------------------------------
local HC2 = Net.FHttp("127.0.0.1",11111)

-- détermination de la version du firmware
local GETheating = ""
payload = "/api/settings/info"
response, status, errorCode = HC2:GET(payload)
if tonumber(status) == 200 
  then
	jsonTable = json.decode(response)
	if tonumber(jsonTable.softVersion) >= 4 
      then
--		version = "4.x"
        GETheating = "/api/panels/heating/"
      else
--		version = "3.x"
        GETheating = "/api/panels/heating?id="
	end
  else
	fibaro:debug('<span style="color:red;">status='..status..', errorCode='..errorCode..', payload='..payload..', response='..response..'</span>')
end

-- fonction de mise à jour du heating panel
-- si handTemperature == 0, c'est en auto
function HeatPanel(id,HandTmp)
  jsonpanel = HC2:GET(GETheating ..id)
  jsontable = json.decode(jsonpanel)
  handTimestamp = jsontable.properties.handTimestamp
  handTemperature = jsontable.properties.handTemperature
  name = jsontable.name
  NouveauPanel = ('{"id":' ..id.. ',"name":"'..name.. '","properties":{"handTemperature":' ..handTemperature.. ',"handTimestamp": ' ..handTimestamp.. ',"vacationTemperature":' ..HandTmp.. '}}')
  HC2:PUT(GETheating ..id, NouveauPanel)
end

-- fonction pour trouver l'ID du heating panel
function HeatPanelID()
  --fibaro:debug("hpName = " ..hpName)
  for j = 1, #hpID, 2 do
  --fibaro:debug(hpID[j])
    if hpName == hpID[j] then hpId = hpID[j+1] end
  end
end

hpName = "" -- nom du HP en cours de traiemeent
hpId = 0    -- ID du HP en cours de traitement


-- lecture de Mode_chauffage = OFF/Auto
local Mode_chauffage = fibaro:getGlobal(varMode_chauffage)


-- Mode_chauffage = OFF, alors tout les HP sont en vacance

for i = 1, #hpID, 2 do
  HeatPanel(hpID[i+1], tmpOff)
end


-- Mode_chauffage = Auto, alors tout les HP sont en auto
if Mode_chauffage == "Auto" then
    fibaro:debug("Programme de chauffage en mode automatique")
    fibaro:debug("Mode Chauffage => Auto")
--  if Chauffage == 0
--    then
  -- Zone 1
      hpId = 0
      for i = 1, #Zone_1 do
        hpName = Zone_1[i]
        HeatPanelID()
        HeatPanel(hpId, 0)
		end

  else
if ( fibaro:getGlobal("Mode_chauffage") == "OFF" ) then
fibaro:debug("Chauffage en mode OFF")
fibaro:log("Chauffage en mode OFF")
fibaro:sleep(2000) -- 2sec
end
end

 

Bouton réduit:

if ( fibaro:getGlobal("Mode_chauffage") == "OFF" ) then
fibaro:debug("Chauffage en mode OFF")
fibaro:log("Chauffage en mode OFF")
fibaro:sleep(2000) -- 2sec
  
fibaro:call(fibaro:getSelfId(),"setProperty","currentIcon","1084") -- Icone chauffage Off

elseif ( fibaro:getGlobal("Mode_chauffage") == "Auto" or "Reduit" ) then
  
if ( fibaro:getGlobal("Mode_chauffage") == "Reduit" ) then
fibaro:debug("Chauffage déja en mode Reduit")
fibaro:log("Chauffage déja en mode Reduit")    
fibaro:sleep(2000) -- 2sec
end

if ( fibaro:getGlobal("Mode_chauffage") == "Auto" ) then
fibaro:debug("Chauffage en mode Auto => Reduit")
fibaro:log("Chauffage en mode Auto => Reduit")
fibaro:sleep(2000) -- 2sec
    
fibaro:setGlobal("Mode_chauffage", "Reduit")
fibaro:debug("Mode chauffage = Reduit") 
fibaro:log("Mode chauffage = Reduit") 
fibaro:sleep(2000) -- 2sec
end
  
local id = 
  
	{
      	CHAUFFAGE_ENTREE = 402,
       	CHAUFFAGE_SALON = 208,
		CHAUFFAGE_SALLE = 212,
  		CHAUFFAGE_CUISINE = 210,
    	CHAUFFAGE_BUREAU = 214,
  	   	CHAUFFAGE_CHAMBRE = 162,
  	   	CHAUFFAGE_CHAMBRE_OWEN = 200,
   	} 

	fibaro:call(id["CHAUFFAGE_ENTREE"],"setTargetLevel", "17");
	fibaro:call(id["CHAUFFAGE_ENTREE"],"setTime", tonumber(os.time(t)) + 120*60);
  
    fibaro:call(id["CHAUFFAGE_SALON"],"setTargetLevel", "17"); 
 	fibaro:call(id["CHAUFFAGE_SALON"],"setTime", tonumber(os.time(t)) + 120*60);
    
    fibaro:call(id["CHAUFFAGE_SALLE"],"setTargetLevel", "17");
  	fibaro:call(id["CHAUFFAGE_SALLE"],"setTime", tonumber(os.time(t)) + 120*60);
      
    fibaro:call(id["CHAUFFAGE_CUISINE"],"setTargetLevel", "17");
    fibaro:call(id["CHAUFFAGE_CUISINE"],"setTime", tonumber(os.time(t)) + 120*60);
        
    fibaro:call(id["CHAUFFAGE_BUREAU"],"setTargetLevel", "17");
	fibaro:call(id["CHAUFFAGE_BUREAU"],"setTime", tonumber(os.time(t)) + 120*60);
                
    fibaro:call(id["CHAUFFAGE_CHAMBRE"],"setTargetLevel", "17");
    fibaro:call(id["CHAUFFAGE_CHAMBRE"],"setTime", tonumber(os.time(t)) + 120*60);
              
    fibaro:call(id["CHAUFFAGE_CHAMBRE_OWEN"],"setTargetLevel", "17");
	fibaro:call(id["CHAUFFAGE_CHAMBRE_OWEN"],"setTime", tonumber(os.time(t)) + 120*60);
  
end

 

 

Bouton OFF:

--Création d'une variable prédéfinie "Mode_chauffage" : "Auto"/"OFF"
local varMode_chauffage = "Mode_chauffage"

-- ID des zones de chauffages
local hpID = 
	{
    "Chambre", 5,
    "Bureau", 6,
    "Rez-de-chaussee", 199,
    "Chambre_Owen", 200,
    }

-- HeatingPanels actifs pour variable Chauffage Zone 1
local Zone_1 = 
	{
	"Chambre",
    "Bureau",
    "Rez-de-chaussee",
    "Chambre_Owen",
    }
fibaro:debug ("Nombre de zone = " ..#Zone_1)

local id = 
  
	{
      	CHAUFFAGE_ENTREE = 402,
       	CHAUFFAGE_SALON = 208,
		CHAUFFAGE_SALLE = 212,
  		CHAUFFAGE_CUISINE = 210,
    	CHAUFFAGE_BUREAU = 214,
  	   	CHAUFFAGE_CHAMBRE = 162,
  	   	CHAUFFAGE_CHAMBRE_OWEN = 200,
   	}

--[[
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  
-- RELANCE DE CHAUFFAGE --
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  

	fibaro:call(id["CHAUFFAGE_ENTREE"],"setTime", tonumber(os.time(t)) + 1*5)
  
 	fibaro:call(id["CHAUFFAGE_SALON"],"setTime", tonumber(os.time(t)) + 1*5)
    
  	fibaro:call(id["CHAUFFAGE_SALLE"],"setTime", tonumber(os.time(t)) + 1*5)
      
	fibaro:call(id["CHAUFFAGE_CUISINE"],"setTime", tonumber(os.time(t)) + 1*5)
        
	fibaro:call(id["CHAUFFAGE_BUREAU"],"setTime", tonumber(os.time(t)) + 1*5)
                
    fibaro:call(id["CHAUFFAGE_CHAMBRE"],"setTime", tonumber(os.time(t)) + 1*5)
              
	fibaro:call(id["CHAUFFAGE_CHAMBRE_OWEN"],"setTime", tonumber(os.time(t)) + 1*5)
]]--
	
if ( fibaro:getGlobal(varMode_chauffage) == "Auto" ) then
fibaro:setGlobal(varMode_chauffage, "OFF")
fibaro:debug("Chauffage en mode Auto => OFF")
fibaro:log("Chauffage en mode Auto => OFF")
  
elseif ( fibaro:getGlobal(varMode_chauffage) == "OFF" ) then
fibaro:debug("Chauffage déja en mode OFF")
fibaro:log("Chauffage déja en mode OFF")

end




-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  
-- GESTION DU PANEL DE CHAUFFAGE FIBARO --
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  

	
local tmpOff = 4 -- température pour HP Off

----------------------------------
-- DO not change bellow this line
---------------------------------
local HC2 = Net.FHttp("127.0.0.1",11111)

-- détermination de la version du firmware
local GETheating = ""
payload = "/api/settings/info"
response, status, errorCode = HC2:GET(payload)
if tonumber(status) == 200 
  then
	jsonTable = json.decode(response)
	if tonumber(jsonTable.softVersion) >= 4 
      then
--		version = "4.x"
        GETheating = "/api/panels/heating/"
      else
--		version = "3.x"
        GETheating = "/api/panels/heating?id="
	end
  else
	fibaro:debug('<span style="color:red;">status='..status..', errorCode='..errorCode..', payload='..payload..', response='..response..'</span>')
end

-- fonction de mise à jour du heating panel
-- si handTemperature == 0, c'est en auto
function HeatPanel(id,HandTmp)
  jsonpanel = HC2:GET(GETheating ..id)
  jsontable = json.decode(jsonpanel)
  handTimestamp = jsontable.properties.handTimestamp
  handTemperature = jsontable.properties.handTemperature
  name = jsontable.name
  NouveauPanel = ('{"id":' ..id.. ',"name":"'..name.. '","properties":{"handTemperature":' ..handTemperature.. ',"handTimestamp": ' ..handTimestamp.. ',"vacationTemperature":' ..HandTmp.. '}}')
  HC2:PUT(GETheating ..id, NouveauPanel)
end

-- fonction pour trouver l'ID du heating panel
function HeatPanelID()
  --fibaro:debug("hpName = " ..hpName)
  for j = 1, #hpID, 2 do
  --fibaro:debug(hpID[j])
    if hpName == hpID[j] then hpId = hpID[j+1] end
  end
end

hpName = "" -- nom du HP en cours de traiemeent
hpId = 0    -- ID du HP en cours de traitement


-- lecture de Mode_chauffage = OFF/Auto
local Mode_chauffage = fibaro:getGlobal(varMode_chauffage)


-- Mode_chauffage = OFF, alors tout les HP sont en vacance

for i = 1, #hpID, 2 do
  HeatPanel(hpID[i+1], tmpOff)
end


-- Mode_chauffage = Auto, alors tout les HP sont en auto
if Mode_chauffage == "Auto" then
    fibaro:debug("Programme de chauffage en mode automatique")
    fibaro:debug("Mode Chauffage => Auto")
--  if Chauffage == 0
--    then
  -- Zone 1
      hpId = 0
      for i = 1, #Zone_1 do
        hpName = Zone_1[i]
        HeatPanelID()
        HeatPanel(hpId, 0)
		end
  
  else
if ( fibaro:getGlobal("Mode_chauffage") == "OFF" ) then
fibaro:debug("Chauffage en mode OFF")
fibaro:log("Chauffage en mode OFF")
fibaro:sleep(2000) -- 2sec
end
end

 

Partager ce message


Lien à poster
Partager sur d’autres sites

Oui j'ai déjà vu ce code, la différence c'est que tu balances l'ID et le NAME en plus dans ta chaine json :

jsontable = json.decode(jsonpanel)

handTimestamp = jsontable.properties.handTimestamp
handTemperature = jsontable.properties.handTemperature
name = jsontable.name

NouveauPanel = ('{"id":' ..id.. ',"name":"'..name.. '","properties":{"handTemperature":' ..handTemperature.. ',"handTimestamp": ' ..handTimestamp.. ',"vacationTemperature":' ..HandTmp.. '}}')

HC2:PUT(GETheating ..id, NouveauPanel)

mois je ne fais que toucher aux propriété qui m'intéressent :

jsonTable = json.decode(response)

jsonTable.properties.handTemperature = Consigne
jsonTable.properties.handTimestamp = Duree
jsonTable = json.encode(jsonTable)

response ,status, errorCode = HC2:PUT("/api/panels/heating/"..Id, jsonTable)

 

alors est ce que ça vient de là ????????? aucune idée... je dirais que non...

Parce que si la programmation du panneau de chauffage plantait, ça le ferait depuis le début, la consigne manuelle ne démarrerait même pas !

Et elle démarre à chaque fois ! c'est le retour en mode schedule qui plante...

 

 

  • Like 1

Partager ce message


Lien à poster
Partager sur d’autres sites

×