Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
KC868-A8 board esphome + Tuya
#1
Hello. I'm configuring the KC868-A8 board with Esphome and the Tuya license. However, I found some errors and would like to share them for a possible solution. KC868-A8 board esphome + Tuya
It's giving an error that I don't know exactly. error image attached.





# Basic Config
esphome:
  name: kc868-a8-contato-web-dht-tuya2
  platform: ESP32
  board: esp32dev

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

# Enable logging
logger:
  baud_rate: 0

api:
  encryption:
    key: "It2KB/xCg0EuwXMc1KyiTXRTSjr0hdQXmxQXnwIVmOE="

ota:
  - platform: esphome
    password: "70604538ddb4bdb4362c2d63114dfb1d"


i2c:
  sda: 4
  scl: 5
  scan: true
  id: bus_a


ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO17_OUT
  phy_addr: 0

  # Add web server
web_server:
  port: 80
  auth:
    username: admin
    password: "admin"

text_sensor:
  - platform: homeassistant
    name: "Casa Inteligente"
    id: home_assistant_text
    entity_id: input_text.test


pcf8574:
  - id: 'pcf8574_hub_out_1'  # for output channel 1-8
    address: 0x24

  - id: 'pcf8574_hub_in_1'  # for input channel 1-8
    address: 0x22


time:
  - platform: homeassistant
    id: homeassistant_time


# Individual outputs
switch:
  - platform: gpio
    name: "light1"
    id: light1
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 0
      mode: OUTPUT
      inverted: true
    restore_mode: RESTORE_DEFAULT_ON
    on_turn_on:
      - lambda: !lambda |-
          id(tuya_iot_component).property_report("output1", true);
    on_turn_off:
      - lambda: !lambda |-
          id(tuya_iot_component).property_report("output1", false);

  - platform: gpio
    name: "light2"
    id: light2
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 1
      mode: OUTPUT
      inverted: true
    restore_mode: RESTORE_DEFAULT_ON
    on_turn_on:
      - lambda: !lambda |-
          id(tuya_iot_component).property_report("output2", true);
    on_turn_off:
      - lambda: !lambda |-
          id(tuya_iot_component).property_report("output2", false);

  - platform: gpio
    name: "light3"
    id: light3
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 2
      mode: OUTPUT
      inverted: true
    restore_mode: RESTORE_DEFAULT_ON
    on_turn_on:
      - lambda: !lambda |-
          id(tuya_iot_component).property_report("output3", true);
    on_turn_off:
      - lambda: !lambda |-
          id(tuya_iot_component).property_report("output3", false);

  - platform: gpio
    name: "light4"
    id: light4
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 3
      mode: OUTPUT
      inverted: true
    restore_mode: RESTORE_DEFAULT_ON
    on_turn_on:
      - lambda: !lambda |-
          id(tuya_iot_component).property_report("output4", true);
    on_turn_off:
      - lambda: !lambda |-
          id(tuya_iot_component).property_report("output4", false);

  - platform: gpio
    name: "light5"
    id: light5
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 4
      mode: OUTPUT
      inverted: true
    restore_mode: RESTORE_DEFAULT_ON
    on_turn_on:
      - lambda: !lambda |-
          id(tuya_iot_component).property_report("output5", true);
    on_turn_off:
      - lambda: !lambda |-
          id(tuya_iot_component).property_report("output5", false);

  - platform: gpio
    name: "light6"
    id: light6
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 5
      mode: OUTPUT
      inverted: true
    restore_mode: RESTORE_DEFAULT_ON
    on_turn_on:
      - lambda: !lambda |-
          id(tuya_iot_component).property_report("output6", true);
    on_turn_off:
      - lambda: !lambda |-
          id(tuya_iot_component).property_report("output6", false);

  - platform: gpio
    name: "light7"
    id: light7
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 6
      mode: OUTPUT
      inverted: true
    restore_mode: RESTORE_DEFAULT_ON
    on_turn_on:
      - lambda: !lambda |-
          id(tuya_iot_component).property_report("output7", true);
    on_turn_off:
      - lambda: !lambda |-
          id(tuya_iot_component).property_report("output7", false);

  - platform: gpio
    name: "light8"
    id: light8
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 7
      mode: OUTPUT
      inverted: true
    restore_mode: RESTORE_DEFAULT_ON
    on_turn_on:
      - lambda: !lambda |-
          id(tuya_iot_component).property_report("output8", true);
    on_turn_off:
      - lambda: !lambda |-
          id(tuya_iot_component).property_report("output8", false);

