Projet TBH

Forum dédié à tous les sujets sans liens avec DomoticZ.
Discuter de tout et de rien, c'est ici.
deennoo
Messages : 4036
Inscription : 25 janv. 2015, 02:00

Re: Projet TBH

Message par deennoo »

C'est pas un script payant ?? Tu casses le marché !! Lol
De quoi se faire Plaisir et essayer d'aider...
http://www.domo-attitude.fr
Neutrino
Messages : 2662
Inscription : 10 juil. 2015, 15:42
Localisation : Les Herbiers(85)

Re: Projet TBH

Message par Neutrino »

T'as raison, je devrais le mettre sur le market de domoticz et le faire payer.... Mince, tout est gratuit ici :mrgreen:
@slybreiz, il faut créer des capteurs virtuels de type température + humidité.
ensuite tu envoies les données avec un truc genre :

Code : Tout sélectionner

commandArray[1] = {['UpdateDevice'] = IDXdeTonCapteur.. '|0|' .. TEMP..";"..HYGRO}
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 »

merci

j'ai donc rajouter :

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.php login MDG "))

   local tempHyroTBH = appelTBH:read('*all')
   appelTBH:close()
   tempInt,hygroInt,tempExt,hygroExt = tempHyroTBH:match("([^;]+);([^;]+);([^;]+);([^;]+)")
   print(tempInt.." "..hygroInt.." "..tempExt.." "..hygroExt)
   --Ensuite remplissez votre commandArray avec les donnees recueillies :)

commandArray[1] = {['UpdateDevice'] = 28.. '|0|' .. tempInt..";"..hygroInt}

commandArray[2] = {['UpdateDevice'] = 29.. '|0|' .. tempExt..";"..hygroExt}

end
return commandArray

Code : Tout sélectionner

2015-12-01 20:59:00.198 Error: EventSystem: /home/pi/domoticz/scripts/lua/script_time_tbhweb_meteo.lua:18: malformed number near '28..'
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
mich423
Messages : 44
Inscription : 23 avr. 2015, 21:44

Re: Projet TBH

Message par mich423 »

Bonsoir,
J'essaie de récupérer la température et humidité intérieure et extérieure, j'ai l'erreur suivante:

unexpected symbol near ')'

Voici mon script, pouvez vous m'aider. Merci.

commandArray = {}

-- Time to run?

time = os.date("*t")

if ((time.hour == 7 or time.hour == 11 or time.hour == 15 or time.hour == 19 or time.hour == 23) and time.min == 00) then

local appelTBH=assert(io.popen("php /home/pi/domoticz/scripts/tbhweb.php"))

local tempHyroTBH = appelTBH:read('*all')
appelTBH:close()
tempInt,hygroInt,tempExt,hygroExt = tempHyroTBH:match("([^;]+);([^;]+);([^;]+);([^;]+)")
print(tempInt.." "..hygroInt.." "..tempExt.." "..tempExt..)
--Ensuite remplissez votre commandArray avec les données recueillies :)
commandArray[1] = {['UpdateDevice'] = 146 '|0|' tempInt..";"..hygroInt..}
commandArray[2] = {['UpdateDevice'] = 147 '|0|' ..tempExt..";"..tempExt..}
end
return commandArray
Domoticz sur Win7 - 4 ds18s20 1-Wire avec ESP8266 - 4 modules relais avec ESP8266- conso EDF OWL CM 180 - RFXTrx433 - Rflink - 4 capteurs température 433Mhz Oregon DIY - 3 Rising Sun - 4 Chacon - Yana Server - Imperihome - Cde portail avec ZK1PA -
Neutrino
Messages : 2662
Inscription : 10 juil. 2015, 15:42
Localisation : Les Herbiers(85)

Re: Projet TBH

Message par Neutrino »

J'aime bien ne pas donner des scripts complets, ça permet au gens de faire des erreurs et d'apprendre ;)


@slybreik

Code : Tout sélectionner

