SmartThings Community

[RELEASE] Sonoff, Sonoff TH, S20, Dual, 4CH, POW, & Touch Device Handler & SmartApp ($5 & $10 Smart Switches)

dth_lighting

(James Doakes) #507

Eric, I flashed my sonoff POW with your code and it seems to work fine on it’s own but I’m having problems with power reporting in ST. I first tried adding it as a device in IDE using your device handler but I didn’t see any way of adding the IP address of the POW device in there. I then added the handler to the sonoff connect smartapp code and was able to select it when discovering manually. This works but only allows me to turn it on and off. It does not show any power WAV information in ST. Is there any other way I can get it to work?
Here is what I added to the smartapp

def manuallyAdd(){
dynamicPage(name: “manuallyAdd”, title: “Manually add a Sonoff device”, nextPage: “manuallyAddConfirm”) {
section {
paragraph "This process will manually create a Sonoff device based on the entered IP address. The SmartApp needs to then communicate with the device to obtain additional information from it. Make sure the device is on and connected to your wifi network."
input “deviceType”, “enum”, title:“Device Type”, description: “”, required: false, options: [“Sonoff Wifi Switch”,“Sonoff TH Wifi Switch”,“Sonoff POW Wifi Switch”]
input “ipAddress”, “text”, title:“IP Address”, description: “”, required: false
}

Thanks


(Eric M) #508

I haven’t added the device information into Sonoff Connect yet. Here is what I would do:

  • Delete the manually created device in the Sonoff Connect App.
  • Go back and “discover” the device in the app. It will install the default Sonoff Handler, but that is ok.
  • Then, go into the IDE and assign the Sonoff POW handler to it.
  • Open the device in the SmartThings app and hit “configure” to make sure the appropriate settings are sent over.

(James Doakes) #509

Well that worked just fine. Weird.
On a separate note, do you know if there’s a way to get the sonoff inching/self-locking device flashed or is it a different board? I have one I use to remote open/close my garage door but I’m still forced to use the ewelink app for it. Same with the sonoff SV. I’m working on a small motor setup to open/close my blinds.

Thanks


(Duwayn) #510

Ditto on including the sonoff inching/self-locking device. That would be awesome as it seems to be the perfect cost effective solution for interfacing SmartThings with my throw back GE low voltage lighting control system. The only other solution I have found is the FortrezZ MIMO, but it is way more than what I need for the application… including cost. TCPExperts - Are the NO/NC contacts on the inching/self-locking “dry”? Based on what I can tell they are, but I haven’t put my hands on one yet to verify.

Thanks in advance!!!


(Eric M) #511

I don’t know the answer to the question, but this put a smile on my face. :slight_smile:


(Eric M) #512

Last night I had a chance to work on and I’m just about finished with the firmware / device handler for the Sonoff Dual. It is about 90% complete with just a few things missing (the auto-off feature, power on state, and some dual specific options that I want to add). Other than that, things are pretty solid on it. For those that wan’t to start using it while I finish things up.

This device is a composite device and requires 2 handlers to be installed. They are both posted below. Also, make sure you update the Sonoff Connect app.

It has clearly labeled headers (other side of the board), but putting it in flash mode is not as straight forward. Connect the right side of the shown resistor to GND. I’ll try to post a better photo later.

Frimware:

https://github.com/erocm123/SmartThingsPublic/raw/master/devicetypes/erocm123/sonoff-dual-wifi-switch.src/SonoffDual.ino.generic.bin

Main Handler:

Child Handler:


[RELEASE] ST_Anything v2.9.2 - Arduino/ESP8266/ESP32 to ST via ThingShield, Ethernet, or WiFi
(James Doakes) #513

Yes the NO/NC contacts are dry.


(Dan) #514

Eric,

Thank you so much for a great example of using the new Composite Device Handler. I have been working this morning on incorporating the Composite Device Handler (CDH) into some of my ST_Anything device handlers. I have it working pretty well, however I do have a question that I thought you might be able to answer.

In your image posted above, the two CDH’s show up in the parent with text as “Relay 1” and “Relay 2”. I understand that this text is set during the creation of the child devices (i.e. “componentLabel:”). Since you also set “isComponent: false”, these child devices show up in the Things List, where a user can change their Display Name.

I have this all working, however I am stuck trying to figure out how to change the “componentLabel” of the child devices to match the displayLabel of the child devices. It would be nice if they matched so inside the parent device view, the text displayed matched the text in the Things view.

I probably made that more complicated that it needed to be. If you have any ideas, please let me know.

Thanks,
Dan


(Steve ) #515

Thanks Eric I have it working finally now :slight_smile:
To anyone like me who flashed it ok but you couldn’t do the next bit I had to unplug from the mains and plug the 3.3v back in and while the led was of I held the power button for 20 seconds like someone mentioned and it flashes 5 times and when I plugged it back into mains and pressed the switch it showed up as I new Wi-Fi access point on my laptop.
Also for anyone else from the UK like me when you’re adding the new device handler you need to make sure you’re in the correct region of the website otherwise it won’t show up to install on the app.
Quick question though I’ve added 2 sonoffs to SmartThings goodnight routine and they work well but I can run it through Alexa as it says some devices are not supported is there a way around that.
Thanks again for the Mood :slight_smile:


(Eric M) #516

Well, I tried the obvious things (which you probably already tried) and they did not work.

it.setComponentLabel(“New Label”)
it.componentLabel = “New Label”

So I am not sure how to do it.


(Paulo Santos) #517

Hi. Having some dificulties flashing the sonoff dual. Can you add some pictures and how to. Found diferent explanations on the web how go get it in flashing mode.


(Duwayn) #518

Perfect!! Thank you!!


(Duwayn) #519

Thank you sir! I know just enough to be dangerous. :wink: If I were to get you a sonoff inching/self locking, any chance of incorporating its’ capabilities into your DH and App? I’m ok with wiring and following instructions… coding not so much.:confused:


(Dan) #520

Thanks for trying and your amazing support of the various ESP8266 devices out in the wild! If I figure it out, I’ll let you know.


(Paulo Santos) #521

Hi Duwayn, can you help with the connections.
how do you enter the sonoff dual into flashing mode?
Eric post says to connect GPIO0 to GND. But which one? the one in the header or directly to the FTDI/USB adapter?
Do you keep it connected during the process or just when powering device?
Sorry but have tried a few thing without luck.
Thanks


(Duwayn) #522

I’m sorry, Paulo, I have no experience with any of the Sonoff devices and am just starting to learn about them myself.


(Eric M) #523

You can attach it to the GND on the header or the FTDI adapter. You can also attach it to the GND that is on the header that is perpendicular to the one marked in my photo.

It should only need to be connected to during initial boot to get it into flash mode.


(Paulo Santos) #524

Thank you for your reply Eric and also for your great job in integrating these devices in ST.
Connect GPIO0 to GND on the header of FTDI and after a few seconds disconnect it?
FTDI adapter GDN doesn’t need to be connected after that for flashing?


(Eric M) #525

You can disconnect GND to GPIO0, but not to the GND terminal on the 4 pin header. It still needs to be connected. You are going to have two wires that go to GND during this process. One of them (the one to GPIO0) can be removed after initial boot.


(Paulo Santos) #526

Thank you. Can see where the problem was now.