Openhab tuya-mqtt installaton of a Tuya Smart WIFI Wireless Security Alarm Siren

I want to pair a KERUI Tuya Smart WIFI Wireless Security Alarm System Siren 433Mhz bought on aliexpress with some aqara sensors. This might be achieved using with tuya-mqtt

Aqara devices will be connected thru zigbee2mqtt with a sonoff dongle and tied to the Alarm siren.

I am expecting the sonoff dongle in a week from now.

Meanwhile in a docker version of openhab I would like to implement the tuya-mqtt installaton of the siren.

I am making my first steps as a newcomer with openhab docker version.

My first question for now is about the procedure to install tuya-mqtt. Is the following thread a good guide to do so?

My second question is more about implementing tuya-mqtt without scraping my docker openhab and zigbee2mqtt containers. What I should not do?

One of the main purposes of MQTT and containers is isolation. OH doesn’t know or care about zigbee2mqtt. OH doesn’t know or care about Tuya to MQTT. Zigbee2mqtt, Mosquitto, and Tuya to MQTT don’t know or care about OH. You can add new services, remove services, change services out and none of that should impact the others beyond configuration changes if the MQTT topics or messages themselves change (adding a new tuya to mqtt service is almost certainly going to create a bunch of new topics that OH needs to subscribe and publish to).

The MQTT Broker is the only commonality between all of these. They all need to know where the broker is and they need to know what to publish and subscribe. That’s it.

Unless you’ve done something really weird with your setup, adding tuya 2 mqtt shouldn’t impact any of the other running containers one bit. You just need to add configuration to OH (i.e. Things) to subscribe and publish to the new MQTT topics.

The same idea applies to the containers. They isolate the services from the host and from each other. There’s nothing you do in one container that should require you to scrap other existing containers unless you are using some sort of antipattern in how you are deploying your containers.

@rlkoshak
Thanks for the advice.

I am trying to find my way. And it seems that there is a path.

I have installed the MQTT-Binding from the gui (xx.x.x.xx.local:8080/settings/)

Working with openhab from docker, I go from the command line to the gui.

I am trying to implement the following:

open services/mqtt.cfg and uncomment/fill the following paramaters:

broker.url=tcp://localhost:1883
broker.clientId=openhab
broker.user=openhab

Command line mode, I thought that I would fine the .config files in my home folder or from thunar in the folder tree. It is not there. Where would it be?
/home/fl/openhab/conf/

By far the easiest way to install and configure add-ons is to do so through MainUI. Adding Things - Advanced | openHAB from the Getting Started tutorial covers installing and configuring the MQTT binding from end-to-end through the UI.

I don’t know what docs you are looking at but OH’s MQTT binding hasn’t worked like that for many many years. See the link above but at a high level:

  1. Install the MQTT Binding
  2. Manually create an MQTT Broker Thing
  3. If the MQTT is discoverable by OH (see the MQTT docs) go to the Inbox and select MQTT and run a scan. If not, create one or more Generic MQTT Things (one per logical device) and add Channels for each sensor or actuator.

You can do this in text files too. I personally don’t recommend starting out that way because it raises the learning curve tremendously and you’ll be spending tons of time just fighting syntax errors and researching what property to put where in what file. But if you choose to ignore that advice, you’ll create the MQTT Broker Thing and MQTT Generic Things in a file ending in “.things” in the “conf/things” folder. See the MQTT add-on docs for the syntax and examples for these files.

In the UI, you get a nice form and just need to fill in the properties. Almost everything you do through the UI gets saved to userdata/jsondb.

I went to the Main ui as you proposed.

  • mqtt binding is installed and I see it
  • -Settings > Add-on settings
  • mqtt broker thing has a problem, ERROR COM message

Should I also additionnaly intall mqtt explorer?

What do you propose?
Thanks.

MQTT is not HTTP. It is not an HTTP URL.

The broker has a host property which is the IP address or hostname of the machine where the MQTT broker is running. It has a separate port property where you supply the port if you are not using the default port of 1883.

Yes, of course. It’s the best way to independently see the topics and message traffic.

The host name is my computer

fl@Satellite-Z930:~$ hostname -i
127.0.1.1
fl@Satellite-Z930:~$

I still have the same error message.

127.0.0.1 is a special IP address. It means “localhost”. When using 127.0.0.1 (or any IP address starting with 127) you are basically saying "do not use the actual network, just stay on this machine.

But OH is running inside a container and container have their own IP stack. 127.0.0.1 from OH’s perspective is a different machine from 127.0.0.1 from the host machine’s perspective. That means 127.0.0.1 points to the container, not the host and not the Mosquitto container.

hostname -i almost always returns 127.0.0.1. Per the man page for hostname

   -i, --ip-address
          Display the network address(es) of the host name. Note that this works only if the host name can be resolved. Avoid using this option; use hostname --all-ip-addresses instead.

