Page 13 sur 19
Re: Projet TBH
Publié : 10 déc. 2015, 22:23
par slybreiz
Code : Tout sélectionner
2015-12-10 22:20:05.311 LUA: <br>17.4 58 6.3 92
2015-12-10 22:20:05.311 LUA: <br>17.4;58;6.3;92
ca viendrais de la source ? du coup
Code : Tout sélectionner
#!/usr/bin/php
<?php
///////////////////////////////////////////////
// Slush Coin Check
///////////////////////////////////////////////
if($argc == 3) {
$username = $argv[1];
$password = $argv[2];
} else {
die("Usage: username password\n");
}
///////////////////////////////////////////////
// Create the temporary cookie
///////////////////////////////////////////////
$cookiefile = tempnam("", "slush_");
///////////////////////////////////////////////
// Get CSRF
///////////////////////////////////////////////
$url = "https://mon.projet-tbh.fr/accounts/login/?next=/";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookiefile);
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookiefile);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
curl_close($curl);
preg_match("/<input type='hidden' name='csrfmiddlewaretoken' value='(.*?)' \/>/", $data, $csrf);
///////////////////////////////////////////////
// Login to Slush
///////////////////////////////////////////////
$url = "https://mon.projet-tbh.fr/accounts/login/?next=/";
$postfields = "csrfmiddlewaretoken=$csrf[1]&username=$username&password=$password";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookiefile);
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookiefile);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
$data = curl_exec($curl);
curl_close($curl);
///////////////////////////////////////////////
// Visit earnings page
///////////////////////////////////////////////
$url = "https://mon.projet-tbh.fr/confort/data-confort-instantane";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookiefile);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
curl_close($curl);
///////////////////////////////////////////////
// Capture current temperature
///////////////////////////////////////////////
try{
$temperature = json_decode($data, true);
if(isset($temperature['temp_int']) and isset($temperature['hygro_int']) and isset($temperature['temp_ext']) and isset($temperature['hygro_ext']))$
echo $temperature['temp_int'] . ";" . $temperature['hygro_int'] . ";" . $temperature['temp_ext'] . ";" . $temperature['hygro_ext'];
} else {
echo null;
}
} catch(Exception $e){
echo($e);
}
///////////////////////////////////////////////
// Clean up cookie
///////////////////////////////////////////////
unlink($cookiefile);
?>
Re: Projet TBH
Publié : 10 déc. 2015, 23:02
par Neutrino
Le script php renvoie bien les bonnes données.
La ligne avec le 'match' est bizarre, il y a plein d'espaces à un endroit où il ne doit pas y en avoir.
Essaye ça :
Code : Tout sélectionner
commandArray = {}
---recupere l'heure en minutes
time=os.time()
minutes=tonumber(os.date('%M',time))
hours=tonumber(os.date('%H',time))
maintenant=tonumber(hours*60+minutes)
if(maintenant%10 ==0 )then
local appelTBH=assert(io.popen("php /home/pi/domoticz/scripts/php/capteur_meteo_2.php LOGIN MDP"))
local tempHygroTBH = appelTBH:read('*all')
appelTBH:close()
print(tempHygroTBH) -- affiche ce que nous renvoie le script PHP
tempInt,hygroInt,tempExt,hygroExt = tempHygroTBH:match("([^;]+);([^;]+);([^;]+);([^;]+)")
print(tempInt.." "..hygroInt.." "..tempExt.." "..hygroExt)
--Ensuite remplissez votre commandArray avec les donnees recueillies :)
tempInt = tostring(tonumber(tempInt))
tempExt= tostring(tonumber(tempExt))
hygroInt = tostring(tonumber(hygroInt))
hygroExt= tostring(tonumber(hygroExt))
commandArray[1] = {['UpdateDevice'] = '28|0|' ..tempInt..";"..hygroInt}
commandArray[2] = {['UpdateDevice'] = '29|0|' ..tempExt..";"..hygroExt}
end
return commandArray
Re: Projet TBH
Publié : 11 déc. 2015, 08:13
par slybreiz
même soucie
Code : Tout sélectionner
2015-12-11 08:10:07.010 LUA: <br>16.9 58 5 97
2015-12-11 08:10:07.017 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_time_tbhweb_meteo.lua
Code : Tout sélectionner
commandArray = {}
---recupere l'heure en minutes
time=os.time()
minutes=tonumber(os.date('%M',time))
hours=tonumber(os.date('%H',time))
maintenant=tonumber(hours*60+minutes)
if(maintenant%10 ==0 )then
local appelTBH=assert(io.popen("php /home/pi/domoticz/scripts/php/capteur_meteo_2.php LOGIN MDP"))
local tempHygroTBH = appelTBH:read('*all')
appelTBH:close()
tempInt,hygroInt,tempExt,hygroExt = tempHygroTBH:match("([^;]+);([^;]+);([^;]+);([^;]+)")
print(tempInt.." "..hygroInt.." "..tempExt.." "..hygroExt)
--Ensuite remplissez votre commandArray avec les donnees recueillies :)
tempInt = tostring(tonumber(tempInt))
tempExt= tostring(tonumber(tempExt))
hygroInt = tostring(tonumber(hygroInt))
hygroExt= tostring(tonumber(hygroExt))
commandArray[1] = {['UpdateDevice'] = '28|0|' ..tempInt..";"..hygroInt}
commandArray[2] = {['UpdateDevice'] = '29|0|' ..tempExt..";"..hygroExt}
end
return commandArray
Re: Projet TBH
Publié : 11 déc. 2015, 11:38
par Neutrino
Donc, là c'est vraiment bizarre...
Tu es sur quelle version de domoticz ?
Il serait peut être judicieux de passer en beta.
Re: Projet TBH
Publié : 11 déc. 2015, 18:17
par slybreiz
version stable V2 3530
par contre je suppose que si je passe en beta pas moyen de revenir en version normal .
Re: Projet TBH
Publié : 11 déc. 2015, 18:41
par slybreiz
Maj fait avec une petite sauvegarde avant bien sur :p
Code : Tout sélectionner
2015-12-11 18:30:05.457 LUA:
18.4 62 9.9 96
2015-12-11 18:30:05.464 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_time_tbhweb_meteo.lua
Re: Projet TBH
Publié : 11 déc. 2015, 19:25
par Neutrino
Il y a toujours moyen de revenir sur une stable

