SmartThings Community

Geekbes Smart WiFi Mini Plug - Somebody Please come up with a Device Handler (uses Tuya SmartLife app)

dth_pocketsocket
requires_server

(Nathan Beiley) #8

I received mine a few days ago.

I think a smartapp which connects to “Smart Life” needs to be created.
This is how Google Home connects to device


#9

Just got mine today and was able to reflash the wifi chip.

If you use any of this information and burn your house down or electrocute yourself or someone else, you’re doing so at your own risk. I’m not responsible.

I used alot of the information on from the tasmota wiki for the sonoff devices in order to get this flashed.

It is in fact an ESP8266, and I was able to flash the tasmota firmware once i got the unit disassembled. There is a breakout board labeled “cdtech” which has all the pins labeled which made the wiring up to my FTDI pretty easy.

~/Downloads/esptool-2.2$ sudo python esptool.py -p /dev/ttyUSB0 write_flash -fs 1MB -fm dout 0x0 sonoff.bin
esptool.py v2.2
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Compressed 488080 bytes to 337379...
Wrote 488080 bytes (337379 compressed) at 0x00000000 in 29.9 seconds (effective 130.4 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting...

Couple of things to note:

  1. Its somewhat difficult to get this apart. I broke the wifi antenna when my screw driver slipped when trying to pry the face off, luckily it still has some of it and does still work… The ground pin also broke off when trying to get the PCB out of the case. I soldered it back on well enough to test it.
  2. The button on the PCB is not wired the same as the sonoff’s and can not be used to put the ESP8266 into bootloader mode. I had to wire a temporary switch from GND to GPIO0/IO0 on the CDtech PCB.
  3. I had to flash a “custom” version of tasmota with my wifi SSID and password built in, as the button does not work to put tasmota in “AP Mode” like it does with the sonoff’s. Once it had my wifi info, it was able to connect up to the wifi without issues.
  4. Once flashed and connected to my wifi, toggling the switch from the wifi seems to only toggle the button’s light, not the internal relay. I played a little bit with the “Configure Module” options, but didnt get it working. I might need to pull it apart again and figure out which GPIO the relay is connected to.



#10

A few more pictures of the wifi module and the exposed pins. I found that IO12 controls the LED.




#11

More progress today.

GPIO12 – Blue LED
GPIO13 – Button
GPIO15 – Relay

I was able to get it working in tasmota by adding the following section to sonoff_template.h file.

{ “Geekbes”, // Geekbes\CDTech (ESP8266)
GPIO_USER, // GPIO00
0, // GPIO01 Serial RXD and Optional sensor
GPIO_USER, // GPIO02
0, // GPIO03 Serial TXD and Optional sensor
0, // GPIO04
0, // GPIO05
0, 0, 0, 0, 0, 0, // Flash connection
GPIO_LED1, // GPIO12 Blue LED (0 = On, 1 = Off)
GPIO_KEY1, // GPIO13 Button (0 = On, 1 = Off)
GPIO_USER, // GPIO14
GPIO_REL1, // GPIO15 Relay
GPIO_USER, // GPIO16
0
}


#12

After doing all of the above, somehow I stumbled upon some new information!



This isn’t a complete solution for Smartthings integration yet, but should eventually result in one without having to flash the firmware.

I was able to test out the script that codetheweb\tuyapi has listed on the github and can confirm it works with the Geekbes plug.

You need to get some information from when the plug initially pairs with the wifi and Smart Life app(localKey,devId/uuid). See below.

I also pieced together enough of a device handler and a nodejs script (both hacked up from Dave Gutheinz’s TPLink DHT/nodejs) to get it to cycle the plug state from within the smartthings app, just like the test script on the tuyapi github does, but no on/off or status checks are working in ST.
I’m going to continue working on the device handler and node script, but this is my first attempt at either.

The below instructions were taken from taken from the m4rcus.TuyaCore github to get the required info using android adb commands.

Retrieving Tuya Plug ID and LocalKey values:

    Install the Tuya Smart Life App onto your device
    Install ADB on your computer: https://www.xda-developers.com/install-adb-windows-macos-linux/
    Ensure your device has USB debugging enabled
    Plug device into your computer
    Run filtered ADB logcat via shell:

    > adb shell
    > logcat | grep BindDeviceSuccessPresenter

    Add the smart plug in the Tuya App, monitor the adb logcat output for the following
    Find the "localKey" and "devId" keys listed in the output, ex:

    12-06 23:58:53.544 17782 17782 D Tuya    : BindDeviceSuccessPresenter updateList devIds:[{"ability":0,"attribute":0,"bv":"5.06","cloudOnline":true,"devId":"0120015260091453a970","encrypt":false,"gwType":"s","i18nTime":0,"iconUrl":"https://images.tuyaus.com/smart/icon/1496461963_0.jpeg","isLocalOnline":false,"isOnline":true,"lat":"","localKey":"5f5f784cd82d449b","lon":"","name":"WiFi Plug ","pv":"2.1","rnFind":false,"runtimeEnv":"prod","supportGroup":false,"switchDp":0,"time":1512626328,"uuid":"0120015260091453a970","verSw":"1.0.4"}]

    In this example, the LocalKey is 5f5f784cd82d449b and the Id is 0120015260091453a970
    Find the IP address of your device via your router's DHCP leases. The IP address reported by the app is not the local IP address.

	The localKey changes when you remove and re-add the device from the Smart Life app.

#13

Here is my github for the device handler and node script for these plugs. Last night was the first night that it survived the night, so I’m hoping some of the issues i had were corrected.

It requires codetheweb/tuyapi(npm install codetheweb/tuyapi) to be installed, and it runs on port 8083.

You need to set static IP’s for the plugs and get the devID and localKey as mentioned above.

Let me know how it works for you guys. I’m sure it needs some work still.


Color bulb
(Nathan Beiley) #14

Get the local_key is a PIA. I suggest everyone send feedback within the Tuya app asking them to display the local_key under Device Info within app.

I did, i think if enough people ask they would add it


(Kevin Joyce) #15

Does anyone have detailed steps how to make the geekbes ym-ws-1 smart plugs work with Samsung Smart Things? I have been following this discussion but not quite sure what would need to be done. Flash, don’t flash. Used ADB to update.

If someone could provide the steps I would really appreciate the information.

Thanks


#16

Only sure fire way to get these things working at the moment is by flashing them with tasmota. Problem here being the difficulty of popping the cases on these things without destroying them. A dremel tool to the back of the case might be able to expose the GPIO/TX/RX pins i had identified earlier.

The other way is with TuyAPI, no flashing. Requires retreiving the localkeys and dev id. I had a node script and device handler working partially, which is on my github listed above, The problem here was something would happen to cause the connection to the plug go haywire. About the time I was working through that, TuyAPI was updated. I was learning both the javascript and the groovy DHT as I was going. I haven’t got around to re-working the node script since the TuyAPI changes. I’m not sure when I will have time to pick it up again.

Personally, I am hoping TuyAPI comes up with a method flashing these devices with a custom firmware(tasmota). Some of the recent progress they have made around getting API keys, etc… might go a long way towards that.

Sorry I dont have any more detailed step-by-step instructions.


(Glen King) #17

Depends on your need. If you need instant reaction, get ST or Iris smartplugs.
If your use case allows flexibility, use the geekbes plugs with IFTTT as your intermediary.


(Kevin Joyce) #18

Thanks. I was hoping there was something more like a firmware flash directly, but not yet.


(Kevin Joyce) #19

I am already using IFTTT but was looking for something in the Smart Things app since it doesn’t see the plugs


(Glen King) #20

You can “fake it out” using virtual/simulated smart outlets so that ST indeed can know and report, and act on, the on/off status of the plug. As well as command the plug to turn on/off. There are plenty of posts on these forums about how to do this.


(Kevin Joyce) #21

I am trying for find an example of how to use these through Smart Things as a virtual outlet. I created an outlet using the information I found but I am not seeing how to connect the smart plug to the virtual outlet.


(Deco D Deki) #22

Hi Blawson327,

I bought Geekbes YM-WS-1. Using dremel I managed to open it without damage to internal electronics.
I have soldered following connections:

  • TX, RX, GND, 3.3V -> FTDI
  • GND, GPIO15 -> switch
  • GPIO0 -> bootloader mode

I have a plan of retrofitting these to EU light wall switches in my apartment. Physical switch would serve as on/off switch; flashing Tasmota in order to connect Geekbes to HomeAsisstant -> turning lights on/off using connected devices.

Powered it on for the first time using FTDI - switch was working –> switching relay on and off (prior to any flashing).

After that I downloaded latest release of Tasmota (5.12.0) and followed your instructions for flashing:

  • To section sonoff_tamplate.h I added your code.
  • To section user_config.h I added my ssid and pass

Successfully flashed using following settings in IDE:
Board Mode: "Generic ESP8266 Module"
Flash Mode: DIO
Flash Frequency: 40Mhz
CPU Frequency: 80Mhz
Flash Size: 1M (64k SPIFFS)
Debug Port: disabled

But powering it on after flashing does nothing. I can not find it connected to my WIFI network.

Is there something I am doing wrong? I would kindly ask for your help :slightly_smiling_face:


(Glen King) #23

You will need two IFTTT recipes per geekbes outlet. Geekbes works thru the SmartLife app.
Sooo recipe #1:

  • if SmartThings simulated Outlet switched ‘on’, Then turn on SmartLife geekbes Outlet

Recipe #2:

  • if SmartThings simulated Outlet switched ‘off’, Then turn off SmartLife geekbes Outlet

Do that, and you can automate the outlet by automating the virtual outlet you created in SmartThings.


(rathkopf) #24

You need a total of 4 IFTTT recipes if you want feedback of the state into the SmartThings app.


(Mitul Shah) #25

What are the other two? I made one for on and another for off, I can’t think of two more?


(Edward Niedziejko) #26

Notifications of manual state changes, I think.


(Kevin Joyce) #27

Does anyone have any examples how to make these work? I have the virtual device but still don’t see how to make the virtual device control the Geekbes plug.