Application virtualization, IoT and Cloud Computing, Blog of Sacha Thomet

Guide

Another LaMetric IoT script – power control

Because I have currently holiday here is another post which is not related to virtualization …

I combined my new “gadgets” the LaMetric time and my new wifi Smart-Plug from MyStrom. The goal was to report the current power consumption of power plug and the possibility to control the plug with the smart ticker.

MyStrom has a very straight forward API (https://mystrom.ch/en/mystrom-api), and the possibility to create apps for LaMetric is pretty easy what I’ve already mentioned in an past blog post.

All what is needed to implement this solution is:

  • a web server which can parse PHP
  • two small scripts
  • and a private app for LaMetric

This is the script to see the current power consumption:

{
    "frames": [
        {
            "index": 0,
            "text": " <!--?php //$host = "http://192.168.1.59/report"; //Call with parameter, e.g.: http://192.168.1.20/LaMetric/myStrom.php?host=192.168.1.59 $host = "http://" . $_GET["host"] . "/report"; $filestring = file_get_contents($host); $startpos = 0; while($pos = strpos($filestring, "\"power\"", $startpos)) { $string = substr($filestring, $pos, strpos($filestring, ",", $pos + 1) - $pos); //echo $string. " "; $newstring = str_replace("\"power\": ","","$string"); echo round($newstring, 2); $startpos = $pos + 1; } ?--> Watt",
            "icon": "i1692"
        }
    ]
}

I just read the content from the API, which is already in JSON format, but I reformat it that it is in that way which I need to bring it to the LaMetric.
This is the script to control the power outlet:

<!--?php $host = "http://" . $_GET["host"] . "/report"; $filestring = file_get_contents($host); $startpos = 0; while($pos = strpos($filestring, "relay", $startpos)) { $string = substr($filestring, $pos, strpos($filestring, "}", $pos + 1) - $pos); $newstring = str_replace("relay\": ","","$string"); //echo $newstring; $startpos = $pos + 1; } $newstring = str_replace(chr(13), "", $newstring); if ($newstring == "false ") { echo "Ist ausgeschaltet, wird nun eingeschaltet"; $URL = "http://" . $_GET["host"] . "/relay?state=1"; $data = file_get_contents($URL); } else { echo "Ist eingeschaltet, wird nun ausgeschaltet"; $URL = "http://" . $_GET["host"] . "/relay?state=0"; $data = file_get_contents($URL); } ?-->

And the LaMetric private app:

This simple poll app call the script on the webserver (192.168.1.20) with the parameter of the MyStrom plug (192.168.1.59).

On button action the controller script is launched with change the status (off to on or visa verse)

myStromApp-mini

(192.168.1.59 is the ip of my Power outlet. 192.168.1.20 is the address of my web server, this can be a raspberry pi or a Synology.)

Citrix Synergy First-Timer Preperation

This year I have the chance to join the Citrix Synergy in Orlando, FL, USA, THE Citrix conference.
For more Information: http://www.citrixsynergy.com

There is already a very good guide for the preparation of this conference from Neil Spellings, see the The ultimate Citrix Synergy survival guide – 2015 , that covers a lot of needed information.

But I add in this post some information for a first timer comes from overseas (Switzerland, Europe) like me.

Revision history
because this is a “living Blog-Post”:

  • 26.04.2015: Added “Join evening together Central & Eastern Europe Team”

Avoid the Jetlag when coming from overseas
My personal best method to avoid the Jetlag (Switzerland, Europe to Florida, US -6 hours):

  • I will arrive early, even Synergy starts on the 13th, I take already the plane on the 9th of May. That gives me some days to get in the correct day/night rhythm.
  • I stay waked up after arrival until my normal sleeping time, even if I’m very tired!
  • If I wake up in the middle of the first night because it’s morning in Europe (and in my day/night rhythm), I’ll take a soft Sleep Aid called MidNite, available in a lot of US Stores (e.g. CVS).
  • I get up after sunrise an go outside to the Sun to let my inner day/night rhythm know thats now day.

Stay online without expensive mobile roaming costs!
Instead of the Net10 card what is mentioned in the blog of Neil spellings I will buy a AT&T GoPhone Prepaid Card with e.g. 2GB for 25$ and I put it in my Huawei E5372. If you intend to use an other device or provider be aware of the used frequencies. This combination gives you a Mobile Hotspot which works in thr US with AT&T and Europe on 2G/3G and 4G mobile network.

Plan your sessions
You can plan the Sessions you want to attend on the Synergy Session Catalog Website . If you are already registered for Synergy you can login with your Synergy account subscribe to the sessions you like to attend (first come first served, no possibility to reserve the seats with exception of the 99$ Pre-event Training Workshop).  and  afterwards you can download a PDF with all your sessions or you can download the  Calendar-Files.

Plan Meetings!

  • After login to your Synergy Account you have the possibility for an Attendee Search and request meetings:
    synmeetings2
  • Try to meet people you known today just virtual from twitter or from a blog to get a face behind of a URL or a Username.

If you register for Citrix Synergy and like this post or this blog
Please use my referral code in the registration:

It’s my email address with MyPeer at the end. That gives me the chance to win Converse sneakers .

If you are from Central & Eastern Europe join the snacks, beer and networking event
Check your Mailbox, and the Spam-Folder about an invitation from Dirk Pfefferle, to a “evening together with Citrix Central & Eastern Europe Team”. I just found in my Spam folder an invitation for this snacks, beer and networking event.