SynAckFin / TuyOTA

Flashing Tuya devices with Tasmota firmware.
GNU General Public License v3.0
90 stars 13 forks source link

Gosund WP3 Module Configuration #6

Closed meingraham closed 5 years ago

meingraham commented 5 years ago

I assume I'm supposed to configure this as a Generic Module. Using @sylvandb TanTan WP3 configuration, this is what I have: image Does that look right?

axiom00 commented 5 years ago

That plug looks very much like the Teckin SP10. Try these settings.

image

meingraham commented 5 years ago

The plug functions as configured using @sylvandb's TanTan WP3 settings. The only issue I'm having is that when I press the button in the socket TASMOTA is seeing a "multi-press" APP: Button1 multi-press 1 and it takes a long time for the socket to respond and toggle the state of the relay. Is there anything I can do to remove the lag and also not have the button cause a "multi-press"?

axiom00 commented 5 years ago

Sorry I've never run across the multi-press issue.

By chance, is the plug connecting to your MQTT server? all my plugs are laggy to commands via the browser or button until I configure the MQTT settings.

digiblur commented 5 years ago

Change to switch1 and use the switchmode you want along with you can do a long press for other actions.

meingraham commented 5 years ago

@digiblur - sorry, a bit like Greek to me. Can you elaborate in "TASMOTA for Dummies"? ;-)

@axiom00 - yes it may be the lag of the plug sending the button to the MQTT broker and then the command being turned around before the action is taken on the relay. Perhaps the "switch" config Travis is suggesting make the relay action "local" w/o having to wait for a command back from the broker? But I need some hand holding. Also, if the button is giving the wrong "information" or it's having to "debounce" in some way, that may compound the lagginess.

meingraham commented 5 years ago

@SynAckFin BTW, I'm finding that if the flash fails, if I just up-arrow and repeat the command, after a few times, the flashing goes through successfully. The only remaining issue at the very end is that it says it fails to configure the newly flashed sonoff-xxxx. But, once it fails, and I point my browser to the IP, there it is in full TASMOTA glory.

I received four Gosund WP3 plugs this afternoon... and now have TASMOTA on all four. Still working out the kinks of the TASMOTA module configuration, but I'm on the home stretch. What I thought was going to be a weekend project ended up taking an evening. Gee, thanks! Now what am I going to do all weekend ;-)

I have attached the capture of my terminal session so you can see everything that transpired. Perhaps there are some clues in there. As you can see, I just kept running the script over and over until it finally succeeded for each plug.

Your Walkthrough was spot on! As you did, the only thing I did was to create an empty ssh file in the boot folder before I plugged the SD card into my RPi. Was able to SSH to it and drove all of this in headless mode. Easy, peasy!

Thanks for the great work... and to all who contributed in troubleshooting the project! Perhaps a few more enhancements can come from my log.

Cheers!

Mike 20190118_230000-TuyOTA.txt

digiblur commented 5 years ago

@meingraham change the config to Switch1. The one downside is you would lose the ability to do a 40 second long press for a factory default, but I have WiFi Manager as default anyways so it will go into AP mode if it loses it's WiFi connection.

I then set switchmode1 5 in the console to allow for a toggle and long press. I also changed setoption32 from the default 40 (4 seconds) to 7 for 0.7 second long press.

Then I set a rule1 of on switch1#state=2 do publish TravisStand/Short Toggle endon on switch1#state=3 do publish TravisStand/Long Toggle endon

I have this on my night stand and use it to fire off various actions in the house. Yes I could have used a DIY D1 mini with some other buttons but this was simple as it was already in case for me with a power supply and a button. I don't use the actual relay at all.

Usually when you go to a switch the response time is quicker since it also doesn't have to wait to see if you are doing a double press.

image

meingraham commented 5 years ago

@digiblur Travis,

Thanks. Changing from a button to a switch helped considerably.

