TuyaGateway v2.0 now available

I just pushed out a new version of the add-on that includes GismoCaster and auto-provisions the MQTT settings from either the installed broker or the settings in the add-on.

1 Like

Also tried with the add-on, it gives me this result and as always admin: admin doesn’t work …

[10:30:25] INFO: Start GismoCaster daemon
2020-07-31 10:30:26,059 DEBUG (Thread-1) [paho.mqtt.client] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b’’
2020-07-31 10:30:26,834 DEBUG (Thread-1) [paho.mqtt.client] Received CONNACK (0, 0)
2020-07-31 10:30:26,834 INFO (Thread-1) [tuyagateway.configure] MQTT Connection state: Connection successful for topic tuyagateway/#
2020-07-31 10:30:26,835 DEBUG (Thread-1) [paho.mqtt.client] Sending SUBSCRIBE (d0, m1) [(b’homeassistant/#‘, 0), (b’tuyagateway/#’, 0)]
2020-07-31 08:30:26,868 DEBUG [asyncio] Using selector: EpollSelector
2020-07-31 08:30:26,880 WARNING [mqtt.mqtt] () Failed to connect to MQTT Broker Setting matching query does not exist.
2020-07-31 10:30:26,926 DEBUG (Thread-1) [paho.mqtt.client] Received SUBACK
2020-07-31 10:30:26,927 DEBUG (Thread-1) [paho.mqtt.client] Received PUBLISH (d0, q0, r1, m0), ‘homeassistant/light/0x00158d00032cae16/light/config’, … (525 bytes)
2020-07-31 10:30:26,930 DEBUG (Thread-1) [paho.mqtt.client] Received PUBLISH (d0, q0, r1, m0), ‘homeassistant/sensor/0x00158d00032cae16/linkquality/config’, … (511 bytes)
2020-07-31 10:30:26,931 DEBUG (Thread-1) [paho.mqtt.client] Received PUBLISH (d0, q0, r1, m0), ‘homeassistant/sensor/0x00158d00010414c5/action/config’, … (452 bytes)
2020-07-31 10:30:26,933 DEBUG (Thread-1) [paho.mqtt.client] Received PUBLISH (d0, q0, r1, m0), ‘homeassistant/sensor/0x00158d00010414c5/battery/config’, … (474 bytes)
2020-07-31 10:30:26,935 DEBUG (Thread-1) [paho.mqtt.client] Received PUBLISH (d0, q0, r1, m0), ‘homeassistant/sensor/0x00158d00010414c5/linkquality/config’, … (483 bytes)
2020-07-31 10:30:26,936 DEBUG (Thread-1) [paho.mqtt.client] Received PUBLISH (d0, q0, r1, m0), ‘homeassistant/sensor/0x00124b001e728880/linkquality/config’, … (534 bytes)
2020-07-31 10:30:26,937 DEBUG (Thread-1) [paho.mqtt.client] Received PUBLISH (d0, q0, r1, m0), ‘homeassistant/switch/0x00124b001e728880/switch/config’, … (561 bytes)
[31/Jul/2020 08:31:12] “GET / HTTP/1.1” 200 818
[31/Jul/2020 08:31:12] “GET /static/css/styles.css HTTP/1.1” 404 1672
[31/Jul/2020 08:31:14] “GET /admin/ HTTP/1.1” 302 0
[31/Jul/2020 08:31:14] “GET /admin/login/?next=/admin/ HTTP/1.1” 200 6098
[31/Jul/2020 08:31:21] “POST /admin/login/?next=/admin/ HTTP/1.1” 200 6438
2020-07-31 10:31:27,005 DEBUG (Thread-1) [paho.mqtt.client] Sending PINGREQ
2020-07-31 10:31:27,006 DEBUG (Thread-1) [paho.mqtt.client] Received PINGRESP
2020-07-31 10:32:27,079 DEBUG (Thread-1) [paho.mqtt.client] Sending PINGREQ
2020-07-31 10:32:27,080 DEBUG (Thread-1) [paho.mqtt.client] Received PINGRESP

Thank you for adding the add-on feature, I was struggling to establish it via docker. I have it set up and gismocaster is working fine!

I need to add devices now

I’m stuck at localkey

Yes, there is a big gap in the docs on how to use - it is a great idea.

I found this tutorial (Starting at step 5) to be the easiest to follow for getting the localkey.

https://plugins.hoobs.org/plugin/homebridge-tuya-lan

2 Likes

I updated the add-on, ad was able to get gismocaster up and running. I’ve created a gismo model and a gismo for the Treatlife plugs I am trying to connect. But I guess I’m kind of stuck. I’m not sure what to put for the Dp values. And how do I get these discovered in HA?

From the logs, it appears that the plug is being discovered by TuyaGateway. But not sure what the next step is.

5.A.4 in the link you posted gives you the (dp)keys. You should add those to the gismo model. And set the publish_topic, in accordance with https://www.home-assistant.io/docs/mqtt/discovery/. For most keys their function can be deduced from the value it holds. For others you can try and change the value in smartlife app and see which value changed. It is a bit of a tedious task I’m afraid, but that is the best we have at the moment.

Thanks for the point in the right direction! I give it all a shot.

Making progress. I’ve been able to get the dps values via the Tuya-cli. Updated the gismo model accordingly, and now the plugs are showing I’m HA. However, after a few minutes, they go to unavailable. Is this because I haven’t set an availability topic? Any idea what I should set there?

If the state value is true/false, would I keep that set as boolean in the gismo model?

The TreatLife plugs I’m working with are simple on/off, with no power monitoring, for what its worth.

Anyone have tips on converting the DPs I see with tuya-cli to something HA can use? For example, here’s what I get from my generic RGBWW bulbs (with some comments):

{
  devId: 'xxxx',
  dps: {
    '20': false,                # on/off
    '21': 'white',              # white/color
    '22': 990,                  # level (0-100%) * 10
    '23': 967,                  # color temp 0:warm, 1000: cool
    '24': '008703e803de',       # color?
    '25': '000e0d0000000000000000c80000',       # ?
    '26': 0                     # ?
  }
}

I’m pretty sure that I need to add 20 as a light/state_topic, 22 as light/brightness_state_topic and 23 as light/white_value_state_topic.

I think 24 is the HSV color value. It looks like it is an HSV value with the first pair of bytes being the hue in the rage of 0-360 and the second being saturation and value ranging from 0-1000. How the heck do I represent that in GismoCaster?

Do I even need to do anything with 21? It seems to be an indicator of whether the bulb is in white or color mode and I’m not sure if I need to set it. I don’t see an obvious topic to use for it.

And I have no idea what DPs 25 and 26 are for, I have yet to see them change. Any ideas?

1 Like

2020-07-31 10:30:26,834 INFO (Thread-1) [tuyagateway.configure] MQTT Connection state: Connection successful for topic tuyagateway/#

2020-07-31 08:30:26,880 WARNING [mqtt.mqtt] () Failed to connect to MQTT Broker Setting matching query does not exist.

Please i’m stuck

Availability topic is set automatically (if it is in the HA model). Apparently the connection to the device is lost some how. Tuya devices have all kinds of quirks. Some devices seem to lock up (deny connection) when you reconnect too quickly. This might be the problem in this case.

When you restart tuyagateway does the device become available again?

21 might be a readonly. 
24 there are not post processing functions available yet. In GC set it as string and process it in HA
25 not a clue
26 might be a timer function, not directly supported by HA. (Of course you could try to alter it with an automation)

You’re getting all kinds of strange errors. I suspect something went awefully wrong in your install. Perhaps it is best to start over.

This time I used the add-on, reinstalled all twice same warning… Can the fact that I’m under docker influence?

I can’t tell… are all the needed ports open? Can you connect with e.g. telnet from your docker to mqtt-broker? Did you configure the mqtt settings in both GC and TG correctly?

First step taken checked the doors both 1883 and 8111 are open

same warning

WARNING [mqtt.mqtt] () Failed to connect to MQTT Broker Setting matching query does not exist.

the addon have no setting, it takes them directly from hassio, and they work because i use it for zigbee2mqtt

I would try standing it up by itself if you have somewhere else to run it just to make sure it isn’t a problem with the addon. It should be getting the settings from HA though.

You should see something like this as almost the first line in the add-on log:

2020-07-31 17:24:22,499 INFO     (Thread-1) [tuyagateway.configure] MQTT Connection state: Connection successful for topic tuyagateway/# 

I had already tried with the normal installation and it gave me the same problem, either by installing it where I have HA, or by using a raspberry pi ZERO

[12:08:09] INFO: Start GismoCaster daemon
2020-08-02 12:08:10,359 DEBUG (Thread-1) [paho.mqtt.client] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b’’
2020-08-02 12:08:11,173 DEBUG (Thread-1) [paho.mqtt.client] Received CONNACK (0, 0)
2020-08-02 12:08:11,173 INFO (Thread-1) [tuyagateway.configure] MQTT Connection state: Connection successful for topic tuyagateway/#
2020-08-02 12:08:11,174 DEBUG (Thread-1) [paho.mqtt.client] Sending SUBSCRIBE (d0, m1) [(b’homeassistant/#‘, 0), (b’tuyagateway/#’, 0)]
2020-08-02 12:08:11,175 DEBUG (Thread-1) [paho.mqtt.client] Received SUBACK
2020-08-02 10:08:11,303 DEBUG [asyncio] Using selector: EpollSelector
2020-08-02 10:08:11,315 WARNING [mqtt.mqtt] () Failed to connect to MQTT Broker Setting matching query does not exist.

Is it normal for SUBACK to return without codes?

My HA config:

External Url: https://xxxxxxx.duckdns.org:8123
Internal Url: http://192.168.1.xxx:8123

Anyway for completeness I have the installation of HA in docker under Debian in a NUC

what else can I check? Since the add-on takes the mqtt settings directly from the Mosquitto addon?