# Improvements of the xAAL Home Automation System
## 5 The xAAL Communication Protocol
### Alternative Home Automation Protocols over IP
#### 5.7.5 Tuya  
Tuya is a business-to-business IoT company [46]. It does not sell home automation by itself (or very few), but provides services for other companies to propose their own devices to consumers. Tuya has about 75 major companies and about 93,000 small or medium companies as clients, over 200 countries, for about 90,000 compatible products [47; 48]. Tuya is one of the preferred technical solutions for low-cost IoT devices. An extremely large number of home automation and IoT products use the Tuya proprietary technology as backend. Everything is 'Tuya-compatible'. Tuya therefore presents itself as an interoperability solution. Well, a dominance industrial position can hardly be seen as a real interoperability solution.  
The service provided by Tuya is in three parts. The heart of its service is a cloud platform: compatible devices can connect to it, send data to it, and receive commands from it. The second part is a generic mobile application for consumers to get control of their device via the Tuya platform (the _Tuya Smart Life App_), as well as REST API for companies to develop their specific mobile application on top the Tuya platform. The third part of Tuya services is to provide a code for developers of companies, to be embedded in their devices. For this, developers are invited to enroll in the Tuya program, to describe their device (functions, data type, commands, etc.). In return, Tuya provides keys to access the platform and a piece of programming code to be embedded in a dedicated Tuya electronic chip, which has an integrated WiFi module. Companies develop their product around the chip and the code provided by Tuya. The code opens a TCP socket from the device at home towards the Tuya cloud platform. The users data goes on the Tuya cloud platform. The Tuya cloud platform control Tuya devices at home, send commands, update firmware remotely, etc.  
Tuya is a very popular solution with many devices sold. As a consequence, it has been widely studied, via reverse-engineering processes due to the lack of open documentation, either for checking its security [49; 50], either to develop alternative compatible applications [51].  
Tuya devices communicate with their servers via HTTP (or HTTPS, depending on the Tuya version) for configuration and key exchange. Then command control of devices is performed with MQTT, the messages of which may be encrypted using AES-128 (depending on the Tuya version). Security is performed by a symmetrical key, which is configured by the Tuya company and pushed to users' devices and application. Parallel to cloud communications, Tuya devices accept local communications with a similar shape of protocol, allowing mobile applications of the user to control devices locally without a go-and-back in the clouds. Messages are in JSON format. Parameters are passed as a map of registers named \"1\" \"2\", etc. in which the meaning is not specified and corresponds somehow to what the developer has set up while listing the functions of its device. There is no formal specification of devices. Tuya controls the whole chain (electronic devices, cloud services, end-user applications); so there is no need to provide specifications of anything. Tuya is widely deployed, but suffers from safety, security and privacy issues.