TuyaGateway v2.0 now available

I had the same problem, this method worked for me:

  1. Uninstall MQTT and TuyaGateway
  2. Install MQTT and Tuyagateway
  3. Wait 10/15 minutes after starting Tuyagateway

If you installed it via. my add-on it should auto-populate the admin/admin username into the database on the first startup. This can take a few minutes as it has to initialize the entire database. Check the logs to see if it threw any errors.

If you’re installing it some other way it very likely didn’t run the database setup (this will be true if you’re running it in docker). You will have to exec into the container and run “make init”. I opened an issue about this in github back when I first tried to install it using docker.

Has anyone successfully added a light with brightness and color temperature adjustment via GismoCaster?
I’m having issues with MQTT discovery.

There is an issue logged here: https://github.com/TradeFace/tuyagateway/issues/76 which I have added to, however I’m not convinced it’s a bug but rather that it’s likely something I’ve missed in the configuration.
Any advice?

I need to keep both the tuya smart application and tuyagateway. But both at the same time they do not work, how can I divide devices into those that I need in the application and those that are needed locally?

I installed the Add-On in HASS.IO and it worked fine. However, i don‘t understand how to config my device in GismoCaster. I have a plug with power measurement. It uses

dps 1 as switch,
dps 4 submits current Im mA,
dps 5 power in W and
dps 6 voltage in V *10
(signature {“1”:true,“2”:0,“4”:40,“5”:45,“6”:2280}).

I also have valid deviceID und localkey. Now i want to create 1 switch und 3 sensors in Home Assistant with GismoCaster. And it would be best, in the value for dps 6 could bei devided by 10 to expose the right V value to Home Assistant.

What steps are needed to create this devices with GismoCaster? I tried to create a gismomodel and than a gismo, however, i had no success. It just created a switch in HA, but no sensors.

It would be great, if someone could explain my the right way!

lots of people have this issue. technical it works and is all good, but the steps for a normal user are a bit too technicall I think, a few samples and hints are welcome and avoid questions.

Basically, and not meant to be an accusation but an observation, the author did a great job, from the software point of view, but from the manual side he practically said the program should be installed like this … end!

Both in this thread and in the wiki of gismocaster there are directions how to configure stuff. And yes at this point I assume you have some basic technical insight of HA. If you are a better documentation writer, please be my guest. I’m more than happy to put it on the wiki.

I think i have at least basic technical insight in HA, however,i don‘t really know how to set up GismoCaster. It would be nice to have ONE step-by-step guide for my mentioned use-case. I haben‘‘Tag found enough information in WIKI and thread, to handle this.

In HA > Devtools > MQTT listen to tuya/<device-id>/# When you toggle the switch you should receive a.../attributes message. I expect the needed values are in there. (but I don’t know, as described in the intital post I only have tuya switches)

edit: just did a small update v2.0.1 tuya/<device-id>/attributes now returns the raw status reply of the device.

Thanks, i understand this. But what is the use of the settings in GismoCaster? I think it would be the best way, if GismoCaster would create a topic for each DPS, in my example

DPS 1 tuya/<device-id>/<name_of_switch_in_gismo> e. g. plug_livingroom,
DPS 4 tuya/<device-id>/<name_of_sensor_in_gismo> e. g. plug_livingroom_current,
DPS 5 tuya/<device-id>/<name_of_sensor_in_gismo> e. g. plug_livingroom_consumption,

and so on.

And based on this config it should create a MQTT-Discovery-Message for each topic to create the HA devices for topics,

tuya/<device-id>/<name_of_dps1_in_gismo> a switch,
tuya/<device-id>/<name_of_dps4_in_gismo> a sensor with unit A
tuya/<device-id>/<name_of_dps5_in_gismo> a sensor with unit W.

I really don’t know, how to code such things, but in my opinion this would be the best solution. What do you think?

https://homieiot.github.io/ proposes a similar structure. I agreed mapping dp values in that way would be more intuitive, but this is not how HA handles components.

Why do you think, it a problem of HA? I work with Xiaomi’s Hygrothermographs in this way using the MQTT-Feature, see here. I had to create the MQTT-Discovery-Messages for each topic/sensor manually, but it works.

And, for example, the DAFANG Hacks Camera integration for Home Assistant works this way, as you can see here.

The only thing we need is that GismoCaster creates the corresponding MQTT-Topics and -Messages and fills them with the values fetched from tuya-devices :slight_smile:

For those devices that solution might work just fine. For other devices it might become problematic. See https://www.home-assistant.io/integrations/climate.mqtt/ for instance. How would you keep all those topics / settings / etc. grouped? Grouping might seem a minor issues when you have a few devices. But when you start adding more and more, it will become an unorderable mess. I’m not trying to reinvent the wheel here, just following the HA spec. So a device is defined by a component, just like you would declare a device in a yaml-file

Okay, i understand. So we will have only one topic called "tuya/<device_id>/state? How can i fill this topic with the dps-values? I need to create a JSON with 3 additional entries:

current:
consumption:
power:

with GismoCaster and GismoCaster has to assign the device values to them. Then i can create a MQTT-sensor in HA based on this values:

sensor:
  - platform: "mqtt"
    state_topic: "tuya/<device_id>"
    icon: "mdi:power"
    unit_of_measurement: "W"
    value_template: "{{ value_json.consumption }}"

Is that possible?

1 Like

I have a basic question: Can someone tell me how i run “npm i @tuyapi/cli -g” from HA? What addon do I need and how do I run the command? I have searched the forum for many hours now but I am stuck. Please help me! (I need to retract the localkey from tuya devices)

So we will have only one topic called "tuya/<device_id>/state ?

It depends on the device. If you have a 3 gang switch you would have 3 commands and states.

I need to create a JSON with 3 additional entries

With the update from yesterday you can pull the values from tuya/<device_id>/attributes

in tuya/<device_id>/<dp-key/attributes you’ll find some tuyagateway added values.

Did you end up adding your lights successfully @sjthespian?
I have a light that returns the same dps as yours. Attempting to set up with only state, brightness and color temp control to start with.
I previously could not get MQTT discovery to work (see https://github.com/TradeFace/tuyagateway/issues/76 for config, I’ve temporarily removed the default state topic values to get around this issue).
Now I have a device in Home Assistant with 3 completely non-functional light entities - one for each dps… which is clearly not correct.


How do I configure a single light entity that utilises multiple dps through GismoCaster?

By the way, thanks @Tradeface for developing TuyaGateway. I intend to document my setup once I get it working and share in this thread.

Probably easier if you do this from a different device (e.g. personal computer) as you’ll only need it once to get your device ids and localkeys.

can you explain to me what I have to do to get these attributes?