Projet TBH

Forum dédié à tous les sujets sans liens avec DomoticZ.
Discuter de tout et de rien, c'est ici.
slybreiz
Messages : 89
Inscription : 14 oct. 2015, 14:33

Re: Projet TBH

Message 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);
?>
domoticz on synology dsm 6 DS109(hack DS112j) + RXFcom433E / Archos Home connecte / 4 * HC ECR-100 / Archos TBH / sonde température Alecto WS1700 / prise chacon
Neutrino
Messages : 2662
Inscription : 10 juil. 2015, 15:42
Localisation : Les Herbiers(85)

Re: Projet TBH

Message 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
Ma maison à plein d'IP ! :mrgreen:
SAV Bonjour. Vous avez vidé le cache ?
slybreiz
Messages : 89
Inscription : 14 oct. 2015, 14:33

Re: Projet TBH

Message 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

domoticz on synology dsm 6 DS109(hack DS112j) + RXFcom433E / Archos Home connecte / 4 * HC ECR-100 / Archos TBH / sonde température Alecto WS1700 / prise chacon
Neutrino
Messages : 2662
Inscription : 10 juil. 2015, 15:42
Localisation : Les Herbiers(85)

Re: Projet TBH

Message par Neutrino »

Donc, là c'est vraiment bizarre...
Tu es sur quelle version de domoticz ?
Il serait peut être judicieux de passer en beta.
Ma maison à plein d'IP ! :mrgreen:
SAV Bonjour. Vous avez vidé le cache ?
slybreiz
Messages : 89
Inscription : 14 oct. 2015, 14:33

Re: Projet TBH

Message par slybreiz »

version stable V2 3530

par contre je suppose que si je passe en beta pas moyen de revenir en version normal .
domoticz on synology dsm 6 DS109(hack DS112j) + RXFcom433E / Archos Home connecte / 4 * HC ECR-100 / Archos TBH / sonde température Alecto WS1700 / prise chacon
slybreiz
Messages : 89
Inscription : 14 oct. 2015, 14:33

Re: Projet TBH

Message 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
domoticz on synology dsm 6 DS109(hack DS112j) + RXFcom433E / Archos Home connecte / 4 * HC ECR-100 / Archos TBH / sonde température Alecto WS1700 / prise chacon
Neutrino
Messages : 2662
Inscription : 10 juil. 2015, 15:42
Localisation : Les Herbiers(85)

Re: Projet TBH

Message par Neutrino »

Il y a toujours moyen de revenir sur une stable :)
Au niveau de tes widgets température, ça donne quoi ?
Ma maison à plein d'IP ! :mrgreen:
SAV Bonjour. Vous avez vidé le cache ?
slybreiz
Messages : 89
Inscription : 14 oct. 2015, 14:33

Re: Projet TBH

Message 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
domoticz on synology dsm 6 DS109(hack DS112j) + RXFcom433E / Archos Home connecte / 4 * HC ECR-100 / Archos TBH / sonde température Alecto WS1700 / prise chacon
Neutrino
Messages : 2662
Inscription : 10 juil. 2015, 15:42
Localisation : Les Herbiers(85)

Re: Projet TBH

Message 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
Ma maison à plein d'IP ! :mrgreen:
SAV Bonjour. Vous avez vidé le cache ?
slybreiz
Messages : 89
Inscription : 14 oct. 2015, 14:33

Re: Projet TBH

Message par slybreiz »

effectivement cela est mieux :p
domoticz_tbh_capteur_ok.JPG
domoticz_tbh_capteur_ok.JPG (31.93 Kio) Consulté 9043 fois
domoticz_tbh_capteur_ok.JPG
domoticz_tbh_capteur_ok.JPG (31.93 Kio) Consulté 9043 fois
domoticz on synology dsm 6 DS109(hack DS112j) + RXFcom433E / Archos Home connecte / 4 * HC ECR-100 / Archos TBH / sonde température Alecto WS1700 / prise chacon
Répondre