Tuya Smart Plug

Wondering if anyone has used these with openhab.
https://www.ebay.com/i/201961768647?chn=ps&dispItem=1

They show up on slickdeals every now and then for 10 bucks.

They have an API for it:
https://docs.tuya.com/en/cloudapi/deviceAPI/tuya.device.active_4.0/

It’s weird how it works though.
I can use it through their app(turn on/off).
I have no idea how it gets past my router to do this.
I don’t have UPNP on, I don’t have any ports forwarded to it, but if I’m out and about, it works from my cell phone.

Wondering if any engineers can look at that and at least explain to me how this thing bypasses firewalls.

Ideally, I’d like to be able to CURL to this like with the TPLink plugs.

Thanks

Your firewall blocks incoming connections but not outgoing connections. The device creates an outgoing connection to the Tuya servers (e.g. like loading a web page) and your phone connects to these same servers and the servers relay the commands sent from your phone to the device.

Becuase the device initiates the connection the firewall does not block it.

This is how almost all IoT devices like this works.

Given this, I doubt there is a way to directly connect to your device. And a brief look at the API shows this is true. Your curl command would go to the Tuya’s servers and they will be relayed back to your plug.

As a consequence, these plugs are only controllable when you have Internet access.

Thanks. I appreciate the insight. Well it was 10 bucks…figured it was worth playing around for that price.

I bought a pair of the Mini Smart Sockets and decided to open one up.

It has the ESP8266EX processor like the SONOFF boards and could be very FIXABLE!

Inside the plug

the micro board

I hope to figure out a better way of opening it (We cut the top off)
It can be glued back together, but won’t be very pretty.

tom

Well I blew up the first one (Glad I have 2)

so now to take it completely apart and see if the little board works.

Took a quick look at the Tuya API pages. Does anyone see how to get a app ID/secret for auth with https?

I have one… I can set up a test wireless lan so I can capture a wireshark trace

Just describe what actions you need captured

tom

Edit: I’ve fixed my openhab wrapper to work with ver 2 of tuyapi. https://github.com/unparagoned/njsTuya . Here it is for reference, it has the scripts, rules, and items for reference.

There are a few api interfaces on github.

Check out https://github.com/codetheweb/tuyapi
They have a really good discussion thread on tuya https://github.com/codetheweb/tuyapi/issues/5

Look at the associated projects as well, I think some of the .net ports might be better than the original codetheweb api.

Any luck finding a way to open these without cutting them?

No, i did not

Hi,

I am having openhab2 up and running and bought few tuya smart plugs, which are working well with smart life app. but I a not able to integrate it with openhab2.

I had referred above GIT repo also, but it will throw authentication error while installing Tuya/cli.

can you please share brief steps how to integrate it with Openhab?

Thanks in advance…