logo elektroda
logo elektroda
X
logo elektroda

Setting Up MOES BHT-006GBW Thermostat with ESPHome on BK7231T

malaysk 402 5
ADVERTISEMENT
  • #1 21488703
    malaysk
    Level 2  
    Hello everyone! I ask for your help with setting up Thermostat MOES BHT-006GBW. It had factory firmware Tuya 1.1.80. I reflashed it without any problems using tuya-cloudcutter using the configuration for 1.1.80 - BK7231T / bk7231t_common_user_config_ty.
    Reflashed to ESPHome-Kickstart-v23.08.29_bk7231t_app.ota.ug.bin and then using this config reflashed to ESPHome
    esphome:
      name: thermostat
      friendly_name: Thermostat
    
    bk72xx:
      board: generic-bk7231t-qfn32-tuya
      framework:
        version: dev
    
    logger:
      baud_rate: 0
      level: debug
    
    api:
    
    ota:
      platform: esphome
    
    wifi:
      networks:
      - ssid: !secret wifi_ssid_1
        password: !secret wifi_password_1
        priority: 2
      - ssid: !secret wifi_ssid_2
        password: !secret wifi_password_2
        priority: 1
      ap:
        password: !secret wifi_password_1
    
    captive_portal:
    
    web_server:
    
    time:
      - id: time_provider
        platform: homeassistant
        on_time_sync:
          - logger.log: "Synchronized system clock"
        on_time:
          - seconds: 0
            then:
              - uart.write: [0x55, 0xaa, 0x00, 0x21, 0x00, 0x00, 0x20] #0x21 (Send weather data)
              - uart.write: [0x55, 0xaa, 0x00, 0x20, 0x00, 0x02, 0x01, 0x00, 0x22] # 0x20 (Enable weather services) 0x01 (success) 0x00 (no error)
              - uart.write: [0x55, 0xaa, 0x00, 0x34, 0x00, 0x02, 0x03, 0x00, 0x38] # 0x34 (Proactively request weather data) 0x03 (subcommand) 0x00 (success)
              - logger.log: "Disabling weather requests"
    
    uart:
      rx_pin: P10
      tx_pin: P11
      baud_rate: 9600
    
    tuya:
      time_id: time_provider
    
    climate:
      - platform: tuya
        name: "Thermostat"
        icon: mdi:heating-coil
        switch_datapoint: 1
        target_temperature_datapoint: 2
        current_temperature_datapoint: 3
        preset:
          eco:
            datapoint: 5
        temperature_multiplier: 0.5
        visual:
          min_temperature: 10 °C      
          max_temperature: 45 °C      
          temperature_step: 0.5 °C
    
    switch:
      - platform: tuya
        name: "Power"
        icon: mdi:power
        switch_datapoint: 1           
        internal: True                
    
      - platform: tuya
        name: "Economy Mode"
        icon: mdi:leaf
        switch_datapoint: 5
    
      - platform: tuya
        name: "Panel Lock"
        icon: mdi:lock
        switch_datapoint: 6      
    
    select:
      - platform: tuya
        name: "Program Schedule"
        icon: "mdi:calendar"
        enum_datapoint: 4
        options:
          0: Schedule
          1: Manual
    
    sensor:
      - platform: "tuya"
        name: "Temperature"
        sensor_datapoint: 3
        unit_of_measurement: "°C"
        device_class: "temperature"
        accuracy_decimals: 1
        filters:
          - multiply: 0.5
        # The climate component already includes temperature, but having the
        # temperature as a separate sensor can be useful
        disabled_by_default: true
    
      # The external temperature sensor, if wired
      - platform: "tuya"
        name: "Temperature (external)"
        sensor_datapoint: 102
        unit_of_measurement: "°C"
        device_class: "temperature"
        accuracy_decimals: 1
        filters:
          - multiply: 0.5
        disabled_by_default: true


    And the thermostat works great.
    BUT.... I really want to reflash it to the OpenBeken firmware for bk7231t, but I don't know how to set it up correctly later, since it uses TuyaMCU. Please, can anyone tell me how to import the ESPHome config into OpenBeken and how to correctly register it in the firmware settings?

    [/code]
  • ADVERTISEMENT
  • #2 21488868
    p.kaczmarek2
    Moderator Smart Home
    Interesting, it looks like they hardcoded TuyaMCU packets?

    Well, the first step is usually here:
    TuyaMCU guide

    In your case, most of the settings seem to be already known. Baud is known (9600), UART port is standard, dpIDs are known... I think we could easily start with a basic autoexec.bat like in the guide and build from there.

    Even if something is missing, then i'm here to help.

    So, is OBK flashed already or not?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 21488896
    malaysk
    Level 2  
    Thanks for your reply!
    Yes, I OBK flashed -
    Chipset: BK7231T

    Build: Built on Mar 17 2025 07:40:59 version 1.18.62

    I'm trying to create an autoexec.bat , but so far it's not working :-)
    I've inserted the following code as an example:
    startDriver TuyaMCU
    tuyaMcu_setBaudRate 9600
    tuyaMcu_defWiFiState 4
    
    //get initial status
    tuyaMcu_sendState 191 2 16
    
    //link tuya output to OBK channels
    linkTuyaMCUOutputToChannel 1 bool 1
    linkTuyaMCUOutputToChannel 2 val 2
    linkTuyaMCUOutputToChannel 3 val 3
    linkTuyaMCUOutputToChannel 5 bool 5
    linkTuyaMCUOutputToChannel 6 bool 6
    linkTuyaMCUOutputToChannel 101 bool 7
    linkTuyaMCUOutputToChannel 102 bool 8
    
    //set OBK channel types
    setChannelLabel 1 "Power"
    setChannelType 1 Toggle
    setChannelLabel 2 "Temperature"
    setChannelType 2 temperature
    setChannelLabel 3 "Temperature (external)"
    setChannelType 3 temperature
    setChannelLabel 5 "Economy Mode"
    setChannelType 5 Toggle
    setChannelLabel 6 "Panel Lock"
    setChannelType 6 Toggle
    
    //aliases for state saving in the tuyaMCU
    alias SAVE1 backlog tuyaMcu_sendState 191 2 103; tuyaMcu_sendState 192 2 1; tuyaMcu_sendState 193 2 1
    alias NOSAVE1 backlog tuyaMcu_sendState 191 2 103; tuyaMcu_sendState 192 2 1; tuyaMcu_sendState 193 2 0
    alias SAVE2 backlog tuyaMcu_sendState 191 2 103; tuyaMcu_sendState 192 2 2; tuyaMcu_sendState 193 2 1
    alias NOSAVE2 backlog tuyaMcu_sendState 191 2 103; tuyaMcu_sendState 192 2 2; tuyaMcu_sendState 193 2 0
    alias SAVE3 backlog tuyaMcu_sendState 191 2 103; tuyaMcu_sendState 192 2 3; tuyaMcu_sendState 193 2 1
    alias NOSAVE3 backlog tuyaMcu_sendState 191 2 103; tuyaMcu_sendState 192 2 3; tuyaMcu_sendState 193 2 0
    alias SAVE5 backlog tuyaMcu_sendState 191 2 103; tuyaMcu_sendState 192 2 5; tuyaMcu_sendState 193 2 1
    alias NOSAVE5 backlog tuyaMcu_sendState 191 2 103; tuyaMcu_sendState 192 2 5; tuyaMcu_sendState 193 2 0
    alias SAVE6 backlog tuyaMcu_sendState 191 2 103; tuyaMcu_sendState 192 2 6; tuyaMcu_sendState 193 2 1
    alias NOSAVE6 backlog tuyaMcu_sendState 191 2 103; tuyaMcu_sendState 192 2 6; tuyaMcu_sendState 193 2 0
    alias SAVE7 backlog tuyaMcu_sendState 191 2 103; tuyaMcu_sendState 192 2 7; tuyaMcu_sendState 193 2 1
    alias NOSAVE7 backlog tuyaMcu_sendState 191 2 103; tuyaMcu_sendState 192 2 7; tuyaMcu_sendState 193 2 0
    
    //change handlers on every state change
    addChangeHandler Channel1 == 1 SAVE1
    addChangeHandler Channel1 == 0 NOSAVE1
    addChangeHandler Channel2 == 1 SAVE2
    addChangeHandler Channel2 == 0 NOSAVE2
    addChangeHandler Channel3 == 1 SAVE3
    addChangeHandler Channel3 == 0 NOSAVE3
    addChangeHandler Channel5 == 1 SAVE5
    addChangeHandler Channel5 == 0 NOSAVE5
    addChangeHandler Channel6 == 1 SAVE6
    addChangeHandler Channel6 == 0 NOSAVE6

    The temperature is shown exactly 2 times higher (look at the screenshot, it shows 24 and 40 degrees, but it should be 12 and 20 degrees)
    And I don’t know how to add temperature control.
    OpenBK7231T system user interface displaying temperature and status information.
  • ADVERTISEMENT
  • #4 21489013
    p.kaczmarek2
    Moderator Smart Home
    When setting channel type for temperature, try using Temperature_div2 instead of Temperature.

    What exactly do you mean by control? I haven't yet looked precisely into this device. Do you mean a field where you can write a temperature?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 21489271
    malaysk
    Level 2  
    p.kaczmarek2 wrote:
    Do you mean a field where you can write a temperature?

    Yes, I can't write the commands correctly to record the new set temperature.
    Unfortunately, I couldn't find an example of autoexec.bat specifically for the thermostat (has anyone really connected thermostats to OBK?)
    Here are all the dpIDs for the thermostat - https://github.com/tuya-cloudcutter/tuya-clou...s/tuya-generic-bht-002gb-wifi-thermostat.json
    This is what my autoexec.bat looks like now
    startDriver TuyaMCU
    tuyaMcu_setBaudRate 9600
    tuyaMcu_defWiFiState 4
    
    setChannelLabel 1 "Power"
    setChannelType 1 Toggle
    linkTuyaMCUOutputToChannel 1 bool 1
    
    setChannelLabel 2 "Target temperature"
    setChannelType 2 Temperature_div2
    linkTuyaMCUOutputToChannel 3 val 2
    
    setChannelLabel 3 "Current temperature"
    setChannelType 3 Temperature_div2
    linkTuyaMCUOutputToChannel 102 val 3
    
    setChannelLabel 4 "Program Schedule"
    setChannelType 4 TextField
    linkTuyaMCUOutputToChannel 4 enum 4
    
    setChannelLabel 5 "Economy Mode"
    setChannelType 5 Toggle
    linkTuyaMCUOutputToChannel 5 bool 5
    
    setChannelLabel 6 "Panel Lock"
    setChannelType 6 Toggle
    linkTuyaMCUOutputToChannel 6 bool 6


    I'm also interested in how I can transfer to Home Assistant via mqtt?
    climate:
      - platform: tuya
        name: "Thermostat"
        icon: mdi:heating-coil
        switch_datapoint: 1
        target_temperature_datapoint: 2
        current_temperature_datapoint: 3
        preset:
          eco:
            datapoint: 5
        temperature_multiplier: 0.5
        visual:
          min_temperature: 10 °C      
          max_temperature: 45 °C      
          temperature_step: 0.5 °C   

    Now Home Assistant only shows the sensor and switches, I can’t even change the temperature.


    Thermostat interface with various settings, including current temperature, power, economy mode, and panel lock.
    Thank you!

    Added after 49 [minutes]:

    I managed to make a command to set a new temperature.

    // set temperature
    setChannelLabel 2 "New Temperature"
    setChannelType 2 Temperature_div2
    linkTuyaMCUOutputToChannel 102 val 2

    // currenttemperature
    setChannelLabel 3 "Current Temperature"
    setChannelType 3 TextField
    linkTuyaMCUOutputToChannel 2 val 3

    Unfortunately there is no choice of slider command for temperature, as for example for dimmer - Dimmer, Dimmer256 and Dimmer1000.
    For example SetTemp, SetTemp_div2, SetTemp_div10 etc.

    User interface of OpenBK7231T temperature management system.
  • #6 21491205
    p.kaczmarek2
    Moderator Smart Home
    That's a good progress. For the temperature, can you check mult usage?
    Full mapping command syntax:
    
    linkTuyaMCUOutputToChannel [dpId] [varType] [channelID] [bDPCache] [mult] [inv] 
    

    If you set mult to 2, then if you have 20 in OBK channel it should send 40 to TuyaMCU, maybe? It will probably strip floating point, but we can solve it next.
    Helpful post? Buy me a coffee.
ADVERTISEMENT