hardware:controllers:youless
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
| hardware:controllers:youless [2017/04/29 09:03] – [Connection to volkszaehler] wf_bitplan.com | hardware:controllers:youless [2018/01/25 16:22] (aktuell) – code jau | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| - | ==== You less device ==== | + | ===== Youless |
| - | Postfossil BV from the Netherlands: | + | Postfossil BV from the Netherlands: |
| - | * http:// | + | |
| - | offers a meter reading device at: | + | offers a meter reading device at: http:// |
| - | * http:// | + | |
| - | In germany the device is available via: | + | In germany the device is available via: http:// |
| - | * http:// | + | |
| - | and can be ordered via Amazon | + | English manual |
| - | * http://www.amazon.de/dp/B00EMBM920 | + | |
| - | 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. | 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: | ||
| - | * http:// | ||
| - | ==== You less software ==== | ||
| This is a screen shot of the web interface offered: | This is a screen shot of the web interface offered: | ||
| - | {{: | + | {{: |
| + | ===== Connection to volkszaehler ===== | ||
| - | ==== Connection to volkszaehler ==== | + | === Data format |
| - | 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. | + | Information on how to access |
| - | === data format === | + | |
| - | * http:// | + | |
| - | has information on how to access the device | + | |
| - | + | ||
| - | === example === | + | |
| - | In my environment the youless device has the ip address 2.0.0.94. | + | |
| - | + | ||
| - | Using the url http:// | + | |
| + | === Example === | ||
| + | In my environment the youless device has the ip address 192.168.0.12 | ||
| + | Using the url http:// | ||
| the json response is: | the json response is: | ||
| < | < | ||
| {" | {" | ||
| </ | </ | ||
| - | + | The json encoded | |
| - | The json encode | + | |
| This information needs to be converted to volkszaehler format and posted to the middleware - this is what the code below does. | 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 | + | === PHP-Code |
| - | The following code is an attempt to read data from the youless logger | + | The following code is an attempt to read data from the youless logger and post it to the volkszaehler |
| - | and post it to the volkszaehler | + | |
| There are three files used: | There are three files used: | ||
| * php file: vzapihelper.php | * php file: vzapihelper.php | ||
| * php file: yl.php | * php file: yl.php | ||
| - | * shell script | + | * sh file: yl.sh (the only file you have to enter individual code. UUIDs of your VZ-Channels an the IP adress |
| - | + | ||
| - | the yl script is to be used for testing or to be called regularly from a crontab entry - it needs to be configured while the yl.php and vzapihelper.php files should work generaly as of the state of Volkszähler software in May 2014. | + | |
| - | + | ||
| - | You might want to set: | + | |
| - | * $url - the url to read the youless | + | |
| - | * $vzurl | + | |
| - | * $cuuid_pwr | + | |
| - | * $cuuid_cnt | + | |
| - | * $delay | + | |
| - | * $cnt_modulo - how often to send the kwH reading default: on every 12th reading / once per minute | + | |
| - | + | === creating the 3 used files === | |
| - | To use the code copy the two script parts to a " | + | to edit or create |
| - | < | + | < |
| - | php yl.php \ | + | the file "yl.php" |
| - | --url=" | + | <code php yl.php> |
| - | --vzurl=" | + | |
| - | --cuuid_pwr=" | + | |
| - | --cuuid_cnt=" | + | |
| - | --delay=5 \ | + | |
| - | --cnt_modulo=12 \ | + | |
| - | --loop | + | |
| - | </ | + | |
| - | + | ||
| - | <code base|example call from cron> | + | |
| - | cd / | + | |
| - | php yl.php | + | |
| - | --url="http:// | + | |
| - | --vzurl="http:// | + | |
| - | --cuuid_pwr="0cca0870-e695-11e3-8c38-xxxx" | + | |
| - | --cuuid_cnt="b8192a00-e71e-11e3-be31-xxxx" | + | |
| - | </ | + | |
| - | + | ||
| - | the output should look like: | + | |
| - | < | + | |
| - | 2014-05-28 21: | + | |
| - | 2014-05-28 21: | + | |
| - | 2014-05-28 21: | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | For any feedback please contact me at wf (at) bitplan.com. Enjoy ... | + | |
| - | + | ||
| - | <code php|yl.php> | + | |
| <?php | <?php | ||
| /** | /** | ||
| * read meter data from youless device | * read meter data from youless device | ||
| * and post it to volkszaehler | * and post it to volkszaehler | ||
| - | * $Header: /home/ | + | * $Header: /etc/yl.php,v 1.14 2014/06/01 10:40:37 wf Exp wf $ |
| */ | */ | ||
| + | |||
| // common code for reading and posting | // common code for reading and posting | ||
| require __DIR__.'/ | require __DIR__.'/ | ||
| - | + | ||
| /** | /** | ||
| * read the meter | * read the meter | ||
| Zeile 106: | Zeile 57: | ||
| | | ||
| $json=readUrl($url); | $json=readUrl($url); | ||
| + | |||
| // get the meter reading | // get the meter reading | ||
| $meter=json_decode($json, | $meter=json_decode($json, | ||
| Zeile 114: | Zeile 65: | ||
| return $meter; | return $meter; | ||
| } | } | ||
| - | + | ||
| /** | /** | ||
| * transfer youless reading to vz middleware | * transfer youless reading to vz middleware | ||
| Zeile 132: | Zeile 83: | ||
| // if you have an analog meter you might want to use and show this | // if you have an analog meter you might want to use and show this | ||
| // $lvl=$meter[" | // $lvl=$meter[" | ||
| + | |||
| // convert to php compatible value | // convert to php compatible value | ||
| | | ||
| // calculate Wh from kWh | // calculate Wh from kWh | ||
| | | ||
| - | | + | |
| // get human readable time stamp | // get human readable time stamp | ||
| | | ||
| + | |||
| // display progress (comment if you use this in cron job) | // display progress (comment if you use this in cron job) | ||
| | | ||
| Zeile 146: | Zeile 97: | ||
| // post data to middleware according to: | // post data to middleware according to: | ||
| // http:// | // http:// | ||
| + | |||
| # first post the power reading in Watt | # first post the power reading in Watt | ||
| | | ||
| + | |||
| # then the energy reading in Wh | # then the energy reading in Wh | ||
| if ($post_cnt) { | if ($post_cnt) { | ||
| | | ||
| } | } | ||
| + | |||
| } | } | ||
| + | |||
| $loop=0; | $loop=0; | ||
| // possible command line options | // possible command line options | ||
| Zeile 172: | Zeile 123: | ||
| // energy (kWh) | // energy (kWh) | ||
| $cuuid_cnt=checkoption(" | $cuuid_cnt=checkoption(" | ||
| - | | + | |
| // loop option - if no set just one shot (e.g. in cron) | // loop option - if no set just one shot (e.g. in cron) | ||
| $doloop=array_key_exists(" | $doloop=array_key_exists(" | ||
| Zeile 186: | Zeile 137: | ||
| $cnt_modulo=1; | $cnt_modulo=1; | ||
| } | } | ||
| + | |||
| // run once or in a loop | // run once or in a loop | ||
| while ($loop< | while ($loop< | ||
| Zeile 195: | Zeile 146: | ||
| $loop++; | $loop++; | ||
| } | } | ||
| - | | + | |
| ?> | ?> | ||
| - | |||
| </ | </ | ||
| - | == vzapihelper | + | |
| - | helper functions to talk to middleware | + | now do the same for the second file, the vzapihelper.php. Type the following in your console: |
| - | <code php|vzapihelper.php> | + | < |
| + | Insert the following code and press " | ||
| + | <code php vzapihelper.php> | ||
| <?php | <?php | ||
| /** | /** | ||
| * vzapi helper functions | * vzapi helper functions | ||
| - | * $Header: /home/ | + | * $Header: /etc/ |
| */ | */ | ||
| + | |||
| /** | /** | ||
| * get a curl channel | * get a curl channel | ||
| Zeile 220: | Zeile 172: | ||
| // Set the url | // Set the url | ||
| curl_setopt($ch, | curl_setopt($ch, | ||
| + | |||
| return $ch; | return $ch; | ||
| } | } | ||
| - | | + | |
| /** | /** | ||
| * read the given url | * read the given url | ||
| Zeile 230: | Zeile 182: | ||
| function readUrl($url) | function readUrl($url) | ||
| $ch=curl($url); | $ch=curl($url); | ||
| - | | + | |
| // Execute | // Execute | ||
| $result=curl_exec($ch); | $result=curl_exec($ch); | ||
| return $result; | return $result; | ||
| } | } | ||
| - | | + | |
| /** | /** | ||
| * post to the given url | * post to the given url | ||
| Zeile 252: | Zeile 204: | ||
| return $result; | return $result; | ||
| } | } | ||
| + | |||
| /** | /** | ||
| * post data to vz middleware | * post data to vz middleware | ||
| Zeile 262: | Zeile 214: | ||
| // post data to middleware according to: | // post data to middleware according to: | ||
| // http:// | // http:// | ||
| + | |||
| // adapt timestamp to volkszaehler conventions | // adapt timestamp to volkszaehler conventions | ||
| $timestamp=time()*1000; | $timestamp=time()*1000; | ||
| + | |||
| # first | # first | ||
| | | ||
| Zeile 274: | Zeile 226: | ||
| } | } | ||
| } | } | ||
| + | |||
| /** | /** | ||
| * check that option $opt is available in $options | * check that option $opt is available in $options | ||
| Zeile 285: | Zeile 237: | ||
| die(" | die(" | ||
| } | } | ||
| + | |||
| ?> | ?> | ||
| + | </ | ||
| + | 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: | ||
| + | < | ||
| + | Insert the following code and press " | ||
| + | <code bash yl.sh> | ||
| + | #!/bin/bash | ||
| + | while true | ||
| + | do | ||
| + | php /etc/yl.php \ | ||
| + | --url=" | ||
| + | --vzurl=" | ||
| + | --cuuid_pwr=" | ||
| + | --cuuid_cnt=" | ||
| + | --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 | ||
| + | * $cuuid_pwr | ||
| + | * $cuuid_cnt | ||
| + | * $delay | ||
| + | * $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 / | ||
| + | </ | ||
| + | and add the following line on the bottom of the file, before the line "exit 0": | ||
| + | < | ||
| + | bash / | ||
| + | </ | ||
| + | |||
| + | 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=" | ||
| + | --vzurl=" | ||
| + | --cuuid_pwr=" | ||
| + | --cuuid_cnt=" | ||
| + | --delay=15 \ | ||
| + | --cnt_modulo=12 \ | ||
| + | --loop | ||
| + | done | ||
| + | exit 0 | ||
| + | </ | ||
| + | |||
| + | the output should look like: | ||
| + | < | ||
| + | 2017-04-29 10:59:00 YL: 640 Watt | ||
| + | 2017-04-29 10:59:05 YL: 639 Watt | ||
| + | 2017-04-29 10:59:10 YL: 639 Watt | ||
| + | </ | ||
| + | |||
| + | |||
| + | For any feedback please contact wf (at) bitplan.com or tiedi (at) web.de. Enjoy ... | ||
| + | |||
| + | |||
| + | [[https:// | ||
| + | |||
| + | |||
| + | |||
hardware/controllers/youless.1493449383.txt.gz · Zuletzt geändert: von wf_bitplan.com