Difference between revisions of "Install myStrom"
(→Setup a button from scratch) |
(→Setup a button from scratch) |
||
(12 intermediate revisions by one user not shown) | |||
Line 16: | Line 16: | ||
The button is characterized by its [https://en.wikipedia.org/wiki/MAC_address MAC address] | The button is characterized by its [https://en.wikipedia.org/wiki/MAC_address MAC address] | ||
which is found on the back of it. | which is found on the back of it. | ||
− | The first 3 bytes are the [https://en.wikipedia.org/wiki/Organizationally_unique_identifier Organizationally Unique Identifier] (OUI) | + | The first 3 bytes are the [https://en.wikipedia.org/wiki/Organizationally_unique_identifier Organizationally Unique Identifier] (OUI) |
+ | which can be <code>5c:cf:7f</code> or <code>bc:ff:4d</code>, | ||
and the last 3 bytes are the device's identifier. | and the last 3 bytes are the device's identifier. | ||
In the examples to come, this identifier will be <code>0c:c6:d1</code>, | In the examples to come, this identifier will be <code>0c:c6:d1</code>, | ||
Line 42: | Line 43: | ||
The button will join the local network and the network with SSID <code>my-button-0CC6D1</code> | The button will join the local network and the network with SSID <code>my-button-0CC6D1</code> | ||
will disappear. | will disappear. | ||
+ | |||
+ | Install ARP tool: | ||
+ | sudo apt install -y arp-scan | ||
Login back to your local Wi-Fi network and find the button: | Login back to your local Wi-Fi network and find the button: | ||
− | arp -a | + | BUTTON_OUI='5c:cf:7f' |
+ | sudo arp-scan -l | grep $BUTTON_OUI | ||
+ | BUTTON_OUI='bc:ff:4d' | ||
+ | sudo arp-scan -l | grep $BUTTON_OUI | ||
+ | |||
+ | BUTTON_ID=0c:c6:d1 | ||
+ | sudo arp-scan -l | grep $BUTTON_ID | ||
+ | |||
+ | BUTTON_IP=`sudo arp-scan -l | grep $BUTTON_OUI:$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: | ||
+ | SERVER_IP=192.168.1.4 | ||
+ | SERVER_PORT=8080 | ||
+ | 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" | ||
+ | |||
+ | Check button actions: | ||
+ | curl --location --request GET "http://$BUTTON_IP/api/v1/action/single" && echo | ||
+ | curl --location --request GET "http://$BUTTON_IP/api/v1/action/double" && echo | ||
+ | curl --location --request GET "http://$BUTTON_IP/api/v1/action/long" && echo | ||
+ | |||
+ | = REST server = | ||
+ | |||
+ | The button can send GET, POST and other requests | ||
+ | to a [https://en.wikipedia.org/wiki/Representational_state_transfer REST] web server. | ||
+ | Different option exist for implementing it, | ||
+ | The proposed solution here is to use [https://metacpan.org/pod/HTTP::Server::Simple HTTP::Server::Simple]. | ||
+ | sudo apt install libhttp-server-simple-perl |
Latest revision as of 11:30, 30 August 2024
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)
which can be 5c:cf:7f
or bc:ff:4d
,
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 192.168.254.2
.
Get info from the button:
curl -i -X GET http://192.168.254.1/api/v1/info
Specify the network the button has to join:
curl -i -X POST -d '{"ssid":"network_name", "passwd":"password"}' http://192.168.254.1/api/v1/connect
The button will join the local network and the network with SSID my-button-0CC6D1
will disappear.
Install ARP tool:
sudo apt install -y arp-scan
Login back to your local Wi-Fi network and find the button:
BUTTON_OUI='5c:cf:7f' sudo arp-scan -l | grep $BUTTON_OUI BUTTON_OUI='bc:ff:4d' sudo arp-scan -l | grep $BUTTON_OUI BUTTON_ID=0c:c6:d1 sudo arp-scan -l | grep $BUTTON_ID BUTTON_IP=`sudo arp-scan -l | grep $BUTTON_OUI:$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:
SERVER_IP=192.168.1.4 SERVER_PORT=8080 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"
Check button actions:
curl --location --request GET "http://$BUTTON_IP/api/v1/action/single" && echo curl --location --request GET "http://$BUTTON_IP/api/v1/action/double" && echo curl --location --request GET "http://$BUTTON_IP/api/v1/action/long" && echo
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