As I understand it, the rule is not needed for "regular" operation of the socket; yes? The rule just takes advantage of having the button and performing actions in addition to triggering the relay. Basically:

Thanks.

Mike

digiblur commented 5 years ago

You will need a rule on the state=3 of the switch to send out the long press action. If there is no rule for state=2 then yes it will toggle the relay.

sylvandb commented 5 years ago

That's picture is the GPIO config I'm using. You can swap which LED GPIO you assign as LED1i if you want to change colors.

Did you configure an MQTT server? If not, I suspect that is causing your delay (it seems to be trying to find a server). Once I configured an MQTT server the lag went from annoying to barely noticeable.

meingraham commented 5 years ago

@sylvandb - yes, I have MQTT set up. The lag is minimal now that I have GPIO4 set up as a switch.

meingraham commented 5 years ago

Final configuration: image

Backlog SwitchMode1 5; SetOption1 1; SetOption13 1

dhami220 commented 5 years ago

Blitzwolf SHP worked on my gosund device.

meingraham commented 5 years ago

@dhami220

Do you mean that the module configuration for the BlitzWolf SHP1 worked for your Gosund WP3? Where is that documented? I looked over on the TASMOTA wiki and it only had the SHP2/4/6. How different is your configuration from what I have above? Thanks.

Mike

dhami220 commented 5 years ago

Here is how my device is configured. @GeorgeIoak recommended it in the original thread and it worked.

My device is: https://www.amazon.com/Assistant-Required-Enabled-Control-Gosund/dp/B072ZX8RTZ

image

dhami220 commented 5 years ago

This is on the home screen, which shows power monitoring, but i believe the plug lacks that hardware functionality. image

meingraham commented 5 years ago

That's the plug I purchased. It has power monitoring?

GeorgeIoak commented 5 years ago

No, I don't think any of the small (only covers 1 outlet) US style plugs has enough room for the power monitoring. If you go to the BlitzWolf product page you'll see that all of their other plug styles have the monitoring except the SHP1.

I have one of the Gosund plugs taken apart but not unsoldered from the mains pins which would allow me to inspect the backside of the PCB and confirm what components are on it. I do have a BlitzWolf completely taken apart but I haven't reversed engineered it yet.

Right now I'm in the mode to try and get as many of these devices converted to Tasmota and then I'll start digging into them a bit more. I'm trying to provide as much information as I can to @SynAckFin and @kueblc as I can.

meingraham commented 5 years ago

@GeorgeIoak,

I didn't think so in such a small package. I was wondering since the SHP2 config sets up power monitoring. I'll probably stick with setting up a "custom" configuration as a Generic module to not confuse the issue. No need to generate the extra payload data and have the web page show non-existent sensors.

Yeah, I wasted no time getting my Gosunds flashed. I'm paranoid that Tuya (or their licensees demands) will decide to close the door on the OTA hack. Hopefully not. I only needed one mini-plug right now. I got four for good measure and flashed them all. Each one ended up being less than $6 each after some discounts (regularly $8.50 in the 4-pack). Can't beat that! 18 months ago I bought some TP-Link "mini-plugs" (ha!) for $27 each and I thought that was a bargain!

Mike

P.S. Thanks for ALL the testing and disassembling you're doing. Your contributions to the Tuya OTA process will benefit me and many others tremendously!

dhami220 commented 5 years ago

@meingraham I tried the generic configuration mentioned in this post on my plug, and it stops responding. There must be some hardware difference between our plugs. Back to Blitzwolf.

meingraham commented 5 years ago

Interesting. Differences in Gosund WP3 varieties would be something to note on the wiki.

These are the only markings on the exterior of mine. Do yours have any differences? image

GeorgeIoak commented 5 years ago

@meingraham Yeah, If I had to place a bet I would say that none of these that are small enough to not block the 2nd outlet won't have energy monitoring. I want to try and map out the button, LED, and relay on these and see if they all map to the same GPIO pins. That would be ideal for Tasmota as we could just submit a PR to add a new device for small US style plugs.