binary_sensor:
  - platform: gpio
    name: "input1"
    on_press:
      then:
        - switch.toggle: light1
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 0
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "input2"
    on_press:
      then:
        - switch.toggle: light2
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 1
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "input3"
    on_press:
      then:
        - switch.toggle: light3
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 2
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "input4"
    on_press:
      then:
        - switch.toggle: light4
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 3
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "input5"
    on_press:
      then:
        - switch.toggle: light5
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 4
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "input6"
    on_press:
      then:
        - switch.toggle: light6
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 5
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "input7"
    on_press:
      then:
        - switch.toggle: light7
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 6
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "input8"
    on_press:
      then:
        - switch.toggle: light8
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 7
      mode: INPUT
      inverted: true


  - platform: gpio
    name: "a8-s3"
    pin:
      number: 32
      inverted: true

  - platform: gpio
    name: "a8-s4"
    pin:
      number: 33
      inverted: true

one_wire:
  - platform: gpio
    pin: GPIO14

sensor:
  - platform: dallas_temp
    name: "Temperatura QCC"
    id: temperatura_1
    address: 0x06136e7e1f64ff28  # Endereço específico do sensor
    accuracy_decimals: 1  # Precisão do sensor em casas decimais
    update_interval: 30s  # Intervalo de atualização dos dados

 
  - platform: dht
    pin: GPIO13  # Ajuste para o pino que você está usando
    model: DHT22  # Substitua pelo modelo do seu sensor (DHT11, DHT22, AM2301, etc.)
    temperature:
      name: "Temperatura externa"
    humidity:
      name: "Umidade externa"
    update_interval: 30s  # Ajuste o intervalo de atualização conforme necessário

tuya_iot:
  id: tuya_iot_component
  product_id: xxx
  device_id: xxx
  device_secret: xxx
  region: us # eu, us, eus, weu, in, cn
  # eu: Central Europe Data Center
  # us: US West Data Center
  # eus: US East Data Center
  # weu: Western Europe Data Center
  # in: India Data Center
  # cn: Chinese Data Center

  on_event:
    - event_name: property/set
      then:
        - lambda: !lambda |-
              // Append the required switch in switch_map to respond to commands issued by Tuya.
              static std::map<float, switch_::Switch*> switch_map {
                { 1, id(light1) },
                { 2, id(light2) },
                { 3, id(light3) },
                { 4, id(light4) },
                { 5, id(light5) },
                { 6, id(light6) },
                { 7, id(light7) },
                { 8, id(light8) },
              };
 ......>


Attached Files Image(s)
   
Reply
#2
tuya_iot:
id: tuya_iot_component
product_id: xxx
device_id: xxx
device_secret: xxx
region: us # eu, us, eus, weu, in, cn

in your code, xxx means replace with your tuya license information.
Reply
#3
Friend, I know that, I did the procedure on the license, however, that is not the problem. I posted the image of the error next to it. I would really like your help. ERROR --->

src/esphome/components/tuya_iot/tuya_iot_component.cpp: In the 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)>&'} of the expression of type 'esphome::tuya_iot::TuyaIotComponent:Confusedubscribe_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 the file included at src/esphome/core/string_ref.h:10, ....
Reply
#4
post your whole yaml file at here or send to email: web@kincony.com
Reply
#5
[anexo=6367]
(11-05-2024, 12:20 AM)administrador Wrote: publique seu arquivo yaml completo aqui ou envie para o e-mail: web@kincony.com

Vai o txt.


Attached Files
.txt   Esboço esphome +Tuya.txt (Size: 9.87 KB / Downloads: 23)
Reply
#6
Because ESPHome have updated, so we updated tuya component also.
just use new version will be ok.

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

switch to v1.2.1 , not use v1.2.0
Reply
#7
It worked, however, now I can't access the KC-868-A8 device. The lan port does not activate, nor does the wifi connect.
Reply
#8
connect ethernet cable with your router, after download re power on of your board, check in your router, whether can find KC868-A8 board.
Reply
#9
I did this procedure, I even use mikrotik router, I even check the logs. Both via WiFi and wired, they don't work. Even the LAN port LED doesn't light up
Reply
#10
now your yaml is config for ethernet, if you want config by wifi, need modify the yaml. you can modify change for wifi , test it. if also can't work, take a video send to us.
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)