commandArray[1] = {['UpdateDevice'] = '28|0|' .. tempInt..";"..hygroInt}

commandArray[2] = {['UpdateDevice'] = '29|0|' .. tempExt..";"..hygroExt}
@mich423
il manque ton login et mot de passe (mais c'est peut-être fait exprès), ensuite, regarde la réponse ci-dessus :)
les .. servent à assembler 2 chaînes, donc finir par hygroExt.. ne marchera pas.
Ma maison à plein d'IP ! :mrgreen:
SAV Bonjour. Vous avez vidé le cache ?
mich423
Messages : 44
Inscription : 23 avr. 2015, 21:44

Re: Projet TBH

Message par mich423 »

Bonsoir,

merci, je viens de modifier comme ceci (pour le login et mot de passe, c'est fait exprès ), toujours la même erreur, voici mon script complet

commandArray = {}

-- Time to run?

time = os.date("*t")

if ((time.hour == 7 or time.hour == 11 or time.hour == 15 or time.hour == 19 or time.hour == 23) and time.min == 00) then

local appelTBH=assert(io.popen("php /home/pi/domoticz/scripts/tbhweb.php login mot_de_passe"))

local tempHyroTBH = appelTBH:read('*all')
appelTBH:close()
tempInt,hygroInt,tempExt,hygroExt = tempHyroTBH:match("([^;]+);([^;]+);([^;]+);([^;]+)")
print(tempInt.." "..hygroInt.." "..tempExt.." "..tempExt..)
--Ensuite remplissez votre commandArray avec les données recueillies :)
commandArray[1] = {['UpdateDevice'] = 146 '|0|' ..tempInt..";"..hygroInt}
commandArray[2] = {['UpdateDevice'] = 147 '|0|' ..tempExt..";"..tempExt}
end
return commandArray

et l'erreur:

unexpected symbol near ')'
Domoticz sur Win7 - 4 ds18s20 1-Wire avec ESP8266 - 4 modules relais avec ESP8266- conso EDF OWL CM 180 - RFXTrx433 - Rflink - 4 capteurs température 433Mhz Oregon DIY - 3 Rising Sun - 4 Chacon - Yana Server - Imperihome - Cde portail avec ZK1PA -
Neutrino
Messages : 2662
Inscription : 10 juil. 2015, 15:42
Localisation : Les Herbiers(85)

Re: Projet TBH

Message par Neutrino »

Nouvelle version du script tbhweb.php pour prendre en compte les rupture de synchro entre la tablette et leur serveurs :

Code : Tout sélectionner

<?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);
?>
Ensuite pour mich423:

Code : Tout sélectionner

commandArray[1] = {['UpdateDevice'] = '146|0|' ..tempInt..";"..hygroInt}
commandArray[2] = {['UpdateDevice'] = '147|0|' ..tempExt..";"..tempExt}
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 »

Ok merci

Oui le login MDP fait exprès .

Oui je comprend mieux maintenant ça permet d apprendre .:-)
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
mich423
Messages : 44
Inscription : 23 avr. 2015, 21:44

Re: Projet TBH

Message par mich423 »

Désolé,
même avec tes modifications, toujours la même erreur

unexpected symbol near ')'
Domoticz sur Win7 - 4 ds18s20 1-Wire avec ESP8266 - 4 modules relais avec ESP8266- conso EDF OWL CM 180 - RFXTrx433 - Rflink - 4 capteurs température 433Mhz Oregon DIY - 3 Rising Sun - 4 Chacon - Yana Server - Imperihome - Cde portail avec ZK1PA -
Neutrino
Messages : 2662
Inscription : 10 juil. 2015, 15:42
Localisation : Les Herbiers(85)

Re: Projet TBH

Message par Neutrino »

Peux-tu donner l'erreur complète et mettre tout ton script entre des balises
Ma maison à plein d'IP ! :mrgreen:
SAV Bonjour. Vous avez vidé le cache ?
Répondre