Dies ist eine alte Version des Dokuments!
Inhaltsverzeichnis
You less device
Postfossil BV from the Netherlands:
offers a meter reading device at:
In germany the device is available via:
and can be ordered via Amazon at
although the device is offered much cheaper via the vendor in the netherlands. The device has a lan interface and can be used with analog ferraris meters as well as digital S0 input.
manual
an english manual can be found at:
You less software
Connection to volkszaehler
I (Wolfgang - wf (at) bitplan.com) am currently trying it out and intending to connect it to the volkszaehler solution. I'll post any news here.
data format
has information on how to access the device
php code for posting to middleware
The following code is a first attempt to read data from the youless logger and post it to the volkszaehler middlware. You might want to modify:
- $url - the url to read the youless from
- $vzurl - the url your middleware runs at
- $cuuid - the channel id to post to
- $delay - how long to wait between posts default: 5 secs / 12 readings per minute
currently only the power reading is posted. Just add another call to also post the meter reading (to a different channel).
To use code copy it to a file „yl.php“ and then start with
php -f yl.php
the output should look like:
2014-05-28 21:05:07 1,518 kWh 1304 Watt 2014-05-28 21:05:12 1,520 kWh 1338 Watt 2014-05-28 21:05:17 1,522 kWh 1318 Watt
For any feedback please contact me at wf (at) bitplan.com. Enjoy …
<?php /** * $Header: /Users/wf/youless/RCS/yl.php,v 1.4 2014/05/28 18:58:31 wf Exp wf $ */ /** * get a curl channel */ function curl($url) { // Initiate curl $ch = curl_init(); // Disable SSL verification curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Will return the response, if false it print the response curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Set the url curl_setopt($ch, CURLOPT_URL,$url); return $ch; } /** * read the given url * @param $url:the url to read from */ function readUrl($url) { $ch=curl($url); // Execute $result=curl_exec($ch); return $result; } /** * post to the given url */ function postUrl($url,$fields) { $ch=curl($url); $fields_string=""; //url-ify the data for the POST foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string, '&'); curl_setopt($ch,CURLOPT_POST, count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); $result=curl_exec($ch); return $result; } /** * read the meter */ function readyouless($url) { $json=readUrl($url); // get the meter reading $meter=json_decode($json, true); // Will dump a beauty json :3 // comment out next line if you'd like to debug the json message // var_dump($meter); return $meter; } /** * transfer youless reading to vz middleware */ function youless2vz($url,$vzurl,$cuuid) { $meter=readyouless($url); $pwr=$meter["pwr"]; $cnt=$meter["cnt"]; $lvn=$meter["lvl"]; $now=date("Y-m-d H:m:s"); echo "$now $cnt kWh $pwr Watt\n"; // http://wiki.volkszaehler.org/development/api/reference $posturl=$vzurl."/".$cuuid.".json"; $fields=array("ts"=>time(),"value" => $pwr ); $presult=postUrl($posturl,$fields); // uncomment to debug // echo $presult; } // the url to read from $url="http://2.0.0.94/a?f=j"; $vzurl="http://capri/vz/middleware.php/data"; // channel uuid $cuuid="0cca0870-e695-11e3-8c38-6dc719f70ac1"; // how often to post to middlewhere $delay=5; // delay in seconds between posts while (true) { youless2vz($url,$vzurl,$cuuid); sleep($delay); } ?>