Using myStrom WiFi-Buttons with HomeAssistant

Once upon a time when I started to realize that zigbee will have - at least for me - no future, it then took my a veeeeeery long-time to find equivalent WiFi devices: bulbs, sensors and so on. Although ESPhome did solve a lot of these challenges, above all there were no WiFi-buttons: nore ready-made nore diy-ones.

I do definitively NOT want to start again a Zigbee vs. WiFi-discussion about battery-life vs. connection issues as this has been done often here like I did myself here or here in the past.
:wink:

In any case: NOW I found the very cool WiFi-Buttons from myStrom, a IoT-manufacturer who is obviously very keen to open-source and local polling. I was BLOWN AWAY on the spot in the same way I was also SADDENED TO DEATH to see that its HA-integration does not work anymore as only unencrypted API commands are supported on the one hand side from myStrom but encryption is requested from HomeAssistant.

Although I can not solve the original problem making the integration work itself, I am VERY HAPPY I could find a workaround for those of you that stumble across this post and try to integrate these buttons.

:partying_face:

You can find additional information about:

The Following describes changing an API-POST-Command for Button 1 being pushed once (1x) resulting in turning a HA-entity on. You have of course to repeat the below step 6 for each other command.

  1. Flash the buttons with custom firmware from myStrom themself.
  2. Use the “myStrom Button Max Tool” to connect to the flashed button and configure the button.
  3. Upload the resulting json-File to the button again using the above tool.
  4. Download the json file from the button:
    curl -s -o configfile.json http://<BUTTON-IP-ADDRESS>/api/v1/config
  5. Edit this file adding the following header repeatedly for each button command:
    From:
 {
          "http": {
            "method": "POST",
            "payload": " {\"state\": \"on\"}",
            "url": "http://<HA-IP-ADDRESS>/api/states/<HA-ENTITY_ID>"
          },
          "scheme": "1x",
          "trigger": "btn1"
        },

To:

 {
          "http": {
            "headers":[
              "Authorization: Bearer <LOOOOOONGAPITOKEN>"
            ],
            "method": "POST",
            "payload": " {\"state\": \"on\"}",
            "url": "http://<HA-IP-ADDRESS>/api/states/<HA-ENTITY_ID>"
          },
          "scheme": "1x",
          "trigger": "btn1"
        },
  1. Upload the File again:
    curl -i -d @configfile.json http://<BUTTON-IP-ADDRESS>/api/v1/config
  2. This should be the buttons answer:
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 0
Connection: close
Pragma: no-cache
Cache-Control: no-store, no-cache
  1. You’re DONE :slight_smile: You can now remotely control HA-Entitys via myStroms WiFi-Button.
2 Likes

Hi!

Thank you for your guide. How ever I had some issues when following it and I want to share my soulution - if there is anybody else having simular issues.

I had firmware 1.2.1 installed on my button and I could’nt install the custom firmware. After some tinkering I emailed myStrom and they were verry helpful.

Apperently you do not need a custom firmware to use the tool “myStrom Button Max Tool” when using the firmware 1.2.1. But you need to set the button to Tool mode. This is done with the following:

curl -i -d '{"mode":"tool"}' http://<your-button-ip>/api/v1/settings

Example:

curl -i -d '{"mode":"tool"}' http://192.168.1.139/api/v1/settings

So I replaced your step 1. with the above command and then the button appeared in “myStrom Button Max Tool” and I could follow the rest of your guide.

Hello,

I’m digging out this topic. I bought a pair of these wonderful buttons, and honestly I’m really pleased with them.

I managed with your explainaitions to set up a system that allows:

  • Actions to be triggered in Home Assistant from the button, via H.A REST API .

  • If the button is plugged into power (or unplugged for less than 10 minutes), H.A reflash the button config when a command is sent, allowing it to update the status of the element just manipulated. For example, turning the icon of a lamp on or off after it has been switched on.

The result is really cool. It allows you to control almost everything at home with a small button: arming the alarm, turning off radiators, managing shutters, etc. If anyone is interested, I’d be happy to share my code.

I would be really interessted @niowid in your setup/code.
I currently have 13 mystrom devices and other and if I could control my with these nice new button, that would be a great setup with HA.

So what is necessary to use the Mystrom Max Button to control actions via HA? No custom firmware and not mystorm home? Thanks