Smart Home Automation

Over the Christmas holidays, I thought it would be a good idea to see if I couldn’t write some code to automatically control my home’s “smart” devices based on the time of day etc.

All my “smart” devices are teckin smart plugs, and Teckin lightbulbs. I really want to get to the point where I can either deploy an opensource piece of software that can expose a RESTful API that I can communicate with in order to control my home devices, or find an existing RESTful API that I can communicate with to send the requests to.

I have managed to connect to, and authenticate with my google smart speakers, but then got stuck on how to send the commands to interact with the devices.

I thought maybe as an alternative, I could send requests to the “Smart Life” android app’s API which keeps leading me to “Tuya”, which looked promising from the API docs, but I went down a massive rabbit hole trying to get set up.

Question

Has anyone had some success with controlling smart devices such as sockets and lightbulbs through sending requests to google home/assistant, or used the Tuya API? I’d even be happy if I built “commands” or “actions” using a web interface GUI, I just need a way to expose them via a web URL or RESTful request.

Take a look at Home Assistant. Their code is open source.

3 Likes

I have some ‘Teckin’ smart plugs made by Tuya (the SP23). I also have some XS-A14 plugs made by NetVIP (also tuya).

Tuya is a whitebox manufacturer of smart devices, … basically if you can imagine youtubers selling merch like t-shirts and mugs with their channel logo. Tuya will sell smartplugs and lightbulbs with other brands logos, and will handle the updates of those devices and backend services required.

It’s kind of cool what they do, but as a technically capable end user I don’t care for that in my own home. I also don’t like having a gazillion apps for different things that almost but not really fully expose their feature sets across different ecosystems.

So I kept the hardware but got rid of my dependency on Tuya ecosystem.


What I did was: I have Home Assistant running on a raspberry pi 4 at home - it’s a whole operating system as a downloadable image, you can run it in a VM. It provides all the brains and integrations for everything.

For the particular smartplugs, I used tuya-convert to overwrite the firmware on the socket with tasmota. Which I don’t care particularly about, except for the fact it comes with tuya-convert and provides me with a webui to flash my own firmwre.

By my own firmware … I mean I used ESPHome to generate it from a yaml config. ESPHome is a HomeAssistant add-on, that lets you communicate with random esp8266/esp32 devices. You can configure everything on the microcontroller, and for a large majority of use cases all you need to do in order to get a useful end device is provide it with a yaml file in a webui, click some buttons and download a firmware file. If you want to change the device in the future, you can go to the esphome addon web-ui and ota flash your new changes.

Your home assistant can connect to google home (for google assistant integrations) or to alexa, … or you can have your own voice recognition and actions thing going. … it can also do its own automations and there’s an android app that’s mostly just a PWA.

There’s a company behind it, that as far as I can tell doesn’t really do much other than fund a couple of people who work on the opensource project all the time, and helps fund/maintain some of the project infrastructure.


Specifically for your devices. Are they these by any chance:


3 Likes

Looking into deploying a home assistant server on a local KVM VM. Will let you guys know how I get on. Looks very promising for now since it has docker deployment making life easy, and a documented REST API. Thanks for the tip!

1 Like

It’s easier if you give it a whole VM… It’s running docker for itself with its add-ons being deployed in containers.

It’s also fairly easy to build “integration components” in Python. Getting them submitted upstream is proving a bit of a challenge though, the dev team is very pedantic but will not actually maintain contributions to the same standard they ask of people for new stuff.

I also use Home Assistant and have converted all of my Tuya devices to tasmota. I did not see how my stuff was benefiting from being in the cloud. Plus, I have connected Home Assistant to my wife’s Google Assistant and she is able to control all of the devices from the “smart” speakers and here phone from anywhere. She wanted all of the smart features and I did not want rogue IoT activity on my network.

Another plus one for home assistant. Very versatile and open to many platforms. All the above comments stand and would be easier to get your plugs and products integrated into HA than you write your own web interface for it, that is unless you like doing it and want that challenge.

I think we can all agree that home assistant is pretty amazing. I am deploying it through docker on its own VM in my KVM host and love how I can type a message in there and the google speaker will speak it out.

I found tutorials/videos on how to convert the touya plug/socketdevices, which I just need to do now. I am doubtful that my teckin bulbs will convert though, as there are a lot of online posts sayin a new firmware came out that blocks it. I will have to make sure that all future smart devices are HA compatible in future, or easily “converted”.

So I tried using tuya convert to convert my SP27 plugs, but I had no success. Every time I put the plug into “fast blinking mode” and then pressed enter on the tuya convert to pair, it would endlessly repeat sending packets and eventually fail. The plug would immediately stop blinking as soon as I would press enter, suggesting to me that the tuya device had communicated, but I’m guessing the firmware is blocking it?

I’ve had similar problems in the past with tuya-convert, it was a bit fiddly with the please connect your phone routine and I had to be careful to follow the instructions from the script to the letter. I also had my firewall interfere the second time.

It’s definitely a rube goldberg kind of thing, there’s plenty of opportunity to clean it up.

A lot of the Tuya stuff received signed firmware and encrypted firmware in December 2019. As a result, Tuya-Convet has worked less and less. As a result, any of the new stuff that I buy, I have had to flash the using the good old fashion way with an FTDI. I have had the best success with the TreatLife gear. Martin Jerry still is the easiest to work with, but I just don’t like the build quality or the feel of those devices.

Just in case you were not aware, here is a database of things that work with tasmota, things that don’t work, and follow on configurations once flashed.

1 Like

tuya-convert was updated mid-2020. This is how I flashed my xs-a14 , maybe there’s still a newer one.

All the automation I have in my home is Alexa

Thanks for share your story. I also have the same case.