I've seen 3 different WiFi modules used in the 4 different plugs I've taken apart so I might need to buy a few more (or donations gladly accepted) to take apart to get a real database of these created. They're can't be that many different reference designs of this style out there!

Looking at my Gosund WP3 the only marking difference I see in mine is that mine has a B10 at the bottom, not B12. That might be some kind of date code though.

I only have 1 of these in actual use and I'm not even sure what I'll do with these since I can't think of what I would want to control.

GeorgeIoak commented 5 years ago

This isn't the best picture but it shows the Gosund WP3 on the left(the one with the wires) and the BlitzWolf BW-SHP1 on the right. You can see that the board layouts are nearly 100% identical. The silk screen is different and the 2 electrolytic caps with TH inductor at the top of the board are in slightly different locations. If I find time today I'll come back with GPIO mapping for the 2 boards if we think it's necessary.

20190119_100704

digiblur commented 5 years ago

If there isn't any power monitoring on the plug it is usually better to just add the device to the Tasmota Wiki in the other devices section. Then folks can just set it up in Generic easily and no additional firmware code space is needed.

GeorgeIoak commented 5 years ago

From what I can tell and recognize this design has a bridge rectifier to go from AC to DC. Then that is fed to some unknown switching regulator to drop the voltage. Then a standard AMS1117 regulator is used to provide the 3.3V.

Other than that there's the usual protection around the relay being driven by a transistor and the 2 color LED and button

meingraham commented 5 years ago

@digiblur - I added the Gosund WP3 to TASMOTA other devices based on my flashing & configuration experiences.

If we find that there are different varieties of Gosund WP3 itself (I don't mean similar/identical switches from different vendors), then we can expand the wiki accordingly.

GeorgeIoak commented 5 years ago

One other difference between these 2 designs I forgot to mention is that the actual WiFi module is different which could of course lead to different GPIO assignments. The BlitzWolf uses the Hysiry ESP8266-S3 module and the Gosund uses the Tuya TYWE2S

I'd be willing to bet that these 2 companies just buy what's available and brand them with their logo so as with most Asian products what you buy one day may not be exactly the same the next day.

sylvandb commented 5 years ago

I hate it when companies put the same branding, model numbers, etc. on different products. That will make things confusing and error prone. So far I've been impressed that the Smart Life app can tell different products apart... Probably it has some unique identifier "This is a Gosund WP3" regardless of the actual implementation, combined with standardized API for on/off is all it needs.

GeorgeIoak commented 5 years ago

@sylvandb Looking at the factory firmware for different devices shows that they pass a product_key which most likely is used in the Smart Life App. These 2 plugs are physically different (same small US plug style) so I want to get a factory firmware image from a BlitzWolf and see how close it is to the Gosund.

Gosund:
=======
ESP.ty_ws_mod.gw_sumer_table_key=[]<bh:00>ESP.ty_ws_mod.wf_nw_rec_key=
{"ssid":null,"passwd":null,"wk_mode":0,"mode":1,"type":0,"source":0,"path":0,"time":0,"random":0}
<bh:00>ESP.ty_ws_mod.gw_active_key={"token":null,"key":null,"local_key":null,"http_url":null,"mq_url":null,
"mq_url_bak":null,"timeZone":null,"region":null,"reg_key":null,"wxappid":null,"uid_acl":null}
<bh:00>ESP.ty_ws_mod.timer_posix_key={"lastFetchTime":0,"count":0,"whole":true}<bh:00>ESP.ty_ws_mod.dev_if_rec_key=
{"id":"68102802dc4f22d51fc4","sw_ver":"1.0.4","schema_id":null,"etag":null,"product_key":"AiHXxAyyn7eAkLQY","ability":0,"bind":false,"sync":false}
<bh:00>ESP.ty_ws_mod.gw_sw_ver_key={"sw_ver":"1.0.4","bs_ver":"5.33","pt_ver":"2.1"}
<bh:00><bh:00>":0,"type":0,"source":0,"path":0,"time":0,"random":0}
<bh:00><bh:00>rue,"sync":false}

