Integrating Mystrom Buttons

This tutorial is about making Mystrom Button work with Openhab. I have a button on my night table to switch on/off the lights and open/close my rollershutters without going out of my bed.

I use the Wifi button from: https://mystrom.ch/de/wifi-button/

With firmware 2.74.31 they added support for content type plain/text and json which enabled the button to talk directly to REST API of Openhab items. Before they used application/x-www-form-urlencoded which was not working.

So first upgrade your button. You see version 2.74 only in the Mystrom app on your mobile. When you use curl to connect to your button you see the full version:

$ curl -v http://192.168.1.10/api/v1/info
* Trying 192.168.1.10...
* TCP_NODELAY set
* Connected to 192.168.1.10 (192.168.1.10) port 80 (#0)
GET /api/v1/info HTTP/1.1
Host: 192.168.1.10
User-Agent: curl/7.54.0
Accept: */*
 HTTP/1.1 200 OK
 Pragma: no-cache
 Cache-Control: no-store, no-cache
 Access-Control-Allow-Origin: *
 Content-Type: application/json
 Content-Length: 245
 Connection: close

{
	"version": "**2.74.31**",
	"mac": "60019XXXXX",
	"type": 104,
	"ssid": "whatever",
	"ip": "192.168.1.10",
	"mask": "255.255.255.0",
	"gw": "192.168.1.1",
	"dns": "192.168.1.1",
	"static": true,
	"connected": true,
	"signal": 54
* Closing connection 0

I used some virtual items in Openhab, which I reset after a second with the expire binding:
Items:
Group:Switch:AND(OFF,ON) Mystrom_Button

Switch Mystrom_Button_Short (Mystrom_Button) { expire="1s,command=OFF" }
Switch Mystrom_Button_Long (Mystrom_Button) { expire="1s,command=OFF" }
Switch Mystrom_Button_Double (Mystrom_Button) { expire="1s,command=OFF" }

Then I use the following rule to switch my lights (two in this case).
Single click = Toggle Light1
Long click = Toogle Light2
Double click = Switch off Light1 & Light2
Rules:

rule “Licht Zimmer1”
when
Member of Mystrom_Button changed to ON
then
switch (triggeringItem.name) {
case “Mystrom_Button_Short”: {
switch (Light1.state.toString) {
case “ON”: { Light1.sendCommand(OFF)
}
case “OFF”: { Light1.sendCommand(ON)
}
}
}
case “Mystrom_Button_Long”: {
switch (Light2.state.toString) {
case “ON”: { Light2.sendCommand(OFF)
}
case “OFF”: { Light2.sendCommand(ON)
}
}
}
case “Mystrom_Button_Double”: {
Light1.sendCommand(OFF)
Light2.sendCommand(OFF)
}
}
end

When you configure the button preferably with a fix IP, the button need to be in config mode in order you can send commands by curl. To get into config mode you need to connect the button with power and then hold the button for about 3-5s. After you let it go it should stay in config mode for some minutes.

To configure the button to trigger my virtual items above I used the following commands:

curl -v -d "single=post://OpenhabIP%3A8080%2Frest/items/Mystrom_Button_Short/?ON" http://192.168.1.10/api/v1/device/60019XXXXX
curl -v -d "double=post://OpenhabIP%3A8080%2Frest/items/Mystrom_Button_Double/?ON" http://192.168.1.10/api/v1/device/60019XXXXX
curl -v -d "long=post://OpenhabIP%3A8080%2Frest/items/Mystrom_Button_Long/?ON" http://192.168.1.10/api/v1/device/60019XXXXX

→ OpenhabIP = IP of my Openhab Server
→ 60019XXXXX = Mac Address of my Mystrom Button. Check Mystrom App or curl call above.
→ 192.168.10.1 = IP of my Mystrom Button

Hope this helps to create some nice addition to your installation :slight_smile:

3 Likes

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.