[ create a new paste ] login | about

Link: http://codepad.org/GHqOhkFP    [ raw code | fork ]

PHP, pasted on Feb 28:
<?php
$text = @file_get_contents("http://192.168.0.19:9090/json.htm?type=devices&rid=2");
if ($text === false) exit;
$json = json_decode($text, true);
//var_dump($json);
//echo "\n";
$emont = $json['result']['0']['Temp'];
$emonh = $json['result']['0']['Humidity'];


$emon_lastupdate = $json['result']['0']['LastUpdate']; $emon_lastupdate =
strtotime($emon_lastupdate); $maintenant = time();
if (round(abs($maintenant-$emon_lastupdate)/60) < 5) {

//var_dump($emon);
//echo "\n";
echo $emont . " / " . $emonh;
echo "\n";


$url = "http://emoncms.org/input/post.json?json={Idx2t:" . $emont . "}&apikey=0c5fd990986e3f08ca3d32c9c351aa30";
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_URL, $url); $response = curl_exec($ch);
curl_close ($ch);
$url = "http://emoncms.org/input/post.json?json={Idx2h:" . $emonh . "}&apikey=0c5fd990986e3f08ca3d32c9c351aa30";
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_URL, $url); $response = curl_exec($ch);
curl_close ($ch);


}


$text = file_get_contents("http://192.168.0.19:9090/json.htm?type=devices&rid=3");
$json = json_decode($text, true);
//var_dump($json);
echo "\n";
$emont = $json['result']['0']['Temp'];
$emonh = $json['result']['0']['Humidity'];


$emon_lastupdate = $json['result']['0']['LastUpdate']; $emon_lastupdate =
strtotime($emon_lastupdate); $maintenant = time();
if (round(abs($maintenant-$emon_lastupdate)/60) < 5) {


//var_dump($emon);
//echo "\n";
echo $emont . " / " . $emonh;
echo "\n";

$url = "http://emoncms.org/input/post.json?json={Idx3t:" . $emont . "}&apikey=0c5fd990986e3f08ca3d32c9c351aa30";
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_URL, $url); $response = curl_exec($ch);
curl_close ($ch);
$url = "http://emoncms.org/input/post.json?json={Idx3h:" . $emonh . "}&apikey=0c5fd990986e3f08ca3d32c9c351aa30";
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_URL, $url); $response = curl_exec($ch);
curl_close ($ch);

}




$text = file_get_contents("http://192.168.0.19:9090/json.htm?type=devices&rid=4");
$json = json_decode($text, true);
//var_dump($json);
echo "\n";
$emon = $json['result']['0']['Temp'];


$emon_lastupdate = $json['result']['0']['LastUpdate']; $emon_lastupdate =
strtotime($emon_lastupdate); $maintenant = time();
if (round(abs($maintenant-$emon_lastupdate)/60) < 5) {

//var_dump($emon);
//echo "\n";
echo $emon;
echo "\n";


$url = "http://emoncms.org/input/post.json?json={Idx4:" . $emon . "}&apikey=0c5fd990986e3f08ca3d32c9c351aa30";
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_URL, $url); $response = curl_exec($ch);
curl_close ($ch);


}


$text = file_get_contents("http://192.168.0.19:9090/json.htm?type=devices&rid=6");
$json = json_decode($text, true);
//var_dump($json);
echo "\n";
$emon = $json['result']['0']['Temp'];
//var_dump($emon);
//echo "\n";

$emon_lastupdate = $json['result']['0']['LastUpdate']; $emon_lastupdate =
strtotime($emon_lastupdate); $maintenant = time();
if (round(abs($maintenant-$emon_lastupdate)/60) < 5) {


echo $emon;
echo "\n";

$url = "http://emoncms.org/input/post.json?json={Idx6:" . $emon . "}&apikey=0c5fd990986e3f08ca3d32c9c351aa30";
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_URL, $url); $response = curl_exec($ch);
curl_close ($ch);


}