TYJ:
====
ESP.ty_ws_mod.dev_ap_ssid_key={"ap_ssid":"SmartLife","ap_pwd":null}
<bh:00>ESP.ty_ws_mod.gw_active_key={"token":null,"key":null,"local_key":null,"http_url":null,"mq_url":null,"mq_url_bak":null,
"timeZone":null,"region":null,"reg_key":null,"wxappid":null,"uid_acl":null}
<bh:00>ESP.ty_ws_mod.timer_posix_key={"lastFetchTime":0,"count":0,"whole":true}<bh:00>ESP.ty_ws_mod.dev_if_rec_key=
{"id":"04200099b4e62d1374c0","sw_ver":"1.0.0","schema_id":null,"etag":null,"product_key":"JxRc0L3YeVkRanNf","ability":0,"bind":false,"sync":false}
<bh:00>ESP.ty_ws_mod.wf_nw_rec_key={"ssid":null,"passwd":null,"wk_mode":1,"mode":0,"type":0,"source":0,"path":0,"time":0,"random":0}
<bh:00>ESP.ty_ws_mod.gw_sw_ver_key={"sw_ver":"1.0.0","bs_ver":"5.24","pt_ver":"2.1"}
dhami220 commented 5 years ago

Mine has slightly different label. image

meingraham commented 5 years ago

Yours looks like it might have been a 250V design even though the rating says 125V. I'm looking at the T10AL250V marking. My unit not only says 120V, but the marking says T10AL120V. These definitely seem like they must have different internals. I wouldn't have thought that required a re-mapping of the IOs, but apparently they must have.

Short of cracking this one open and tracing the connections, perhaps some trial and error for the GPIO/LED permutations.

GeorgeIoak commented 5 years ago

I agree with @meingraham , your plug's marking look curious. I have my Gosund open but I didn't get too far mapping out the GPIO pins but I think @meingraham already has his working.

I was able to capture some additional logs and firmware today and we succeeded in finding some new information so Colin is digesting the new data.

dhami220 commented 5 years ago

How do you guys open these? This specific one hibernate and comes back to life every 3 months or so. Hoping to catch this alive soon and load tasmota.

GeorgeIoak commented 5 years ago

@dhami220 Sorry, but what do you mean:

This specific one hibernate and comes back to life every 3 months or so

To open these you need to find a thin tool like a knife and slowly work your way around the seam. It can help if you put this in a vise and gently squeeze to help break the bond between the 2 halves. I found that the Gosund was much easier to open than the BlitzWolf.

sylvandb commented 5 years ago

The seam is right around the base (facing the wall when plugged in)?

I've only tried a couple, and they were glued/welded very tightly. I think my next step would have been a saw but maybe I'll try a vice...

GeorgeIoak commented 5 years ago

I've opened many products that were assembled this way. The ones that are ultrasonically welded together are very difficult to open up. Not sure how well this will show up but here's 3 of the 4 plugs I've opened up. That's a BlitzWolf, Gosund, and Slitinfo. Notice how much the Blitzwolf is damaged yet the other 2 look almost perfect. 20190121_093323

Using the vice helps break the bond. You don't want to apply a lot of pressure as you'll just crack the plastic but you want to squeeze it enough to deform the shape a little which helps break the bond. I'm sure there must be videos of the process on YouTube

dhami220 commented 5 years ago

Thanks guys! Now I know where the seam is and will try to get my third one opened up.

@GeorgeIoak: I bought two plugs back in 2017. Used one right away and when I try to use the second one 6 months later, found it to be dead. Vendor sent me a replacement and that worked fine.

The one that was dead surprising turned on couple of times in last year or so (I was trying all sort of things; keep the button pressed, plug in a load, hold button before plugging in etc.), but process of bringing it to life is not repeatable. Once it turns on, I can provision it, and it works for a few days and then dies again. I was hoping it is some kind of software issue and hopefully, loading tasmota will fix it.

