Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Hardware
  3. Looking for detailed description for hacking a sonoff

Looking for detailed description for hacking a sonoff

Scheduled Pinned Locked Moved Hardware
45 Posts 12 Posters 49.3k Views 15 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? A Former User

    Hello @mgaman ,

    Nice modified version. Because I can't flash it for now, can you tell me wether it's possible to use json commands together with MQTT features?
    Let me explain : json requests sent from my home automation software are more reliable than MQTT, as they get acknowledgement via the HTTP response, so the sender immediately knows wether the device got the order or not. This is very important to me, as it may be necessary to send orders more than once if the sonoff device is far away from the wifi router. Maybe I'm not clear, your opinion will be appreciated.

    dbemowskD Offline
    dbemowskD Offline
    dbemowsk
    wrote on last edited by
    #36

    @Foune What automation software are you using? I have a Vera Plus controller and use a firmware called ESP Easy with my sonoffs. The Vera plugin that I use sends an HTTP request something like this:

    http://192.168.1.36/control?cmd=GPIO,12,1
    

    That is to tell the sonoff to use GPIO pin 12 which is my relay, and send it a 1 or ON command. The sonoff sends an immediate JSON response like this:

    {
    "log": "GPIO 12 Set to 1",
    "plugin": 1,
    "pin": 12,
    "mode": "output",
    "state": 1
    }
    

    This tells me that GPIO pin 12 was successfully set to a 1 state.

    The Vera plugin will occasionally check the up status of the node by sending a ping and checking the response. On the Vera controller, the device will either show Online or Offline.

    Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
    Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #37

      Thanks for your detailed answer. If your sonoff device is used in a scenario and the order is not received by it, your vera won't do anything to solve that. I'm looking for a synchronous protocol acknowledgement between the sender and the receiver so that I won't need to code a scheduled task to check whether the command was executed. I use eventghost together with domoticz : domoticz when its plugins are OK, eventghost if I want a fully customizable management, like for my 433 devices which are sometimes lazy to trigger.

      dbemowskD 1 Reply Last reply
      0
      • ? A Former User

        Thanks for your detailed answer. If your sonoff device is used in a scenario and the order is not received by it, your vera won't do anything to solve that. I'm looking for a synchronous protocol acknowledgement between the sender and the receiver so that I won't need to code a scheduled task to check whether the command was executed. I use eventghost together with domoticz : domoticz when its plugins are OK, eventghost if I want a fully customizable management, like for my 433 devices which are sometimes lazy to trigger.

        dbemowskD Offline
        dbemowskD Offline
        dbemowsk
        wrote on last edited by
        #38

        @Foune said in Looking for detailed description for hacking a sonoff:

        If your sonoff device is used in a scenario and the order is not received by it, your vera won't do anything to solve that.

        Correct, but that is coding that needs to be done on the controller side and has little to do with the device. If the device receives the request, it will send the JSON response back.

        I'm looking for a synchronous protocol acknowledgement between the sender and the receiver so that I won't need to code a scheduled task to check whether the command was executed

        As I said, that needs to be coded on the controller side. If the sonoff doesn't receive the request, how is it going to send anything back saying that it didn't receive it. In the example I gave above, it shows the JSON acknowledgement that the command was received. The only thing you can do is write into the code that if the response is not received within some specified period of time, then re-send the command.

        Your 433 devices as you say are sometimes lazy to trigger. They may not be triggering because they did not properly receive the command sent by the controller.

        Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
        Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

        ? 1 Reply Last reply
        0
        • dbemowskD dbemowsk

          @Foune said in Looking for detailed description for hacking a sonoff:

          If your sonoff device is used in a scenario and the order is not received by it, your vera won't do anything to solve that.

          Correct, but that is coding that needs to be done on the controller side and has little to do with the device. If the device receives the request, it will send the JSON response back.

          I'm looking for a synchronous protocol acknowledgement between the sender and the receiver so that I won't need to code a scheduled task to check whether the command was executed

          As I said, that needs to be coded on the controller side. If the sonoff doesn't receive the request, how is it going to send anything back saying that it didn't receive it. In the example I gave above, it shows the JSON acknowledgement that the command was received. The only thing you can do is write into the code that if the response is not received within some specified period of time, then re-send the command.

          Your 433 devices as you say are sometimes lazy to trigger. They may not be triggering because they did not properly receive the command sent by the controller.

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by A Former User
          #39

          @dbemowsk All right, so we all agree about the superiority of the json over the MQTT in term of synchronous acknowledgement. This is why I'm asking to mgaman whether I can send commands to the sonoff using json, having in the same time the MQTT features : status report, command, and his new wifi features. I'm sorry if it is a native feature, having read the official doc It seems that chosing one protocol disable the others.

          EDIT : I have my answer, I read the source code, there is only the MQTT feature on mgaman's version. I wish I had this wifi MQTT management in addition to the original espeasy code.

          dbemowskD 1 Reply Last reply
          0
          • ? A Former User

            @dbemowsk All right, so we all agree about the superiority of the json over the MQTT in term of synchronous acknowledgement. This is why I'm asking to mgaman whether I can send commands to the sonoff using json, having in the same time the MQTT features : status report, command, and his new wifi features. I'm sorry if it is a native feature, having read the official doc It seems that chosing one protocol disable the others.

            EDIT : I have my answer, I read the source code, there is only the MQTT feature on mgaman's version. I wish I had this wifi MQTT management in addition to the original espeasy code.

            dbemowskD Offline
            dbemowskD Offline
            dbemowsk
            wrote on last edited by
            #40

            @Foune said in Looking for detailed description for hacking a sonoff:

            All right, so we all agree about the superiority of the json over the MQTT in term of synchronous acknowledgement.

            I never said that. I was merely commenting on how my setup works using the ESP Easy firmware which does send a return JSON response. I have never used MQTT, so I don't know if it sends a return response to a command or not. If it does, then I don't see any difference other than how you would process that response on the controller end.

            Also, with ESP Easy, I don't as you say "send commands to the sonoff using json". I send an HTTP request and receive the response in JSON format. If @mgaman has a way with MQTT to retrieve the status of a node, e.g. ON or OFF, then on your controller side code, you could send your ON/OFF command, and then right after send a status request command and check the response from that. Depending on the response, you could re-send the ON/OFF command if necessary.

            Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
            Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Antoliveira
              wrote on last edited by
              #41

              Hello!
              I have several sonoff RF, which I bought recently. They are with the original firmware. At this point I control the sonoff manually or through the amazon echo dot. I wanted to control the sonoff also through Homeseer which as far as I know supports HTTP / JSON request and MQTT if needed, via plugin. My question is this: it is possible to keep the voice command via amazon echo?
              Thanks

              dbemowskD 1 Reply Last reply
              0
              • A Antoliveira

                Hello!
                I have several sonoff RF, which I bought recently. They are with the original firmware. At this point I control the sonoff manually or through the amazon echo dot. I wanted to control the sonoff also through Homeseer which as far as I know supports HTTP / JSON request and MQTT if needed, via plugin. My question is this: it is possible to keep the voice command via amazon echo?
                Thanks

                dbemowskD Offline
                dbemowskD Offline
                dbemowsk
                wrote on last edited by
                #42

                @Antoliveira I don't know if there is an Amazon Echo plugin for Homseer, but if there is, you could convert them to work with homseer and run them with the echo via Homseer. This is what I do with my Vera controller. I have never used the original firmware. I didn't even know that worked with the echo, but my guess is that if you changed firmware that that would not work the same any more. The firmware I use on the Sonoffs that I have is called ESP Easy. Controlling a device is as simple as an HTTP request, and the firmware provides a JSON response. The commands are like this:

                HTTP://<SONOFF_IP>/control?cmd=GPIO,12,1 //this will turn on the device
                HTTP://<SONOFF_IP>/control?cmd=GPIO,12,0 //this will turn off the device
                

                I have a plugin on my Vera controller that controls the Sonoffs, and then I have another plugin that allows my echo to control my Vera enabled devices. The echo will not control the Sonoffs directly though.

                Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
                Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Antoliveira
                  wrote on last edited by
                  #43

                  @dbemowsk
                  Thanks for the answer
                  That's exactly what I want to do.
                  The homeseer has a plugin for the amazon echo, the only difference being that instead of commanding the sonoff directly (eg: "Alexa turn off Kitchen lights" I will need to say "Alexa tell Homeseer to turn off kitchen lights"
                  The most negative point will be that without the computer on which the homeseer runs, I will never be able to command the sonoffs by voice ....
                  Do you know if ESP Easy will work correctly on sonoff RF?
                  Thanks

                  dbemowskD 1 Reply Last reply
                  0
                  • A Antoliveira

                    @dbemowsk
                    Thanks for the answer
                    That's exactly what I want to do.
                    The homeseer has a plugin for the amazon echo, the only difference being that instead of commanding the sonoff directly (eg: "Alexa turn off Kitchen lights" I will need to say "Alexa tell Homeseer to turn off kitchen lights"
                    The most negative point will be that without the computer on which the homeseer runs, I will never be able to command the sonoffs by voice ....
                    Do you know if ESP Easy will work correctly on sonoff RF?
                    Thanks

                    dbemowskD Offline
                    dbemowskD Offline
                    dbemowsk
                    wrote on last edited by
                    #44

                    @Antoliveira My understanding of the Sonoff RF devices is that they are the same ans the regular Sonoff devices, with the only difference being that it includes a 433MHz RF receiver. The 433MHz receiver lets you control the device with an RF remote or other 433MHz controller. From what I read on it, the Sonoff RF still uses the same ESP8266 chip and is set up pretty much the same, with the RF receiver triggering the ESP8266 through GPIO 0 which is the same GPIO port that the on-board button is connected to. Because it still uses the ESP8266 chip, the ESP Easy firmware will still work. The only thing is that the 433MHz control will not work by just installing ESP Easy alone. ESP Easy is very configurable in how it functions, so you will have to basically tell it how to use the 433MHz functionality. It is the same as configuring the on-board button to work with it.

                    Here is some information from the LetsControlIt forum that gives some information.
                    https://www.letscontrolit.com/forum/viewtopic.php?t=3272

                    Here to is a link to my website blog post where I show how to configure the Sonoff to work with the Vera controller, but this section of the post explains how to configure ESP Easy to use the button as a local control switch. This should also work with the 433Mhz receiver.
                    https://dan.bemowski.info/2017/07/04/using-a-sonoff-with-espeasy-and-vera/#adding_local_control_using_the_button

                    Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
                    Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Antoliveira
                      wrote on last edited by
                      #45

                      @dbemowsk
                      Relevant and good quality information.
                      I fully understand what has to be done.
                      Now I have no excuse to at least test a drive ...
                      Thanks

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      17

                      Online

                      11.7k

                      Users

                      11.2k

                      Topics

                      113.1k

                      Posts


                      Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • MySensors
                      • OpenHardware.io
                      • Categories
                      • Recent
                      • Tags
                      • Popular