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. OpenHardware.io
  3. 💬 Sonoff relay using MySensors ESP8266 wifi or mqtt gateway

💬 Sonoff relay using MySensors ESP8266 wifi or mqtt gateway

Scheduled Pinned Locked Moved OpenHardware.io
mqttsonoffhome assistanesp8266
93 Posts 25 Posters 28.0k Views 20 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.
  • hekH Offline
    hekH Offline
    hek
    Admin
    wrote on last edited by
    #24

    @gohan,
    it depends on if the controller supports ESPEasy/espurna "out of the box". Not all controllers even have MQTT support.

    1 Reply Last reply
    0
    • warmaniacW warmaniac

      @Efflon

      Can I ask please ? I don't know if I understand correctly principle of working Sonoff under mysensors , I uploaded sketch from here to Sonoff , Sonoff is connected to my WiFi network , now I need to make MQTT gateway connected trought LAN or WiFi to the raspberry where is running Domoticz ? I had nodeMCU will it work ? Thanks much

      EfflonE Offline
      EfflonE Offline
      Efflon
      wrote on last edited by
      #25

      @warmaniac the sonoff works just like any sensor except its configured as a gateway since that is what is needed for esp8266+mysensors . Mqtt or ethernet/wifi is just a matter of taste and your setup, skip mqtt if you don't have anything else using it.

      warmaniacW 1 Reply Last reply
      1
      • EfflonE Efflon

        @warmaniac the sonoff works just like any sensor except its configured as a gateway since that is what is needed for esp8266+mysensors . Mqtt or ethernet/wifi is just a matter of taste and your setup, skip mqtt if you don't have anything else using it.

        warmaniacW Offline
        warmaniacW Offline
        warmaniac
        wrote on last edited by
        #26

        @Efflon said in 💬 Sonoff relay using MySensors ESP8266 wifi or mqtt gateway:

        @warmaniac the sonoff works just like any sensor except its configured as a gateway since that is what is needed for esp8266+mysensors . Mqtt or ethernet/wifi is just a matter of taste and your setup, skip mqtt if you don't have anything else using it.

        I want to use standalone Sonoff (one device) than I must install broker (Mosquito) on my raspberry where is Domoticz running ? And how can I add than that device or how can this setup looks like.

        EfflonE E 2 Replies Last reply
        0
        • warmaniacW warmaniac

          @Efflon said in 💬 Sonoff relay using MySensors ESP8266 wifi or mqtt gateway:

          @warmaniac the sonoff works just like any sensor except its configured as a gateway since that is what is needed for esp8266+mysensors . Mqtt or ethernet/wifi is just a matter of taste and your setup, skip mqtt if you don't have anything else using it.

          I want to use standalone Sonoff (one device) than I must install broker (Mosquito) on my raspberry where is Domoticz running ? And how can I add than that device or how can this setup looks like.

          EfflonE Offline
          EfflonE Offline
          Efflon
          wrote on last edited by
          #27

          @warmaniac You dont need mqtt/mosquitto. Just follow the guide at https://www.domoticz.com/wiki/MySensors for adding a "MySensors Gateway with LAN interface (Ethernet)" then follow the ethernet sketch here https://www.openhardware.io/view/318/Sonoff-relay-using-MySensors-ESP8266-wifi-or-mqtt-gateway

          warmaniacW 1 Reply Last reply
          0
          • EfflonE Efflon

            @warmaniac You dont need mqtt/mosquitto. Just follow the guide at https://www.domoticz.com/wiki/MySensors for adding a "MySensors Gateway with LAN interface (Ethernet)" then follow the ethernet sketch here https://www.openhardware.io/view/318/Sonoff-relay-using-MySensors-ESP8266-wifi-or-mqtt-gateway

            warmaniacW Offline
            warmaniacW Offline
            warmaniac
            wrote on last edited by warmaniac
            #28

            @Efflon

            Tried LAN sketch after adding new hardware in domoticz this error occurs

            2017-04-06 06:28:07.230 MQTT: Connecting to 192.168.2.209:5003
            2017-04-06 06:28:07.335 Error: MQTT: disconnected, restarting (rc=2)
            

            after that Sonoff blik twice. What may be wrong ?

            Edit:

            Understand now , it is added as classic mysensor LAN gateway , now working fine ! I tried to do it complicated way , but it was easy :D

            2017-04-06 06:30:29.756 MySensors: trying to connect to: 192.168.2.209:5003
            2017-04-06 06:30:30.757 MySensors: connected to: 192.168.2.209:5003
            2017-04-06 06:30:30.758 MySensors: Gateway Ready...
            2017-04-06 06:30:30.762 MySensors: Node: 0, Sketch Name: Sonoff ethernet
            2017-04-06 06:30:30.763 MySensors: Node: 0, Sketch Version: 1.0
            2017-04-06 06:30:30.769 (MQTT) Light/Switch (Light)
            2017-04-06 06:30:31.778 MySensors: Gateway Version: 2.1.1
            2017-04-06 06:30:31.779 MySensors: Gateway Version: 2.1.1
            
            2017-04-06 06:31:11.939 User: Admin initiated a switch command (87/Sonoff-1/On)
            2017-04-06 06:31:11.942 (MQTT) Light/Switch (Sonoff-1)
            2017-04-06 06:31:12.789 (MQTT) Light/Switch (Sonoff-1)
            
            EfflonE 1 Reply Last reply
            0
            • warmaniacW warmaniac

              @Efflon

              Tried LAN sketch after adding new hardware in domoticz this error occurs

              2017-04-06 06:28:07.230 MQTT: Connecting to 192.168.2.209:5003
              2017-04-06 06:28:07.335 Error: MQTT: disconnected, restarting (rc=2)
              

              after that Sonoff blik twice. What may be wrong ?

              Edit:

              Understand now , it is added as classic mysensor LAN gateway , now working fine ! I tried to do it complicated way , but it was easy :D

              2017-04-06 06:30:29.756 MySensors: trying to connect to: 192.168.2.209:5003
              2017-04-06 06:30:30.757 MySensors: connected to: 192.168.2.209:5003
              2017-04-06 06:30:30.758 MySensors: Gateway Ready...
              2017-04-06 06:30:30.762 MySensors: Node: 0, Sketch Name: Sonoff ethernet
              2017-04-06 06:30:30.763 MySensors: Node: 0, Sketch Version: 1.0
              2017-04-06 06:30:30.769 (MQTT) Light/Switch (Light)
              2017-04-06 06:30:31.778 MySensors: Gateway Version: 2.1.1
              2017-04-06 06:30:31.779 MySensors: Gateway Version: 2.1.1
              
              2017-04-06 06:31:11.939 User: Admin initiated a switch command (87/Sonoff-1/On)
              2017-04-06 06:31:11.942 (MQTT) Light/Switch (Sonoff-1)
              2017-04-06 06:31:12.789 (MQTT) Light/Switch (Sonoff-1)
              
              EfflonE Offline
              EfflonE Offline
              Efflon
              wrote on last edited by
              #29

              @warmaniac Excellent!

              1 Reply Last reply
              0
              • BrydenB Offline
                BrydenB Offline
                Bryden
                wrote on last edited by
                #30

                Does anyone know how I can request the current state of the relay via MQTT.

                Eg HASS has rebooted, forgotten what state the switch was previously in, then it wont work untill power is cycled to the sonoff.

                I want to send an MQTT message to the sonoff to get its current state. Tried looking over the forums and page and cant seem to see anything about requesting a state from a binary switch / relay actuator

                martinhjelmareM 1 Reply Last reply
                0
                • BrydenB Bryden

                  Does anyone know how I can request the current state of the relay via MQTT.

                  Eg HASS has rebooted, forgotten what state the switch was previously in, then it wont work untill power is cycled to the sonoff.

                  I want to send an MQTT message to the sonoff to get its current state. Tried looking over the forums and page and cant seem to see anything about requesting a state from a binary switch / relay actuator

                  martinhjelmareM Offline
                  martinhjelmareM Offline
                  martinhjelmare
                  Plugin Developer
                  wrote on last edited by
                  #31

                  @Bryden

                  If you're using the mysensors component in home assistant, you can activate persistence to load devices and last known state when home assistant restarts.

                  Another option is to use the retain flag when publishing mqtt messages from the gateway. Support for this has been added in mysensors dev branch:
                  https://github.com/mysensors/MySensors/pull/793

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    Matthew Ohlson de Fine
                    wrote on last edited by
                    #32

                    How do you load the relay sensor in Vera after connecting the Sonoff as a wifi gateway as described?

                    1 Reply Last reply
                    0
                    • warmaniacW Offline
                      warmaniacW Offline
                      warmaniac
                      wrote on last edited by
                      #33

                      After electricity plugged off , it stops working / not connecting to wifi router, but on manual click it turns on and of , it is problem because I don't use haas config ? I dont know where can I place them, can you help me ? :) thanks

                      1 Reply Last reply
                      0
                      • U Offline
                        U Offline
                        user2684
                        Contest Winner
                        wrote on last edited by
                        #34

                        Hi, I see in the instruction a note about not being tested against 220v so just to confirm it is working fine, I've uploaded the sketch to one of those with the power socket plug embedded and I'm able to control it remotely. Great job!
                        As a side note, I'd copy and paste the "Sonoff specific details" instructions from the sketch also into the build page. My bad because I've missed them and had to google a bit on how to upload the sketch but maybe also others may experience the same.
                        Thanks

                        EfflonE 1 Reply Last reply
                        0
                        • U user2684

                          Hi, I see in the instruction a note about not being tested against 220v so just to confirm it is working fine, I've uploaded the sketch to one of those with the power socket plug embedded and I'm able to control it remotely. Great job!
                          As a side note, I'd copy and paste the "Sonoff specific details" instructions from the sketch also into the build page. My bad because I've missed them and had to google a bit on how to upload the sketch but maybe also others may experience the same.
                          Thanks

                          EfflonE Offline
                          EfflonE Offline
                          Efflon
                          wrote on last edited by
                          #35

                          @user2684 Thanks for reporting. I have updated the instructions with the Sonoff details.

                          1 Reply Last reply
                          1
                          • B Offline
                            B Offline
                            betonishard
                            wrote on last edited by
                            #36

                            Great work!

                            I was wondering if some of you already know if Espeasy supports the pow versions power usage reporting. I checked the github and couldn't find it. I know Espurna supports it (as a domoticz MQTT). However when I check the REST API of Esputna there is nothing noted about the power consumption (only humidity and temp) requests.

                            Any help is much appreciated.
                            Regards, and keep up the good work.

                            1 Reply Last reply
                            0
                            • U Offline
                              U Offline
                              user2684
                              Contest Winner
                              wrote on last edited by
                              #37

                              Hi, I have a sonoff device running this sketch since a few weeks now and everything is working great :-) However I've noticed that when the wireless network goes off and then is restored back again the sonoff results still unreachable. When I unplug and plug it again the connection it comes back online. Is this a known behavior? Thanks

                              1 Reply Last reply
                              0
                              • gohanG Offline
                                gohanG Offline
                                gohan
                                Mod
                                wrote on last edited by
                                #38

                                is it reachable via IP or is it totally unresponsive?

                                warmaniacW 1 Reply Last reply
                                0
                                • U Offline
                                  U Offline
                                  user2684
                                  Contest Winner
                                  wrote on last edited by
                                  #39

                                  Totally unresponsive like once disconnected from the wifi (I turn it off from time to time), it is no more able to reconnect. I still need to understand if it happens every time so I was wondering if this was somehow expected or not :)

                                  1 Reply Last reply
                                  0
                                  • gohanG gohan

                                    is it reachable via IP or is it totally unresponsive?

                                    warmaniacW Offline
                                    warmaniacW Offline
                                    warmaniac
                                    wrote on last edited by
                                    #40

                                    @gohan said in 💬 Sonoff relay using MySensors ESP8266 wifi or mqtt gateway:

                                    is it reachable via IP or is it totally unresponsive?

                                    I had same problem too.. When is longer not turned on, Sonoff disconnects from wifi , that ip is not in client list, in my case I only turn sonoff on throught black button on the top and than it is okay about day-two.

                                    1 Reply Last reply
                                    0
                                    • Nca78N Offline
                                      Nca78N Offline
                                      Nca78
                                      Hardware Contributor
                                      wrote on last edited by
                                      #41

                                      I have few sonoff and I just installed one with this script to replace a dead 433 device. So thank you very much for the script and the tutorial.

                                      Reports of regular wifi connection losses are what kept me away from sonoff until now. Maybe the script could check wifi connection regularly and force a reconnect. Something like in the link below ?
                                      http://www.esp8266.com/viewtopic.php?f=32&t=8286

                                      1 Reply Last reply
                                      0
                                      • BrydenB Offline
                                        BrydenB Offline
                                        Bryden
                                        wrote on last edited by
                                        #42

                                        Another I have had these running posts.

                                        I have had 3 Sonoff relays running on 240v 50Hz for 2-3 months straight.

                                        2 of them in IP67 outdoor lights with Phillips LED Lamps, switch on and off several times per day, Not a single hardware issue.

                                        best $6 ever

                                        Nca78N 1 Reply Last reply
                                        1
                                        • E Offline
                                          E Offline
                                          Ed1500
                                          wrote on last edited by
                                          #43

                                          @betonishard ESPeasy I am not sure, but supposedly Tasmota does

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


                                          6

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 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