Benutzer-Werkzeuge

Webseiten-Werkzeuge


hardware:controllers:youless

Dies ist eine alte Version des Dokuments!


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

You less software

This is a screen shot of the web interface offered:

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 an attempt to read data from the youless logger and post it to the volkszaehler middlware. As of version 1.8 it's working in my (Wolfgang's) environment.

You might want to modify:

  • $url - the url to read the youless from
  • $vzurl - the url your middleware runs at
  • $cuuid_pwr - the channel id to post the power reading in Watt to
  • $cuuid_cnt - the channel id to post the power reading in Wh to (resolution 1000)
  • $delay - how long to wait between posts default: 5 secs / 12 readings per minute
  • $cnt_modulo - how often to send the kwH reading default: on every 12th reading / once per minute

To use code copy the two script parts to a „vzapihelper.php“ and „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
  /**
   * read meter data from youless device
   * and post it to volkszaehler
   * $Header: /home/wf/youless/RCS/yl.php,v 1.9 2014/05/29 16:15:46 wf Exp $
   */
 
// common code for reading and posting
require __DIR__.'/vzapihelper.php';
 
   /**
    * 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
    *   param 1: url to read from youless
    *   param 2: vzurl - middleware url of volkszaehler
    *   param 3: channel uuid for power reading in Watt
    *   param 4: channel uuid for energy reading in kWh
    *   param 5: shall we post the cnt reading?
    */
   function youless2vz($url,$vzurl,$cuuid_pwr,$cuuid_cnt,$post_cnt) {
     // read data from youless
     $meter=readyouless($url);
     // get values 
     $pwr=$meter["pwr"];
     $cnt=$meter["cnt"];
     // the level is not interesting for digital meters
     // if you have an analog meter you might want to use and show this
     // $lvl=$meter["lvl"];
 
     // convert to php compatible value
     $cnt=str_replace(",",".",$cnt);
     // calculate Wh from kWh
     $cnt1000=$cnt*1000;
 
     // get human readable time stamp 
     $now=date("Y-m-d H:m:s");
 
     // display progress (comment if you use this in cron job)
     echo "$now $cnt kWh $pwr Watt\n";
 
     // post data to middleware according to: 
     // http://wiki.volkszaehler.org/development/api/reference
 
     # first post the power reading in Watt
     post2vz($vzurl,$cuuid_pwr,$pwr);
 
     # then the energy reading in Wh
     if ($post_cnt) {
       post2vz($vzurl,$cuuid_cnt,$cnt1000);
     }
 
   }
 
  // modify the follwing parts to your needs
  // the url to read from
  $url="http://2.0.0.94/a?f=j";
  $vzurl="http://capri/vz/middleware.php/data";
 
  // channel uuids
  // power (watts)
  $cuuid_pwr="0cca0870-e695-11e3-8c38-6dc719f70ac1";
  // energy (kWh)
  $cuuid_cnt="b8192a00-e71e-11e3-be31-e59be3e5a943";
 
  // how often to post to middlewhere
  $delay=5;       // delay in seconds between posts 
  $cnt_modulo=12; // how many delays for posting a kwH reading
 
  $loop=0;
  while (true) {
    $loop++;
    youless2vz($url,$vzurl,$cuuid_pwr,$cuuid_cnt,$loop % $cnt_modulo==0);
    sleep($delay);
  }
 
?>
<?php
  /**
   * vzapi helper functions
   * $Header: /home/wf/youless/RCS/vzapihelper.php,v 1.2 2014/05/29 16:16:44 wf Exp $
   */
 
  /**
   * 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;
   }
 
   /**
    * post data to vz middleware
    *   param 1: vzurl - middleware url of volkszaehler
    *   param 2: channel uuid 
    *   param 3: value to post
    */
   function post2vz($vzurl,$cuuid,$value,$debug=false) {
     // post data to middleware according to: 
     // http://wiki.volkszaehler.org/development/api/reference
 
     // adapt timestamp to volkszaehler conventions
		 $timestamp=time()*1000;
 
     # first 
     $posturl=$vzurl."/".$cuuid.".json";
     $fields=array("ts"=>$timestamp,"value" => $value );
     $presult=postUrl($posturl,$fields);
     if ($debug) {
       echo $presult;
     }
   }
 
?>
hardware/controllers/youless.1401387176.txt.gz · Zuletzt geändert: 2014/05/29 20:12 von wf_bitplan.com