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

MyStrom

IoT – ideology of technology | new MyStrom Smart Devices

Those who know me in person are aware that my life is not only controlled by Citrix technology, I’m also fascinated by Smart Home stuff and Internet of Things, IoT. Since years I use Philips Hue, Netatmo and other gadgets to make my life easier – or to solve problems which I won’t have without this Smart Home devices… Some of my neighbours believe that I have a girlfriend called “Alexa” and I’m very rude to her.

Anyway, I already wrote about the MyStrom Smart plugs in the article Control MyStrom smart plug by a trigger or Another LaMetric IoT script – power control .

The special thing about the MyStrom WiFi Switch is that they are only for Switzerland, we have here not the same wall sockets like they are common in Europe. For this reason in my point of view MyStrom is a niche product, even when it’s a very very good product.

Today I received a package from MyStrom with two very cool new products inside, the MyStrom Bulb and the MyStrom WiFi button. I have already similar products, for the Smart Bulb from Philips Hue and SengLed Boost. For the button I have currently an Amazon IoT button, which I have connected to IFTTT that I can trigger some things.

In this post I want to compare this new MyStrom devices to other existing devices on the market.

Comparison Smart Bulb:

myStrom WiFi Bulb

  • 39.- CHF (Color)
  • Color
  • E27

+ Has a HTTP Rest API
+ Show power consumption
+ great colors!
–  only 600 lm
– Bulb becomes pretty hot, 52,9°C after 30min test.

Philips Hue

  • 69.- CHF (Color)
  • 20.- CHF (White)
  • E27 and GU10 available (Update: Now also E14)

+ Use the ZigBee protocol
+ Up to 806 lm
– An additional device, called “Bridge” is required
– Colors not so saturated
– Range is limited, I was not able to have a Hue Bulb in my garage, why I added a SengLed Boost.
– Bulb becomes pretty hot, 62,5°C after 30min test.

SengLed Boost

  • 59.- CHF
  • E27

+ Works as an Wireless Wifi Repeater
–  only 470 lm

IKEA TRÅDFRI
LED-Bulb E27 1000 lm White

  • 14.95 CHF (White)
  • Color also available  but not with 1000lm
  • Uses 12,4 Watt
  • Is compatible with Hue-Bridge after latest firmware and perhaps 3rd party Software

+ brightest and cheapest Bulb
– Bulb becomes pretty hot, on some parts 84,9°C after 30min test!

 

Conclusion: It really depends on your needs which Smart Bulb is the best for you, if you have already a Philips Hue ecosystems it makes no sense to Switch to MyStrom. But if you start on green field, you really have to consider to go for MyStrom. With MyStrom you have Bulbs, Plugs and Buttons from one brand. The MyStrom Bulbs are cheaper than Hue and for me very important every MyStrom device has his Webserver which allows you to toggle the power state. If you want o extend you Wifi Range, have a look to SengLED Boost Bulb, but wit this it’s not easy to toggle the light with something other than the existing app.

Comparison Smart Button:

MyStorm WiFi Button

  • 25.- CHF

+ Availible in Switzerland – for everyone (soon …)
+ Battery rechargeable
+ Native IFTTT compatible
+ 3 Push Patterns
+ Fast reaction time (< 2sec to toggle a Switch)

Amazon IoT Button

  • 19.90$

– Only for Amazon Prime customers
– Battery not replaceable
– Reaction time pretty long
+ IFTTT with an “special setup” possible
+ 3 Push patterns

Hue Tap

  • 69.-
    NOT TESTET!

– need the Brigde
+ No need for battery
+ 3 buttons

Hue Dimmer Switch

  • 29.-
    NOT TESTET!

– need the Brigde (?)

Conclusion: For most “Home-automater” the MyStrom Wifi button will be the best choice, the way to configure an AWS IoT button is an “advanced expierience”. I don’t like that the Amazon IoT Button has a non replaceable/rechargeable battery inside. If you have already a large huge Philips Hue ecosystem maybe the Hue Tap / Dimmer Switch is the best for you.

Control MyStrom smart plug by a trigger (ifttt or octoblu)

mystromSome weeks ago I bought my first smart plug from MyStrom. If you are living  in Switzerland you have only a limited choice of smart plugs because of the non EU standard plug (T13).

