TuyaGateway v2.0 now available

Tags: #<Tag:0x00007f73999c3470> #<Tag:0x00007f73999c3380>

Hi All,
I (with the help of a few others) developed TuyaGateway. A python server that talks to your tuya devices on one side and MQTT on the other. TuyaGateway uses TuyaFace to connect with the devices. TuyaFace is the rewritten variant of the much used, and not very well working python-tuya library. With an additional (web)application (GismoCaster) the configuration can be created for both the gateway and Home Assistant (discovery). Below a quick overview of the goodies.

I’ve a limited amount of devices I could test (and of course they work all fine now), so at this point I’d like to invite others to give it a try. I’d love to hear your feedback.


I have two plug sockets with energy usage that is “useless” in HA.
Is that something that works or you need help with debugging?
(The energy usage thing)

I’ll give it a try once I finish my new instalation since I have a few devices in this platform, but I’d like to ask:

I have one tuya RF gateway with a few door/presence sensors, is there any chance of me getting these devices to appear in HA?

Thanks. It will not be this evening, but tomorrow or this weekend I’m definitely going to install this.

I’ve tested with this series of products https://www.aliexpress.com/item/33039474452.html (they couldn’t be flashed) 1,2,3 gang switches and the wifi sockets. These work flawlessly with the gateway.
In short when you have the deviceid and the localkey you should be able to get them in your devicelist and contol them.

I am happy to work with you to help you through the problems.

@Tradeface I have recently acquired this Tuya Vacuum cleaner from Aliexpress and unfortunately doesn’t have a ESP8266 to be flashed nor Tuya Vacuum’s are yet integrated in Home Assistant integration.

Do you think this will work?

I also have a Tuya Scale (it has ESP8266 but I haven’t yet figure out the communication to the main MCU and I’m Ok reverting back and forth to stock or custom firmwares), a Tuya 866mhz Thermostat Gateway (no ESP8266) to control the 866mhz Radiator Valves (TRV) and the next couple of days I should also receive a Tuya Wifi Door Lock (I know already it has ESP8266 rest to know if it will play nice with Tasmota).

@Sthope I think it will work, provided that you have the id and key (and of course a network connection)

In earlier version of the software I only supported booleans (on/off). After a some what extensive rewrite, now also str/int/float are supported. So technically the gateway way is able to do the job. GismoCaster had a bit of a early birth, so there might be a bit of trouble correctly setting up more complex devices ( like the vacuum). But with new insights in what is exactly needed I can rewrite the interface to accommodate these devices.

GismoCaster is roughly said a mapping tool; In which you map the commands from HA to data endpoints on the device. And v.v. for status data the device returns

1 Like

Alright, thank you for your quick reply!
I’m at home today I will give it a test.

I do buy all ‘crazy’ and new Tuya devices that I know or think it has a ESP8266 to make it compatible with Tasmota.
I’m happy to help if that’s necessary.

When I run

git clone https://github.com/TradeFace/gismocaster.git
cd gismocaster

On the make I get endless messages of these :

2020-06-12 07:25:10,770 WARNING  [mqtt.mqtt] () Failed to connect to MQTT Broker Setting matching query does not exist.
2020-06-12 07:25:10,775 DEBUG    [mqtt.mqtt] Publishing tuyagateway/config/homeassistant/binary_sensor {"values": [], "topics": [{"name": "availability_topic", "abbreviation": "avty_t", "topic_type": "publish", "default_value": "~availability", "values": []}, {"name": "json_attributes_topic", "abbreviation": "json_attr_t", "topic_type": "publish", "default_value": "~attributes", "values": []}, {"name": "state_topic", "abbreviation": "stat_t", "topic_type": "publish", "default_value": "~state", "values": []}], "templates": []} True
2020-06-12 07:25:10,885 WARNING  [mqtt.mqtt] () Failed to connect to MQTT Broker Setting matching query does not exist.
2020-06-12 07:25:10,890 DEBUG    [mqtt.mqtt] Publishing tuyagateway/config/homeassistant/alarm_control_panel {"values": [], "topics": [], "templates": []} True
2020-06-12 07:25:11,161 WARNING  [mqtt.mqtt] () Failed to connect to MQTT Broker Setting matching query does not exist.
2020-06-12 07:25:11,166 DEBUG    [mqtt.mqtt] Publishing tuyagateway/config/homeassistant/switch {"values": [], "topics": [{"name": "availability_topic", "abbreviation": "avty_t", "topic_type": "publish", "default_value": "~availability", "values": []}, {"name": "command_topic", "abbreviation": "cmd_t", "topic_type": "subscribe", "default_value": "~command", "publish_topic": "state_topic", "values": []}, {"name": "state_topic", "abbreviation": "stat_t", "topic_type": "publish", "default_value": "~state", "values": []}], "templates": [{"name": "json_attributes_template", "abbreviation": "json_attr_tpl", "default_value": ""}]} True

All help is welcome :slight_smile: And yeah it shouldn’t even be a consideration if a device can be flashed.

Yes, one of the results of early birthing gismocaster. It directly tries to connect to mqtt (without configuration) You can start the server and login to the admin.
Then navigate to mqtt > settings and put in the right connection details.

Since I don’t have a desktop environment on the pi I installed it on, I tried starting it with

 python3 web/manage.py runserver --noreload

Now I get :

Sorry, forgot /admin, now I get something :slight_smile:

:slightly_smiling_face: great

Yeah I should put a page there

A workflow would be nice. I have 2 of these :

But I’m not sure how to connect them with TuyaGateway. Both TuyaGateway and Gismocaster are running already, but now how to proceed ? I have the local keys.

Hmm, the interface is a bit technical indeed. You can start with adding a gismo model. And map the datapoints it provides. Then add a gismo and connect the created model. After that you should be able to see the device in HA (and control it)

Hi! Do I need to install it separately or it can be installed through HA Add-on thingy ?

Struggling to get both tuyagateway and gismocaster working in docker images. I opened an issue on the gismocaster side, but figured I’d check here first on the tuyagateway.

I am running HA on a Ubuntu 16.04 box in a docker container with supervisor. Have set up Mosquitto and can test that independently working.

When I make the docker I have tried passing config parameters in the Dockerfile (username, host, password) and tried accepting the defaults and setting Mosquitto to allow anonymous connections, but I never get a log message of the tuyagateway connecting to Mosquitto.

How do I set the configuration for host/port/user/pass when I’m using the docker install?


Can this be installed on same Raspberry as the Hassio?

OK - I have it all installed, but really struggling with the whole Gismo model / Gismo thing. Where can I find more documentation on it? I have confirmed in Mosquitto log that the Gismocaster container is connected to Mosquitto.

I followed the screenshots for one of my switches and one of my lights, then sent MQTT messages through Mosquitto based on the testing page on GitHub, but I’m not seeing anything come back and the lights/switches won’t change state.

I’m sure if I can get one going the rest will be easy, just not making sense for the first one :slight_smile:

I would like to try it, I have 10 sockets of Tuya and looking for additional items to be delivered,
it seems that the docker compose is invalid (image is inaccesible), can you please provide an updated docker compose to run it?