So just use hostname which will give the human readable name of the host (which I’m betting is “Satellite-Z930” based on your prompt. Or use hostname --all-ip-addresses to see all the IP addresses assigned to this machine.

The one you need will most likely be the one that starts with 192 (e.g. 192.168.1.25) or 10 (e.g. 10.10.1.25).

Do not use the IP address that starts with 172 (e.g. 172.0.17.1). That’s the internal Docker IP address.

The really long IP address that also includes letters is the IP v6 address. That might work too if you want to try that.

Use the hostname first. If that doesn’t work, go through the IP addresses until one works. The first one will almost certainly work though.

Nothing works, I have tried the thre following propositions, I could not find the IP v6 address:
10.0.0.54
hostname
Satellite-Z930

fl@Satellite-Z930:~$ hostname --all-ip-addresses
10.0.0.54 172.18.0.1 172.17.0.1 
fl@Satellite-Z930:~$ hostname
Satellite-Z930
fl@Satellite-Z930:~$ ip -6 addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 state UNKNOWN qlen 1000
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
3: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000
    inet6 fe80::c8c2:679d:8c04:610e/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
4: br-2c1c9f1f28f1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 state DOWN 
    inet6 fe80::3883:50ff:fe04:3c57/64 scope link 
       valid_lft forever preferred_lft forever
fl@Satellite-Z930:

Logs?

Are you sure mosquitto is up and running on that machine?

My fault, mosquitto was stopped.

fl@Satellite-Z930:~$ docker restart mosquitto
mosquitto

The hostname that works is:
10.0.0.54

It works now!

Thanks so much!

Listing Tuya devices by linking your mobile phone TUYA app to a TUYA developper account.
Linking a Tuya device (here I have modified and formatteed the original text for clarity)
https://github.com/codetheweb/tuyapi/blob/master/docs/SETUP.md
Devices that you want to use must be registered in either the Tuya Smart app or the Smart Life app.

  1. Create a new account
    [https://iot.tuya.com/] Select WesternUnited States as your country (other data location do not seem to work).
  2. Then Cloud > Development in the (left navigation panel). You will have to agree “purchase” the Trial Plan toproceed. The purchase is of no charge and no form of payment is required. Once in the Projects tab, click “Create”, select “Smart Home” for “Industry” field and select "Smart Home"the development method.** Select WesternUnited States for location access option, and feel free to skip the services option in the next window. After you’ve created a new project, click open project. The “Access ID/Client ID” and “Access Secret/Client Secret” are the API Key and API Secret values need in step 7.
  3. Then Cloud > Development > open project “MyProject”(in Project management > Service API (center tab)>Go to authorize (right tab). “Select API” > click subscribe on “IoT Core”, “Authorization”, and click subscribe on “Smart Home Scene Linkage” in the dropdown and to all other subcription in black (also check your PopUp blocker). Click “basic edition” and “buy now” (basic edition is free). Check if the 3 services are listed under Cloud → Projects → “MyProject” → API. If not, click “Add Authorization” and select them.
  4. Select Cloud > Development > open project “MyProject”. Then click the “Devices” tab. Click the “Link Tuya App account” tab, and select Western America Data Center.
  5. Click “Add App Account” and scan the QR code from within your smart phone/tablet tuya app selecting the QR code. Your account will now be linked and as a result you will see your devices within the TUYA developper account that you have created.
  6. On the command line, run tuya-cli wizard. It will prompt you for required information, and will then list out all your device names, IDs, and keys for use with TuyAPI. Copy and save this information to a safe place for later reference.

Finally, the tuya api is good for finding devices not only for tuya but for smart life appolications too. And what else?

(post deleted by author)

And the result from the tuya-cli wizard is:

fl@Satellite-Z930:~$ sudo tuya-cli wizard
[sudo] password for fl: 
? The API key from tuya.com: xxxxxxxxxx
? The API secret from tuya.com xxxxxxxxxx
? Provide a 'virtual ID' of a device currently registered in the app: ebe3f2702d4d56589apk6f
[
  {
    name: 'Multifunction alarm',
    id: 'ebe3f2702d4d56589apk6f',
    key: 'lZVey4T2nk[lhh[p'
  },
  {
    name: 'Thermostat mezzanine ',
    id: 'eb5c81b7ce01a2ec03dfar',
    key: "y+?5NWH&r'?RbtrI"
  },
  {
    name: 'Relais WIFI et Timer',
    id: 'eb74a206398a79ba5d6yji',
    key: 'vRtz`+B.KjIJQys.'
  }
]
fl@Satellite-Z930:~$

And I found a docker version of tuya-mqtt
https://github.com/mwinters-stuff/tuya-mqtt-docker?tab=readme-ov-file#readme

to be continued as I have to debug the docker version of tuya-mqtt