MyStrom is pretty cool because it mets almost all my requirement, there is a possibility to measure to power consumption within two rates (day and night), it’s controllable with the mobile phone app and there is a nice web interface.

But one thing I miss, I cannot react to triggers and power of the smart plug on a defined event. Like already in an earlier post mentioned there is a REST API which allows to control the plug from the internal network. (See Another LaMetric IoT script – power control)

Last day’s I just found the API documentation which allows to control the MyStrom out of the cloud:
https://mystrom.ch/mobile/ 

So I have now all to connect this Thing to the Internet and react on a trigger.

Possibility 1: The everything imaginable way,
MyStrom and Octoblu

mystromlogo      +      ocoblu

If you are using Octoblu beta, which is currently available for everyone for free you can create very intelligent workflows to control your smart plug. You can react to twitter and power of or on depending what is twittered, you can power off your heater as soon a temperature is reached, you can stop charge as soon your device have a defined state of charge.

The Things you connect use with Octoblu are nearly infinite.

mystrom-octoblu

Octoblu is for advanced use, and to be honest I’m also on the learning phase! I do not describe here more details for this case. There are a lot of sample blueprints on https://www.octoblu.com .  Octoblu was acquired by Citrix in 2015.

Possibility 2: The easy way,
MyStrom and IFTTT

 mystromlogo      +      iftttlogo

This way is suitable for “Home use” and for people who only want to create a simple workflow where a trigger initiate for example a Power On or Power Of of the smart plug.

All what you need is a Control-Script on a Webserver with PHP on the Internet, and a IFTTT account.

How it works: The script is very simple, it just handle the  authentication process on the API, read the AuthToken out of the JSON answer and Push out the payload with the AuthToken. IFTTT just take the trigger and call the script with the username, passwort and the payload which you can build from the API

Example: I want to control my smart plug by twitter, if I twitter #lightsoff

Step 1:

Take this script and put it on your webserver:

<!--?php 



/*
V0.1 by Sacha Thomet, www.appcloud.ch, 12-2015



This script can be used to control the MyStrom power outlet with IFTTT.
In IFTTT you need to take the MAKER component to make a web request.



The script must be called with 3 parameters:
- Your MyStrom username (email)
- Your MyStrom password
- the decided payload
 e.g. ../device/switch?on=true%id=64002D012305 to turn on your device with Mac 64002D012305



 Documentation of all API calls: https://mystrom.ch/mobile/
 Attention! You need to replace in your payload all "&" with a "%" !!



 Example:
 [email protected]&password=mysecreatword&payload=https://mystrom.ch/mobile/device/switch?on=true%id=64002D012305



*/



//create variables from parameter
$email = ($_GET["email"]);
$password = ($_GET["password"]);
$payload = ($_GET["payload"]);



//myStrom host with the parameters to gather the AuthToken
$host = "https://mystrom.ch/mobile/auth?email=$email&password=$password";
$filestring = file_get_contents($host); 



//format the AuthToken that only the token remain from the JSON Answer
$startpos = 0;
while($pos = strpos($filestring, "authToken", $startpos))
{
 $string = substr($filestring, $pos, strpos($filestring, "name", $pos + 1) - $pos); 



 //echo $string. " ";
 $newstring = str_replace("authToken","","$string");
 $newstring2 = str_replace('"',"",$newstring);
 $newstring3 = str_replace(":","","$newstring2");
 $authCode = str_replace(",","","$newstring3");



 echo " AuthCode is $authCode 
" ;



 $startpos = $pos + 1;
} 



// Because & cannot submitted in a $_GET we subsitute it with a %
$correctpayload = str_replace("%","&","$payload");



echo "Full payload is: $correctpayload&authToken=$authCode";



$fullpayload = "$correctpayload&authToken=$authCode";
$payloadString = file_get_contents($fullpayload); 



?-->

Step 2:

Create a recipe on IFTTT, use Twitter as Trigger and Maker as Action. In maker you create your request:

[yourwebserver]myStromAuthenticator.php?email=[youraccountemail]&password[yourpassword]&payload=[yourpayload]

e.g. the payload to turn of the device with Mac 64002D012325 is: https://mystrom.ch/mobile/device/switch?on=false%id=64002D012325

The result should be that:

mystrom-ifttt-572x1024

You create 2 of those recipies, one to Power On and one to Power Off

Now you can twitter you defined hashtags to control your smart plug.

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.)