Sonoff, how it works?



  • I have sonoff device used to on/off the light. I have installed and configured it through ewelink. All works fine .i just want to know how the cloud server is able to reach my sonoff device over internet although it doesn't have a public IP? I understand that the sonoff device is using http post and get requests to reach the server for status update and query as the server has public ip..etc. but don't understand how the cloud server is sending commands (on/off) to the sonoff device despit it doesn't have a public ip? So how the server is reaching the device over internet?



  • Perhaps the local IP of the sonoff is stored in the cloud service, than that is used from the app to control the sonoff locally.
    Are you still able to control it when you have no internet connection?

    I use tasmota on my sonoffs. That is completely transparent and doesn't send any data over the internet, just locally



  • I would expect there to be two options: Either the Sonoff connects to the Ewelink cloud service and polls if there are actions to be taken. So the actions are not sent directly to the Sonoff unit, but the Sonoff reads at some point something needs to be done.

    Another approach would be that a tunnel of some kind is initiated by the Sonoff. The Ewelink service then sends commands back through this tunnel.



  • @mhmd I never bothered to discover how original Sonoff firmware works. The whole idea that my home is managed via a remote Chinese server is just not appealing to me.
    Plus nobody in the DIY community using a native Sonoff app. The whole idea to buy Sonoff is to hack it.

    I have several Sonoff relays and I am using ESP Easy (Let's control it) firmware:

    https://rutg3r.com/sonoff-firmware-tutorial-to-esp-easy/



  • I too use Sonoffs and use the ESP Easy firmware that @alexsh1 uses. I wrote a BLOG post some time back on how to install and configure it for use with a Vera home controller. https://dan.bemowski.info/2017/07/04/using-a-sonoff-with-espeasy-and-vera/



  • @mhmd

    Please see https://blog.ipsumdomus.com/sonoff-switch-complete-hack-without-firmware-upgrade-1b2d6632c01 for a description on what the sonoff uses to cimmunicate with the chinese cloud.
    On initial setup you just integrate the sonoff in your WLAN and then it communicates with the chinese cloud. The ewlink also communicates with the chinese cloud and status and other commands are stored and forwarded by the cloud to/from your sonoff device.



  • @mhmd It's a function of your router's network address translation (NAT). It's the same way your browser can get push notifications (as from this forum).

    When your Sonoff device communicates with the Chinese server, your router uses a different port number and stores that info. When traffic comes in to your external IP address with that port number the router knows which internal IP address and port to send it to.

    You can read more about NAT elsewhere.

    The bottom line is that the Chinese server isn't getting special access to your network and doesn't know your local IP address.


Log in to reply
 

Suggested Topics

  • 4
  • 2
  • 20
  • 2
  • 4
  • 3

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts