Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom ESPHome firmware and Tuya integration
#21
(08-05-2024, 08:27 AM)admin Wrote: if you use ESPHome, we have yaml demo for tuya , but that is only use for KinCony's product.

I have a Kincony A6 for controlling my hybrid heating system. My Warm water boiler is connected via a Tuya smart plug that I want to switch on and off depending on specific usage needs (volumes, temperature, measured by the kincony).
I fould on github the esphome-tuya-iot library but it does not really do what I need.
How ca I use the Tuya API to control from my esphome implementation on the A6 the tuya smart plug? Is there any way to use or tweak the custom_component esphome for this purpose?
Reply
#22
what function you want to do? can you take an example? such as you want to use A6 board sensor to control your tuya smart plug? or ...?
Reply
#23
I measure temperatures and other modbus data with the A6 and depending of the temperature levals, I want to activate (switch on/off) a tuya smart plug that measures the energy for the hot water production.
Optionally reading also the plug's data for energy consumption
Reply
#24
download KCS firmware for KC868-A6, set the tuya license, so that KC868-A6 can work with tuya app. Then set AUTOMATION in tuya app, let KC868-A6 work with other tuya product.
Reply
#25
Hi,
I have the same problem as the initial question, but didn't find any solution given for it - A6 controller - setting up Tuya IO integration lib in custom ESPHome YAML code.
With all setup done - like in the demo video (https://www.youtube.com/watch?v=M_B8ln2-llY) - added external_components, tuya_iot setup (product_id: xxx, device_id: xxx, device_secret: xxx and region: eu are set with the provided by email IDs/secret etc. as well as switch_map and its number); on all switches on_turn_on and on_turn_off code is added to all relays with changed "outputX" number...

When trying to install the code to the board, I get same error: invalid initialization of reference of type 'const json_parse_t&' - here is the complete dump:

Code:
src/esphome/components/tuya_iot/tuya_iot_component.cpp: In lambda function:
src/esphome/components/tuya_iot/tuya_iot_component.cpp:167:96: error: invalid initialization of reference of type 'const json_parse_t&' {aka 'const std::function<bool(ArduinoJson6185_D1::ObjectRef)>&'} from expression of type 'esphome::tuya_iot::TuyaIotComponent::subscribe_json(const string&, const mqtt_json_callback_t&, uint8_t)::<lambda(const string&, const string&)>::<lambda(ArduinoJson::JsonObject)>'
         json::parse_json(payload, [topic, callback](JsonObject root) { callback(topic, root); });
                                                                                                ^
In file included from src/esphome/core/string_ref.h:11,
                 from src/esphome/core/entity_base.h:5,
                 from src/esphome/components/sensor/sensor.h:4,
                 from src/esphome/components/adc/adc_sensor.h:3,
                 from src/esphome.h:3,
                 from src/esphome/components/tuya_iot/tuya_iot_component.h:3,
                 from src/esphome/components/tuya_iot/tuya_iot_component.cpp:1:
src/esphome/components/json/json_util.h:26:6: note: in passing argument 2 of 'bool esphome::json::parse_json(const string&, const json_parse_t&)'
bool parse_json(const std::string &data, const json_parse_t &f);
      ^~~~~~~~~~
*** [.pioenvs/hankerila-a6/src/esphome/components/tuya_iot/tuya_iot_component.cpp.o] Error 1

Could you point me out to what could be the problem. Am I missing something?
Reply
#26
Hi,
I found the solution for the parse_json error - there is a fix version of the Tuya IOT lib - v1.2.1 which needs to be specified in the setup of the external_components:
url: https://github.com/hzkincony/esphome-tuya-iot
ref: v1.2.1 # not v1.2.0 as in the readme
Reply
#27
we suggest to download KCS v2 firmware, then set tuya license in webpage, it will be very easy.
Reply
#28
Try custome code
# Basic Config
esphome:
name: kc868-a6-test
friendly_name: KC868_A6_Test

external_components:
- source:
type: git
url: https://github.com/hzkincony/esphome-tuya-iot
ref: v1.2.1

esp32:
board: esp32dev
framework:
type: arduino


src/esphome/components/tuya_iot/tuya_iot_component.cpp: In member function 'virtual void esphome::tuya_iot::TuyaIotComponent::update()':
src/esphome/components/tuya_iot/tuya_iot_component.cpp:292:19: error: 'esp_mqtt_client_config_t' {aka 'struct esp_mqtt_client_config_t'} has no member named 'username'
292 | mqtt_cfg_.username = username;
| ^~~~~~~~
In file included from src/esphome/core/component.h:8,
from src/esphome/core/application.h:7,
from src/esphome/components/api/api_frame_helper.h:12,
from src/esphome/components/api/api_connection.h:5,
from src/esphome.h:3,
from src/esphome/components/tuya_iot/tuya_iot_component.h:3,
from src/esphome/components/tuya_iot/tuya_iot_component.cpp:1:
src/esphome/components/tuya_iot/tuya_iot_component.cpp:293:49: error: 'esp_mqtt_client_config_t' {aka 'struct esp_mqtt_client_config_t'} has no member named 'username'
293 | ESP_LOGD(TAG, "username: %s", mqtt_cfg_.username);
| ^~~~~~~~
src/esphome/core/log.h:99:100: note: in definition of macro 'esph_log_d'
99 | ::esphome::esp_log_printf_(ESPHOME_LOG_LEVEL_DEBUG, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__)
| ^~~~~~~~~~~
src/esphome/components/tuya_iot/tuya_iot_component.cpp:293:9: note: in expansion of macro 'ESP_LOGD'
293 | ESP_LOGD(TAG, "username: %s", mqtt_cfg_.username);
| ^~~~~~~~
src/esphome/components/tuya_iot/tuya_iot_component.cpp:297:19: error: 'esp_mqtt_client_config_t' {aka 'struct esp_mqtt_client_config_t'} has no member named 'password'
297 | mqtt_cfg_.password = password_str;
| ^~~~~~~~
src/esphome/components/tuya_iot/tuya_iot_component.cpp:298:49: error: 'esp_mqtt_client_config_t' {aka 'struct esp_mqtt_client_config_t'} has no member named 'password'
298 | ESP_LOGD(TAG, "password: %s", mqtt_cfg_.password);
| ^~~~~~~~
src/esphome/core/log.h:99:100: note: in definition of macro 'esph_log_d'
99 | ::esphome::esp_log_printf_(ESPHOME_LOG_LEVEL_DEBUG, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__)
| ^~~~~~~~~~~
src/esphome/components/tuya_iot/tuya_iot_component.cpp:298:9: note: in expansion of macro 'ESP_LOGD'
298 | ESP_LOGD(TAG, "password: %s", mqtt_cfg_.password);
| ^~~~~~~~
src/esphome/components/tuya_iot/tuya_iot_component.cpp:302:19: error: 'esp_mqtt_client_config_t' {aka 'struct esp_mqtt_client_config_t'} has no member named 'uri'
302 | mqtt_cfg_.uri = uri;
| ^~~
src/esphome/components/tuya_iot/tuya_iot_component.cpp:303:19: error: 'esp_mqtt_client_config_t' {aka 'struct esp_mqtt_client_config_t'} has no member named 'cert_pem'
303 | mqtt_cfg_.cert_pem = tuya_cacert_pem;
| ^~~~~~~~
src/esphome/components/tuya_iot/tuya_iot_component.cpp:304:19: error: 'esp_mqtt_client_config_t' {aka 'struct esp_mqtt_client_config_t'} has no member named 'cert_len'
304 | mqtt_cfg_.cert_len = sizeof(tuya_cacert_pem);
| ^~~~~~~~
src/esphome/components/tuya_iot/tuya_iot_component.cpp:305:19: error: 'esp_mqtt_client_config_t' {aka 'struct esp_mqtt_client_config_t'} has no member named 'skip_cert_common_name_check'
305 | mqtt_cfg_.skip_cert_common_name_check = true;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/tuya_iot/tuya_iot_component.cpp:306:19: error: 'esp_mqtt_client_config_t' {aka 'struct esp_mqtt_client_config_t'} has no member named 'use_global_ca_store'
306 | mqtt_cfg_.use_global_ca_store = false;
| ^~~~~~~~~~~~~~~~~~~
src/esphome/components/tuya_iot/tuya_iot_component.cpp:308:19: error: 'esp_mqtt_client_config_t' {aka 'struct esp_mqtt_client_config_t'} has no member named 'protocol_ver'
308 | mqtt_cfg_.protocol_ver = MQTT_PROTOCOL_V_3_1_1;
| ^~~~~~~~~~~~
src/esphome/components/tuya_iot/tuya_iot_component.cpp:311:19: error: 'esp_mqtt_client_config_t' {aka 'struct esp_mqtt_client_config_t'} has no member named 'client_id'
311 | mqtt_cfg_.client_id = client_id;
| ^~~~~~~~~
Compiling .pioenvs/kc868-a6-test/src/esphome/components/web_server_base/web_server_base.cpp.o
*** [.pioenvs/kc868-a6-test/src/esphome/components/tuya_iot/tuya_iot_component.cpp.o] Error 1
========================= [FAILED] Took 403.43 seconds =========================
Reply
#29
do you want KC868-A6 work with tuya app by ESPHome?
Reply
#30
(10-12-2025, 11:17 PM)admin Wrote: do you want KC868-A6 work with tuya app by ESPHome?

Yes
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)