Aller au contenu
Syris

Module Virtuel - Ipx800 + Shtx3

Recommended Posts

Bonjour,

 

 

Ci joint ma modeste contribution pour l'ipx 800 et le shtx3.

 

Quelq'un en avait déjà  fait un il me semble mais je ne l'ai pas retrouvé...

 

 

Je suis parti du principe que le module est câblé comme suit :

 

Luminosité : A1

Humidité : A2

Température : A3

 

 

Les formules des trois capteurs pour la conversion de l'analogique ont été péchés ici :

http://www.selso.com/dokuwiki/doku.php?id=ipx800

 

 

Dans le code, j'ai mis les deux solutions possibles concernant le capteur de luminosité (SH100) ou en lux (tiré des réglages de cet article : http://gurau-audibert.hd.free.fr/josdblog/2015/03/capteur-sht-x3-humidite-temperature-et-luminosite/) ou en %. Vous n'avez qu'a grisé l'un ou l'autre.

 

 

J'ai affiché en bas du module la valeur de la température, sa me semblait pas mal :)

 

 

Il faut donc 3 variables : lumshtx3/humshtx3/tempshtx3 et 4 labels.

 

 

 

Code bouton :

HC2 = Net.FHttp("192.168.1.60")
response = HC2:GET("/api/xdevices.json?cmd=30")

response = json.decode(response)

fibaro:setGlobal("lumshtx3", response.AN1)
fibaro:setGlobal("humshtx3", response.AN2)
fibaro:setGlobal("tempshtx3", response.AN3)


-- Calcul pour la luminosite (LS100) - (en pourcentage):
-- local lumcalcul = fibaro:getGlobalValue("lumshtx3") * 0.09775
-- lumcalcul = string.format("%.1f",lumcalcul)

-- Calcul pour la luminosite (LS100) - (en lux, formule non officiel):
local lumcalcul = fibaro:getGlobalValue("lumshtx3") * 4.8828
lumcalcul = string.format("%.1f",lumcalcul)

-- Calcul pour l'humidité (SH100) :
local humcalcul = (((fibaro:getGlobalValue("humshtx3") * 0.00323 / 3.3)-0.1515) / 0.00636 / (1.0546 - (0.00216 * ((fibaro:getGlobalValue("tempshtx3"))* 0.00323 - 1.63) / 0.0326)))
humcalcul = string.format("%.2f",humcalcul)

-- Calcul pour la température (TC5050) :
local tempcalcul = ((((fibaro:getGlobalValue("tempshtx3")* 0.00323) - 1.63) / 0.0326))
tempcalcul = string.format("%.2f",tempcalcul)

fibaro:debug(lumcalcul)
fibaro:debug(humcalcul)
fibaro:debug(tempcalcul)

fibaro:log(tempcalcul.." °C ")


DateHeure = os.date("%Y-%m-%d %H:%M:%S", os.time())
fibaro:debug(DateHeure)

fibaro:call(fibaro:getSelfId(),"setProperty","ui.Label1.value", lumcalcul .." Lux")
-- fibaro:call(fibaro:getSelfId(),"setProperty","ui.Label1.value", lumcalcul .." %")
fibaro:call(fibaro:getSelfId(),"setProperty","ui.Label2.value", humcalcul .. " %")
fibaro:call(fibaro:getSelfId(),"setProperty","ui.Label3.value", tempcalcul .. " °C")
fibaro:call(fibaro:getSelfId(),"setProperty","ui.Label4.value",DateHeure)

Boucle Principale :

local myDeviceID = fibaro:getSelfId() 
if type(n) == "nil" then
n1 = tonumber(os.time())
fibaro:call(myDeviceID, "pressButton", "1")
n = 1
end
if tonumber(os.time()) > n1 + (4) then
 fibaro:call(myDeviceID, "pressButton", "1")
 n1 = tonumber(os.time())
end

post-2984-0-82315400-1439460346_thumb.png

post-2984-0-14043800-1439460412_thumb.png

post-2984-0-80365500-1439460426_thumb.png

Module_Shtx3.vfib

  • Upvote 2

Partager ce message


Lien à poster
Partager sur d’autres sites

Oui, effectivement je me suis inspiré de ton code concernant le x400t que j'ai très bien compris.

Partager ce message


Lien à poster
Partager sur d’autres sites

sweet38000 :

 

En bidouillant si : http://www.domotique-fibaro.fr/index.php/topic/4832-installer-un-plugin-utilisateur-en-40x/?hl=%20virtual%20%20sensor

Mais a chaque reboot, ils ne fonctionneront plus.

 

Et si c'est pour gérer le shtx3, je n'ai jamais réussi a rentrer les formules : http://www.domotique-fibaro.fr/index.php/topic/5278-shtx3-ipx800-et-virtual-sensor/?hl=%2Bvirtual+%2Bsensor

  • Upvote 1

Partager ce message


Lien à poster
Partager sur d’autres sites

J'ai répondu dans l'autre topic, cela devrait fonctionner.

Partager ce message


Lien à poster
Partager sur d’autres sites

×