Install myStrom

From xPL
Jump to: navigation, search

The myStrom Smart Home system consists out of buttons, motion sensors, bulbs, LED strips and power switches. The system can be controlled via an app, but the different elements can be accessed via a RESTful Web service over Wi-Fi. The REST API describes how to setup and use the devices..

The myStrom devices start operating on a standalone Wi-Fi network. Once connected to a device, one can set it up to join a local Wi-Fi network. This being done, the devices are accessed via the myStrom REST API.

Before all, make sure you have installed an xPL hub and a control user.

Setup a button from scratch

The button is characterized by its MAC address which is found on the back of it. The first 3 bytes are the Organizationally Unique Identifier (OUI) : 5c:cf:7f, and the last 3 bytes are the device's identifier. In the examples to come, this identifier will be 0c:c6:d1, which has to be updated in each case.

To discover the myStrom button, press on it until it starts to blink. Find its Wi-Fi network:

nmcli dev wifi

You should discover a network with Service Set IDentifier (SSID) my-button-0CC6D1.

Change your Wi-Fi network to that one and check your IP address:

ifconfig | grep ^w
ifconfig wlp1s0

Your IP address should be

Get info from the button:

curl -i -X GET

Specify the network the button has to join:

curl -i -X POST -d '{"ssid":"network_name", "passwd":"password"}'

The button will join the local network and the network with SSID my-button-0CC6D1 will disappear.

Login back to your local Wi-Fi network and find the button:

sudo arp-scan -l | grep $BUTTON_OUI
sudo arp-scan -l | grep $BUTTON_ID

BUTTON_IP=`sudo arp-scan -l | grep $BUTTON_ID | sed -e 's/\s.*//'` && echo $BUTTON_IP
ping -c 1 $BUTTON_IP
arp -n | grep $BUTTON_ID
curl -X GET http://$BUTTON_IP/api/v1/info && echo
curl -X GET http://$BUTTON_IP/api/v1/device && echo

Setup button actions:

curl --location --request POST "http://$BUTTON_IP/api/v1/action/single" --data-raw "post://$SERVER_IP:$SERVER_PORT/myStrom/button?id=$BUTTON_ID&key=single"
curl --location --request POST "http://$BUTTON_IP/api/v1/action/double" --data-raw "post://$SERVER_IP:$SERVER_PORT/myStrom/button?id=$BUTTON_ID&key=double"
curl --location --request POST "http://$BUTTON_IP/api/v1/action/long" --data-raw "post://$SERVER_IP:$SERVER_PORT/myStrom/button?id=$BUTTON_ID&key=long"
curl --location --request POST "http://$BUTTON_IP/api/v1/action/touch" --data-raw "post://$SERVER_IP:$SERVER_PORT/myStrom/button?id=$BUTTON_ID&key=touch"

REST server

The button can send GET, POST and other requests to a REST web server. Different option exist for implementing it, The proposed solution here is to use HTTP::Server::Simple.

sudo apt install libhttp-server-simple-perl