Au niveau de tes widgets température, ça donne quoi ?
Re: Projet TBH
Publié : 11 déc. 2015, 20:37
par slybreiz
toujours pareil pas d'affichage des temperature / humidite.
par contre j'ai fait un script lua juste avec la température et un widget température et la ça fonctionne l'affichage est correcte
je pense que je vais séparer les différentes courbes temp ext tempint et humint humiext pour voir les valeur dans les widget et garder les widjets temp/hum pour les pont de rosé .
en attendant d'avoir des vraies sonde températures :p
Re: Projet TBH
Publié : 11 déc. 2015, 22:13
par Neutrino
Mèkechuikon !
Le capteur temp + humidity attend 3 valeurs !
temp;hygro;statut !!!
Code : Tout sélectionner
commandArray[1] = {['UpdateDevice'] = '28|0|' ..tempInt..";"..hygroInt..";0"}
commandArray[2] = {['UpdateDevice'] = '29|0|' ..tempExt..";"..hygroExt..";0"}
Plus d'info ici :
http://www.domoticz.com/wiki/Domoticz_A ... 2Fhumidity
Re: Projet TBH
Publié : 12 déc. 2015, 20:36
par slybreiz
effectivement cela est mieux :p

- domoticz_tbh_capteur_ok.JPG (31.93 Kio) Consulté 9027 fois

- domoticz_tbh_capteur_ok.JPG (31.93 Kio) Consulté 9027 fois