for ($i = 51; $i < 58; $i++) {
        $string = "http://192.168.0.19:9090/json.htm?type=devices&rid=" . $i;
        $text = file_get_contents($string);
        $json = json_decode($text, true);
        //var_dump($json);
        echo "\n";
        $emon = $json['result']['0']['Temp'];


        $emon_lastupdate = $json['result']['0']['LastUpdate']; $emon_lastupdate =
        strtotime($emon_lastupdate); $maintenant = time();
        if (round(abs($maintenant-$emon_lastupdate)/60) < 5) {


        //var_dump($emon);
        //echo "\n";
        echo $emon;
        echo "\n";


        $url = "http://emoncms.org/input/post.json?json={Idx" . $i . ":" . $emon . "}&apikey=0c5fd990986e3f08ca3d32c9c351aa30";
        $ch = curl_init($url);
        curl_setopt($ch,CURLOPT_URL, $url); $response = curl_exec($ch);
        curl_close ($ch);

        }
}


$text = file_get_contents("http://192.168.0.19:9090/json.htm?type=devices&rid=60");
$json = json_decode($text, true);
//var_dump($json);
echo "\n";
$emont = $json['result']['0']['Temp'];
$emonh = $json['result']['0']['Humidity'];


$emon_lastupdate = $json['result']['0']['LastUpdate']; $emon_lastupdate =
strtotime($emon_lastupdate); $maintenant = time();
if (round(abs($maintenant-$emon_lastupdate)/60) < 5) {


//var_dump($emon);
//echo "\n";
echo $emont . " / " . $emonh;
echo "\n";

$url = "http://emoncms.org/input/post.json?json={CuveHaut:" . $emont . "}&apikey=0c5fd990986e3f08ca3d32c9c351aa30";
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_URL, $url); $response = curl_exec($ch);
curl_close ($ch);
$url = "http://emoncms.org/input/post.json?json={CuveVolt:" . $emonh . "}&apikey=0c5fd990986e3f08ca3d32c9c351aa30";
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_URL, $url); $response = curl_exec($ch);
curl_close ($ch);

}


        $string = "http://192.168.0.19:9090/json.htm?type=devices&rid=81";
        $text = file_get_contents($string);
        $json = json_decode($text, true);
        //var_dump($json);
        echo "\n";
        $emon = $json['result']['0']['Temp'];


        $emon_lastupdate = $json['result']['0']['LastUpdate']; $emon_lastupdate =
        strtotime($emon_lastupdate); $maintenant = time();
        if (round(abs($maintenant-$emon_lastupdate)/60) < 5) {


        //var_dump($emon);
        //echo "\n";
        echo $emon;
        echo "\n";


        $url = "http://emoncms.org/input/post.json?json={MoyenneCapteur:" . $emon . "}&apikey=0c5fd990986e3f08ca3d32c9c351aa30";
        $ch = curl_init($url);
        curl_setopt($ch,CURLOPT_URL, $url); $response = curl_exec($ch);
        curl_close ($ch);
        }

        $string = "http://192.168.0.19:9090/json.htm?type=devices&rid=91";
        $text = file_get_contents($string);
        $json = json_decode($text, true);
        //var_dump($json);
        echo "\n";
        $emon = rtrim($json['result']['0']['Data'], "%");


        $emon_lastupdate = $json['result']['0']['LastUpdate'];
        $emon_lastupdate = strtotime($emon_lastupdate);
        $maintenant = time();
        if (round(abs($maintenant-$emon_lastupdate)/60) < 5) {


        //var_dump($emon);
        //echo "\n";
        echo $emon;
        echo "\n";


        $url = "http://emoncms.org/input/post.json?json={RendementVMC:" . $emon . "}&apikey=0c5fd990986e3f08ca3d32c9c351aa30";
        $ch = curl_init($url);
        curl_setopt($ch,CURLOPT_URL, $url); $response = curl_exec($ch);
        curl_close ($ch);
        }




?>


Create a new paste based on this one


Comments: