===== Youless device ===== Postfossil BV from the Netherlands: http://www.postfossil.nl/ offers a meter reading device at: http://www.youless.net/home.html In germany the device is available via: http://www.bg-etech.de/ English manual can be found at: http://www.bg-etech.de/images/YouLess/Youless-manual-1.3C_EN.pdf The device has a lan interface and can be used with analog ferraris meters as well as digital S0 input. This is a screen shot of the web interface offered: {{:playground:youlessscreenshot.png?300|}} ===== Connection to volkszaehler ===== === Data format === Information on how to access the device: http://wiki.td-er.nl/index.php?title=YouLess === Example === In my environment the youless device has the ip address 192.168.0.12 Using the url http://192.168.0.12/a?f=j the json response is: {"cnt":"22018,290","pwr":3789,"lvl":0,"dev":"","det":"","con":"*","sts":"","raw":1} The json encoded information has the current meter count / kWh in "cnt" and the current power level in Watts in "pwr". This information needs to be converted to volkszaehler format and posted to the middleware - this is what the code below does. === 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 middleware. As of version (2017/06 June) it's working in my environment. There are three files used: * php file: vzapihelper.php * php file: yl.php * sh file: yl.sh (the only file you have to enter individual code. UUIDs of your VZ-Channels an the IP adress of your youless device) === creating the 3 used files === to edit or create a file type the following in your console of your volkszaehler raspberry or what else: sudo nano /etc/yl.php the file "yl.php" in the folder "etc" doesn't exist before, so you now have created. Insert the following code and press "STRG" +"X" to save an exit the file: now do the same for the second file, the vzapihelper.php. Type the following in your console: sudo nano /etc/vzapihelper.php Insert the following code and press "STRG" +"X" to save an exit the file: $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; } } /** * check that option $opt is available in $options * return the value if available */ function checkoption($opt,$options) { if (array_key_exists($opt,$options)) return $options[$opt]; else die("option $opt missing!\n"); } ?> The last file ist the yl.sh. The script automatically will be started from the crontab (Taskmgr) of your linux system, so that the youless device is also working after a reboot. Type the following in your console: sudo nano /etc/yl.sh Insert the following code and press "STRG" +"X" to save an exit the file: #!/bin/bash while true do php /etc/yl.php \ --url="http://IP ADRESS OF YOUR YOULESS DEVICE/a?f=j" \ --vzurl="http://localhost/middleware.php/data" \ --cuuid_pwr="ENTER HERE THE UUID OF THE CHANNEL FORM YOUR VOLKSZAEHLER YOU WANT TO POST THE CURRENT POWER TO" \ --cuuid_cnt="ENTER HERE THE UUID OF THE CHANNEL FORM YOUR VOLKSZAEHLER YOU WANT TO POST THE METER READING (Zählerstand) TO" \ --delay=15 \ --cnt_modulo=12 \ --loop done exit 0 Here is a statement of the parameter * $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 make the sh-file executable for crontab (Taskmgr) you have to give the rights. Type the following into your console: sudo chmod +x /etc/yl.sh To edit the crontab type sudo nano /etc/rc.local and add the following line on the bottom of the file, before the line "exit 0": bash /etc/yl.sh& So that's it. now it should work. You also can test your configuration if you enter the following code in your console: php /etc/yl.php \ --url="http://IP ADRESS OF YOUR YOULESS DEVICE/a?f=j" \ --vzurl="http://localhost/middleware.php/data" \ --cuuid_pwr="ENTER HERE THE UUID OF THE CHANNEL FORM YOUR VOLKSZAEHLER YOU WANT TO POST THE CURRENT POWER TO" \ --cuuid_cnt="ENTER HERE THE UUID OF THE CHANNEL FORM YOUR VOLKSZAEHLER YOU WANT TO POST THE METER READING (Zählerstand) TO" \ --delay=15 \ --cnt_modulo=12 \ --loop done exit 0 the output should look like: 2017-04-29 10:59:00 YL: 640 Watt 50.595 kwH 2017-04-29 10:59:05 YL: 639 Watt 50.596 kwH 2017-04-29 10:59:10 YL: 639 Watt 50.597 kwH For any feedback please contact wf (at) bitplan.com or tiedi (at) web.de. Enjoy ... [[https://wiki.volkszaehler.org/howto/raspberry_pi_image?s[]=raspberry|how to flash a complete volkszahler image on your raspberry]]