TuyaGateway v2.0 now available

kevin@tuyagateway:/etc/systemd/system$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.4 LTS
Release:        18.04
Codename:       bionic

I just pushed an initial version of the addon. You can find it at https://github.com/sjthespian/addon-tuyagateway. If you arenā€™t familiar with installing unofficial add-ons, you can find the instructions in DOCS.md in that repo. If you are running the mosquito add-on, you shouldnā€™t need any additional configuration.

I just found some ideas on running multiple processes in a single add-on (looking at how mosquito does it), so Iā€™m going to take a stab at adding Gismo Caster to this as well.

2 Likes

I was just looking at this thread this morning, and hoping an add-on would be available soon. Great timing!

I just added the repository, but it seems that something isnā€™t configured quite right. The repository doesnā€™t load up with a name, and once added, I donā€™t see TuyaGateway listed anywhere. Here is a screenshot of the repositories:

@mikeg1130 Fixed. I left out the json file that described the respository. Since Iā€™m testing locally, i didnā€™t need it.

If you delete the repo and add it back, it should populate the info now.

Looks good now. Iā€™ve got it installed and running. Now Iā€™ll see if I can figure out where to go from here in the docs.

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.