msillano / TuyaUIweb

Local WEB interface to monitor Tuya, with data export for subsequent processing.
MIT License
1 stars 0 forks source link
cloud csv datalogger devices export-csvfile export-json iot json local monitoring openapi2 portable tuya tuyacloud ui user-interface webapp windows

Elevate Your Tuya Device Monitoring Experience

versione italiana

This complete and dynamic solution organizes all your devices, rooms, and homes in an intuitive tree structure within a web browser. Each node in the tree has an informative tooltip with real-time updated values of the device's properties, giving you a complete and immediate overview of your Tuya ecosystem.

To ensure maximum security, TuyaUIweb operates exclusively in read-only mode, without making any changes to your data on Tuya Cloud.

Developed using vis-network and the TuyaCloud v2 API, TuyaUIweb represents a significant step forward in monitoring and managing your Tuya devices.

Features:

At-a-glance overview of the entire situation.
In the initial phase, all necessary data is read from Tuya Cloud and a local structure is built containing ALL the information. The visualization tree graph is built based on this information.

Real-time updates.
Data updates are polled: they are read from the TuyaCloud with a frequency that can be set by the user, from 30 seconds to a few minutes, and the popups are updated immediately.

Logging and data export.
It is possible to export some data to a file: the user must specify home, device, and status (properties) to identify the data of interest and these are saved at regular intervals (minimum 1 minute) in an internal buffer (max 5000 records = 80h @1rec/min), then exported to a file, either automatically or at user command.

Customizable look and feel. This open-source program, in HTML+Javascript, is fairly well documented and modular. Therefore, any intervention is possible, allowing you to adapt the program to individual needs.

Normal and expert mode. In 'expert mode' (since VER 1.2) in the tooltip of each device there is also the 'category' of the device (in plain text), the 'device_id' (device.id), and the 'secret_key' (device.local_key). This information is very useful for users of TuyaDEAMON or similar HUBs like HA.
In 'expert mode', a command is available to put the entire data structure obtained from Tuya Cloud in the console: it can be explored at each level in the console pad or copied with copy and paste in JSON format.

Implementation notes

Safety NOTE

This APP is totally open, without any protection, and contains your credentials in clear text in the files!
DO NOT make it accessible from the outside or by third parties, otherwise, all your data, including Tuya credentials, are exposed!


Versions

Installation

1) Download and unzip the TuyaUIweb.1.x.zip file to a directory (with the permissions required by the operating system). 2) Perform the configuration operations. 3) The main file is tuyaui.html. A WEB server is not required: as the code is all in JavaScript, TuyaUIweb is executed by the browser. To launch it, see the goTuyaUI.bat file (for Windows, Chrome). For other operating systems/browsers, create a similar script.
note: Ignore the Chrome message: "You are using an unsupported command line flag: - disable-web-security...": unsupported but working. 4) During installation and setup, the console is useful (in the browser - developer tools -, or menu 'inspect element') because the information and error messages of TuyaUIweb go there. On the left startup OK (Chrome, CORS disabled) on the right CORS error case (Opera):

normal start CORS error

Configuration

This APP is for experienced users, therefore it is acceptable that the configuration is done directly by editing a file (config.js).

Customizations

Two areas have been highlighted and related functions are placed in a separate file (custom.js) for user editing simplicity, with detailed instructions and examples:

Custom icons
Tuya no longer allows you to change the icons, due to a questionable interpretation of its current copyright laws by its legal advisors. In TuyaUIweb I have chosen the 'awesome4' icons, with a wide choice and free to use. To customize them, the user must provide a selection criterion and an indication of the icon to use. By default, for example, they have special icons (see images):

Customization of tooltip content
Depending on the device, not all properties in Tuya status are useful:

CSV format

This is an example of a log file in CVS format:

[date, time, ROMA.TF_frigo.va_temperature, ROMA.Temperatura studio.va_temperature]
[2024-05-17, 06:35:28, 71, 22]
[2024-05-17, 06:37:28, 71, 22]
... more ...

The first row contains the column headers, the following rows contain the data. The operations to do are the following (in an ASCII editor, for example, Notepad++, with 'global find&replace'): 1) Remove the square bracket '[' at the beginning of each line. 2) Replace the final square bracket with a semicolon ';'.

The correct CVS result is the following, which can be imported into many DBs and spreadsheets:

date, time, ROMA.TF_frigo.va_temperature, ROMA.Temperatura studio.va_temperature;
2024-05-17, 06:35:28, 71, 22;
2024-05-17, 06:37:28, 71, 22;
... more ...

JSON format

This is an example of a log file in JSON format:

[{"home":"ROMA","device":"TF_frigo","status":"va_temperature","result":70,"day":"2024-05-17","time":"19:37:51"},
 {"home":"ROMA","device":"Temperatura studio","status":"va_temperature","result":25,"day":"2024-05-17","time":"19:37:51"}],
[{"home":"ROMA","device":"TF_frigo","status":"va_temperature","result":70,"day":"2024-05-17","time":"19:39:51"},
 {"home":"ROMA","device":"Temperatura studio","status":"va_temperature","result":25,"day":"2024-05-17","time":"19:39:51"}],

Note that all identifying data is added to each measurement, resulting in a more verbose result than the CVS case. The operations to do are the following (in an ASCII editor, for example Notepad++): 1) Add a pair of square brackets '[]' to enclose all content.

The correct JSON result is the following, which can be used with JSON parsers to recreate the objects:

[
[{"home":"ROMA","device":"TF_frigo","status":"va_temperature","result":70,"day":"2024-05-17","time":"19:37:51"},
 {"home":"ROMA","device":"Temperatura studio","status":"va_temperature","result":25,"day":"2024-05-17","time":"19:37:51"}],
[{"home":"ROMA","device":"TF_frigo","status":"va_temperature","result":70,"day":"2024-05-17","time":"19:39:51"},
 {"home":"ROMA","device":"Temperatura studio","status":"va_temperature","result":25,"day":"2024-05-17","time":"19:39:51"}],
]

It is an array of arrays containing the individual measurements (objects).


MIT License

This project is a work-in-progress: it is provided "as is", without warranties of any kind, express or implied.

Thank you for your interest in TuyaUIweb
m.s.


Acknowledgments