Aller au contenu

Messages recommandés

Posté(e)

Visualisation des Températures par ordres décroissant

 

 

 

 

Ce VD va vous permettre de visualiser toutes les sondes de température

 

 

Il suffit d'importer le VD pour que cela fonctionne

 

med_gallery_374_242_6153.png
 
 
 

Fichier à  télécharger : Mise a jours version 0.90b : unknown.gif  Temperature_v0.9b.vfib

  • Upvote 2
Posté(e)

les flèches, c'est pour naviguer dans les pages  ?

Alors pourrais-je suggérer d'afficher le n° de page et le nombre total de pages :

Page   2/4

ou

Page   1/1

  • 2 semaines après...
Posté(e)

Mise a jours version 0.90b : Temperature_v0.9b.vfib

 


 
med_gallery_374_242_6153.png
 
Code <--------------

HC2 = Net.FHttp("127.0.0.1",11111) 
R_Modules = HC2:GET("/api/devices")
local AllModules = json.decode(R_Modules)
Reponse1 = HC2:GET("/api/sections")
local Sections = json.decode(Reponse1)
Reponse2 = HC2:GET("/api/rooms")
local Room = json.decode(Reponse2)
------------------------------------------------------  
local Temperature = {}
local SelfId = fibaro:getSelfId()
local IdEnd = AllModules[#AllModules].id
local Page = tonumber(fibaro:getValue(SelfId, "ui.LabPage.value"))
local LabSections = fibaro:getValue(SelfId, "ui.LabSection.value")
local LabPieces = fibaro:getValue(SelfId, "ui.LabPieces.value")
------------------------------------------------------------
-- Recuperer nom + section a partir d'une id
-------------------------------------------------------------
function recupvaleur(RoomID)
      for i,v in ipairs(Room) do
          if Room[i].id == RoomID then
             local RoomName = Room[i].name
             local SectionID = Room[i].sectionID
             for k,w in ipairs(Sections) do
                if Sections[k].id == SectionID then 
                   local a , b = RoomName, Sections[k].name
                   return b , a
                end
             end
          end
      end
end
---------------------------------------------------------------------
-- Création de la table des température
---------------------------------------------------------------------
for i,v in ipairs(AllModules) do
    if AllModules[i].visible == true and AllModules[i].type == "com.fibaro.temperatureSensor" then 
       local id = AllModules[i].id
       local PieceID = AllModules[i].roomID
       local Nom = AllModules[i].name
       local SectionName , PieceName = recupvaleur(PieceID)
       local Valeur = tonumber(AllModules[i].properties.value)
       if LabSections == "Tous" then
          table.insert(Temperature, {SectionName, PieceName, Nom, Valeur})
          fibaro:debug(SectionName.." - "..PieceName.." - "..Nom.." - "..Valeur.." degrés")
       else
          if SectionName == LabSections and LabPieces == "Tous" then
             table.insert(Temperature, {SectionName, PieceName, Nom, Valeur})
             --fibaro:debug(SectionName.." - "..PieceName.." - "..Nom.." - "..Valeur.." degrés")
          else
             if SectionName == LabSections and LabPieces == PieceName then
                table.insert(Temperature, {SectionName, PieceName, Nom, Valeur})
             end
          end
       end
    end
end


table.sort(Temperature, function(a, return a[4]>b[4] end)
local t = tonumber(#Temperature)
------------------------------------------------------------------
-- Mise a jour des labels et gestion des pages
------------------------------------------------------------------
if Page == nil or Page <= 1 then
  Page = 1
else
  Page = Page - 1
end

if t == 0 then
   fibaro:call(SelfId, "setProperty", "ui.LabMiniMax.value", "Pas de sondes")
else
   fibaro:call(SelfId,"setProperty","ui.LabPage.value", Page)
   fibaro:call(SelfId, "setProperty", "ui.LabMiniMax.value", "Max : "..Temperature[1][4].." C - Mini : "..Temperature[#Temperature][4].." C - Nbre "..t)
end

local p = Page*5-5
for i = 1, 5 do 
  fibaro:debug("i = "..i.." Page = "..p.."Table = "..t)
  if t < i+p then
    fibaro:call(SelfId, "setProperty", "ui.Label"..i..".value", "")
  else   
    fibaro:call(SelfId, "setProperty", "ui.Label"..i..".value", Temperature[i+p][2].." - "..Temperature[i+p][3].." : "..Temperature[i+p][4].." C")
  end
end

code -------->

HC2 = Net.FHttp("127.0.0.1",11111) 
R_Modules = HC2:GET("/api/devices")
local AllModules = json.decode(R_Modules)
Reponse1 = HC2:GET("/api/sections")
local Sections = json.decode(Reponse1)
Reponse2 = HC2:GET("/api/rooms")
local Room = json.decode(Reponse2)
------------------------------------------------------  
local Temperature = {}
local SelfId = fibaro:getSelfId()
local IdEnd = AllModules[#AllModules].id
local Page = tonumber(fibaro:getValue(SelfId, "ui.LabPage.value"))
fibaro:debug("Nombres de modules : " ..#AllModules.." - Sections : "..#Sections)
fibaro:debug("Dernier ID : "..IdEnd)
local LabSections = fibaro:getValue(SelfId, "ui.LabSection.value")
local LabPieces = fibaro:getValue(SelfId, "ui.LabPieces.value")

-------------------------------------------------------------
-- Recuperer nom + section a partir d'une id
-------------------------------------------------------------
function recupvaleur(RoomID)
      for i,v in ipairs(Room) do
          if Room[i].id == RoomID then
             local RoomName = Room[i].name
             local SectionID = Room[i].sectionID
             for k,w in ipairs(Sections) do
                if Sections[k].id == SectionID then 
                   local a , b = RoomName, Sections[k].name
                   return b , a
                end
             end
          end
      end
end
---------------------------------------------------------------------
-- Création de la table des température
---------------------------------------------------------------------
for i,v in ipairs(AllModules) do
    if AllModules[i].visible == true and AllModules[i].type == "com.fibaro.temperatureSensor" then 
       local id = AllModules[i].id
       local PieceID = AllModules[i].roomID
       local Nom = AllModules[i].name
       local SectionName , PieceName = recupvaleur(PieceID)
       local Valeur = tonumber(AllModules[i].properties.value)
       if LabSections == "Tous" then
          table.insert(Temperature, {SectionName, PieceName, Nom, Valeur})
          --fibaro:debug(SectionName.." - "..PieceName.." - "..Nom.." - "..Valeur.." degrés")
       else
          if SectionName == LabSections and LabPieces == "Tous" then
             table.insert(Temperature, {SectionName, PieceName, Nom, Valeur})
             --fibaro:debug(SectionName.." - "..PieceName.." - "..Nom.." - "..Valeur.." degrés")
          else
             if SectionName == LabSections and LabPieces == PieceName then
                table.insert(Temperature, {SectionName, PieceName, Nom, Valeur})
             end
          end
       end
       --fibaro:debug(SectionName.." - "..PieceName.." - "..Nom.." - "..Valeur.." degrés")
    end
end

table.sort(Temperature, function(a, return a[4]>b[4] end)
local t = tonumber(#Temperature)
------------------------------------------------------------------
-- Mise a jour des labels et gestion des pages
------------------------------------------------------------------
if Page == nil then
  Page = 1
elseif Page >= t/5 then
  -- ne modifie rien
else
  Page = Page + 1
end
if t == 0 then
   fibaro:call(SelfId, "setProperty", "ui.LabMiniMax.value", "Pas de sondes")
else
   fibaro:call(SelfId,"setProperty","ui.LabPage.value", Page)
   fibaro:call(SelfId, "setProperty", "ui.LabMiniMax.value", "Max : "..Temperature[1][4].." C - Mini : "..Temperature[#Temperature][4].." C - Nbre "..t)
end


local p = Page*5-5
for i = 1, 5 do 
  fibaro:debug("i = "..i.." j = "..p.."Table = "..t)
  if t < i+p then
    fibaro:call(SelfId, "setProperty", "ui.Label"..i..".value", "")
  else   
    fibaro:call(SelfId, "setProperty", "ui.Label"..i..".value", Temperature[i+p][2].." - "..Temperature[i+p][3].." : "..Temperature[i+p][4].." C")
  end
end

code -Piece

HC2 = Net.FHttp("127.0.0.1",11111)
Reponse1 = HC2:GET("/api/sections")
local Sections = json.decode(Reponse1)
table.insert(Sections, {name = "Tous"})
Reponse2 = HC2:GET("/api/rooms")
local Room = json.decode(Reponse2)
table.insert(Room, {name = "Tous"})
local SelfId = fibaro:getSelfId()
local LabSections = fibaro:getValue(SelfId, "ui.LabSection.value")

-- Recuperation de l'id de la section 
if LabSections ~= "Tous" then
   for i,v in ipairs(Sections) do
       if LabSections == Sections[i].name then
          IDSections = Sections[i].id 
          fibaro:debug(IDSections)
          break
       end
   end
else
  IDSections = "Tous"
end
fibaro:debug("id Section: "..IDSections)
-- creation de la table des pieces dans la section
local NomRoom = {"Tous"}
if IDSections ~= "Tous" then
   for i,v in ipairs(Room) do
      if Room[i].sectionID == IDSections then
         table.insert(NomRoom, Room[i].name)
         --fibaro:debug(Room[i].name)
      end
   end
else
   for i,v in ipairs(Room) do
      table.insert(NomRoom, Room[i].name)
      --fibaro:debug(Room[i].name)
   end
end  
--------------------------------------------------------------
local LabPieces = fibaro:getValue(SelfId, "ui.LabPieces.value")
fibaro:call(SelfId, "setProperty", "ui.LabPieces.value", "Tous")
for i = 1, #(NomRoom) do
    fibaro:debug(LabPieces.." "..i.." "..NomRoom[i])
    if LabPieces == NomRoom[i] and i > 1 then
       LabPieces = NomRoom[i -1]
       break
    end
end

 
fibaro:debug("piece "..LabPieces)

fibaro:call(SelfId,"setProperty","ui.LabPage.value", "1")
fibaro:call(SelfId, "setProperty", "ui.LabPieces.value", LabPieces)
fibaro:call(SelfId, "pressButton", "10")



code Piece+

HC2 = Net.FHttp("127.0.0.1",11111)
Reponse1 = HC2:GET("/api/sections")
local Sections = json.decode(Reponse1)
table.insert(Sections, {name = "Tous"})
Reponse2 = HC2:GET("/api/rooms")
local Room = json.decode(Reponse2)
table.insert(Room, {name = "Tous"})
local SelfId = fibaro:getSelfId()
local LabSections = fibaro:getValue(SelfId, "ui.LabSection.value")
-- Recuperation de l'id de la section 
if LabSections ~= "Tous" then
   for i,v in ipairs(Sections) do
       if LabSections == Sections[i].name then
          IDSections = Sections[i].id 
          fibaro:debug(IDSections)
          break
       end
   end
else
  IDSections = "Tous"
end
fibaro:debug("id Section: "..IDSections)
-- creation de la table des pieces dans la section
local NomRoom = {"Tous"}
if IDSections ~= "Tous" then
   for i,v in ipairs(Room) do
      if Room[i].sectionID == IDSections then
         table.insert(NomRoom, Room[i].name)
         --fibaro:debug(Room[i].name)
      end
   end
else
   for i,v in ipairs(Room) do
      table.insert(NomRoom, Room[i].name)
      --fibaro:debug(Room[i].name)
   end
end  
--------------------------------------------------------------
local LabPieces = fibaro:getValue(SelfId, "ui.LabPieces.value")
fibaro:call(SelfId, "setProperty", "ui.LabPieces.value", "Tous")
for i = 1, #(NomRoom) do
    fibaro:debug(LabPieces.." "..i.." "..NomRoom[i])
    if LabPieces == NomRoom[i] and i < #(NomRoom) then
       LabPieces = NomRoom[i +1]
       break
    end
end

 
fibaro:debug("piece "..LabPieces)

fibaro:call(SelfId,"setProperty","ui.LabPage.value", "1")
fibaro:call(SelfId, "setProperty", "ui.LabPieces.value", LabPieces)
fibaro:call(SelfId, "pressButton", "10")

Code - Sect

HC2 = Net.FHttp("127.0.0.1",11111)
Reponse1 = HC2:GET("/api/sections")
local Sections = json.decode(Reponse1)
table.insert(Sections, {name = "Tous"})
local SelfId = fibaro:getSelfId()
local LabSections = fibaro:getValue(SelfId, "ui.LabSection.value")
fibaro:call(SelfId, "setProperty", "ui.LabSection.value", "Tous")
for i,v in ipairs(Sections) do
    if LabSections == Sections[i].name and i > 1 then --or Sections[i].name == "Tous" then
       LabSections = Sections[i -1].name 
       break
    end
end
if LabSections == "" then
  LabSections = "Tous"
end
fibaro:debug("nom :"..LabSections)
fibaro:call(SelfId,"setProperty","ui.LabPage.value", "1")
fibaro:call(SelfId, "setProperty", "ui.LabSection.value", LabSections)
fibaro:call(SelfId, "setProperty", "ui.LabPieces.value", "Tous")
fibaro:call(SelfId, "pressButton", "10")

code Sect +

HC2 = Net.FHttp("127.0.0.1",11111)
Reponse1 = HC2:GET("/api/sections")
local Sections = json.decode(Reponse1)
table.insert(Sections, {name = "Tous"})
local SelfId = fibaro:getSelfId()
local LabSections = fibaro:getValue(SelfId, "ui.LabSection.value")
fibaro:call(SelfId, "setProperty", "ui.LabSection.value", "Tous")
for i,v in ipairs(Sections) do
    local t = #Sections
    fibaro:debug("table = "..t)
    if LabSections == Sections[i].name and i <= t -1 then
       LabSections = Sections[i +1].name
       break
    end
end
if LabSections == "" then
  LabSections = "Tous"
end
fibaro:debug("nom :"..LabSections)
fibaro:call(SelfId,"setProperty","ui.LabPage.value", "1")
fibaro:call(SelfId, "setProperty", "ui.LabSection.value", LabSections)
fibaro:call(SelfId, "setProperty", "ui.LabPieces.value", "Tous")
fibaro:call(SelfId, "pressButton", "10")

Temperature_v0.9b.vfib

×
×
  • Créer...