Something else I observed yesterday. Out of the three gosund plugs I have, I was able to flash the one that was sent to me as a replacement. Likely part of a different batch and had different gosund firmware (1.0.6? - should have recorded it). The second one that is alive (from the first batch) is not asking for an update (which is needed for the script to work).

GeorgeIoak commented 5 years ago

@dhami220 The unit that is intermittent sounds like a poor soldering issue more than software issue. I would practice opening that unit first so you can learn how it is done and if it really breaks it won't be a big a deal because it wasn't working properly before.

I'm not sure you need a firmware update for the script to work. We're learning new things about the default firmware and the process used to communicate and provision them. Hopefully soon "we" will be able to update the scripts and create a more fool proof firmware replacement method.

Unfortunately the Gosund that I opened is one of the harder units to attach wires to. Both the Tx and Rx "pins" are on the inside of the WiFi module. It took 2 of us for me to read the firmware on this unit, one person held the clips and the other worked the computer and other wires.

dhami220 commented 5 years ago

Put the unit in a vice and cracked open without much trouble. Looked around for loose connections and saw one of the capacitor lead loose in the pcb hole. bent the wire slightly and plugged it in. SPARK AND SMOKE. Now i think it is really dead :).

GeorgeIoak commented 5 years ago

I'm not sure bending the cap lead was the best approach but I definitely wouldn't use that unit now. I'd be curious to see a couple of pictures though

dhami220 commented 5 years ago

Here are a few pictures.

img_20190122_072918 img_20190122_072934 img_20190122_072947 img_20190122_073006 img_20190122_073022 screenshot_20190122-073109_camera

GeorgeIoak commented 5 years ago

I don't see any obvious signs of damage, which capacitor did you bend the lead on?

What I do notice is that this board is the same as what is in the BlitzWolf that I have and not the same as the Gosund that I have. The 2 designs are very similar but they do use a different WiFi module. I can't remember if we compared the GPIO assignments but I'm willing to bet that we're going to find the insides of these plugs are going to be different which means 1 person's Gosund could have different GPIO assignments then the next person's Gosund. I could be wrong so I'll try to map out both units today (or maybe we already have this information?).

As a manufacturer it would make sense to use whatever components are available but I would also try to make the same firmware for all of the devices.

meingraham commented 5 years ago

@dhami220 - Could you provide a couple of front/back close-up photos of the Wi-Fi module (the PCB installed vertically) to see if the specific type of Tuya module can be ascertained.

Thanks.

Mike

dhami220 commented 5 years ago

@meingraham Here are the pictures of the wifi module. img_20190125_072125 img_20190125_072227

@GeorgeIoak The black capacitor on the left had one wiggly leg. Felt like the solder joint on the bottom side of the board was damaged. img_20190125_072205

meingraham commented 5 years ago

@dhami220 - Thanks for the photos.

@GeorgeIoak - I haven't had to open my Tuya devices (thank you!) so I cannot compare to anything. I thought the Wi-Fi module photos might have some distinctive markings. Can you tell from the photos what kind of Tuya module it is? Or will it require looking under the metal shield?

Regards.

Mike

GeorgeIoak commented 5 years ago

@meingraham That is the ESP8266-S3 WiFi Module

It is used in the Gosund as well as the Dual plug I have called the slitinto

meingraham commented 5 years ago

Ah, it is, in fact, the metal shield which identifies it. Good reference site. I think I'll add that link to the wiki.

GeorgeIoak commented 5 years ago

The other WiFi module I've run into

meingraham commented 5 years ago

Thanks. I updated the wiki on TuyOTA and TASMOTA.

amitubale commented 5 years ago

That plug looks very much like the Teckin SP10. Try these settings.

image

These settings worked on the Tuya OUKITEL smart plugs from amazon. Flashed them with Tuya OTA process.