Skip to content

How to configure the wifi button

This tutorial will show you how to configure the Mystrom wifi button.

Important

This is required if you want to run the TUG demo with the speech interaction.

Using the app

First, you will need to download the app and create an account.

Open the app, click on the symbol in the right corner and click on Add device / WiFi Button.

Now we will connect the button to your wifi network. Click on Not connected and select Light. Choose the manual configuration. Go on until this screen appers:

Press the button for 1 second and the button will start blinking white.

Go on, this screen will appear:

Keep the button pressed for 2 seconds, the LED will start blinking red and white: now the button will be in Access Point for 5 minutes.

Be patient

This might take few seconds.

Go on and select and connect to my-button-XXXXXX network, where XXXXXX will change depending on the button.

Go back to the app and wait until a list of wifi networks appears.

Choose yours and click on Use fixed IP. Now choose an IP address for your button and insert your subnet mask, gateway and DNS. If required insert the password of your network.

How to set the IP address

The IP address you choose must be in the same subnet of the machine you will interface to. Thus the first three numbers of the IP address you choose should match those of your machine. Follow this guide to know the IP address of your machine.

After few seconds the wifi button is found and connected to your network! Go on and choose a name for it and an icon. Done? Congratulations, now your button configured!!

You can skip the action setting as I will show you how so set actions in next section.

Setting the actions

This is a guide that shows you how to communicate with your device once it has been configured!

To get the device specific information, you can do:

curl --location --request GET '[Button IP]/api/v1/device'

Tip

Replace [Button IP] with the one you chose when configuring the button.

The output will be a json object with the mac address (without delimiters) and its field, as shown here.

Now we want to set the button such that it sends a POST request to our IP if pressed once, which corresponds to the single action.

Additional actions

For the TUG demo, we only use the single action. As explained here, this button also allows you to set double (http request executed when pressing the button twice) and long (http request executed when pressing the button long).

Not familiar with http requests?

Check this out!

For doing so, you can do:

curl -v -d "single=post://[Your IP]/api/mystrom?key%3Dspeech" http://[Button IP]/api/v1/device/[Button MAC]

where:

  • you need to replace [Your IP] with the IP address of the machine where you want to receive the POST request;
  • you need to replace [Button IP] with the IP address of your button;
  • you need to replace [Button MAC] with the MAC address of your button;
  • the string speech after key%3D is the value of the keyword sent with the POST request.

Button MAC

You can find the MAC address of your button in the app: click on the button, go on Settings / Technical specifications. Note that in the curl command, you need to insert the MAC address with no semicolons.

Connection refused

If you get the following error: Failed to connect to [Button IP] port 80: No route to host, it means that the device is into sleep mode. This is done in order to preserve battery life (the device is visible in the network only after adding to wifi).

Luckily, you can enter into maintenance mode, by keeping the button pressed for 5 seconds (it starts blinking green). Now you should be able to communicate again with the device!

In this way, we set the single action, which corresponds to the http request executed when pressing the button once.

Important

If you want to use the wifi button to run the TUG demo, configure the single action to send a POST request to the machine where you run node-button.js.

Tip

To set double or long action, you can follow the same procedure and replace in the curl command single with the action you want to configure.

Now if you get the device specific information, using the command:

curl --location --request GET '[Button IP]/api/v1/device'

you will see a json output:

{
    "[Button MAC]":
    {"type": "button", "battery": true, "reachable": true, "meshroot": false,
      "charge": false, "voltage": 4.179, "fw_version": "2.74.31",
      "single": "post:\/\/[Your IP]]\/api\/mystrom?key=speech",
      "double": "", "long": "", "touch": "", "generic": "",
      "connectionStatus": {"ntp": true, "dns": true, "connection": true,
                          "handshake": true, "login": true}, "name": ""}
}

where the single action is configured as "post:\/\/[Your IP]]\/api\/mystrom?key=speech".