logo elektroda
logo elektroda
X
logo elektroda

[Solved] Tuya Smart Breaker with OpenBK: MQTT Integration for HomeAssistant Energy, Voltage, Power, Toggle

lubopetrov 192 6
ADVERTISEMENT
  • #1 21589316
    lubopetrov
    Level 2  
    I need help with Tuya smart circuit breaker flashed with OpenBK. How to MQTT to HomeAssistant consuption,voltage,power and control Toggle function?
    here is my autoexec
    
    // Start TuyaMCu driver
    startDriver TuyaMCU
    // set TuyaMCU baud rate
    //tuyaMcu_setBaudRate 115200
    // set TuyaMCU default wifi state 0x04, which means "paired",
    // because some TuyaMCU MCUs will not report all data
    // unless they think they are connected to cloud
    tuyaMcu_defWiFiState 4
    
    setChannelType 1 EnergyTotal_kWh_div100
    setChannelType 2 toggle
    // linkTuyaMCUOutputToChannel dpId verType tgChannel
    linkTuyaMCUOutputToChannel 16 bool  2
    // set voltage, current ,power channel types
    setChannelType 3 Voltage_div10
    setChannelType 4 Current_div1000
    setChannelType 5 Power
    // map dpID 6, which is VCP format, to first voltage, then current, then power (3, 4, 5)
    linkTuyaMCUOutputToChannel 6 RAW_V2C3P3  3
    
    // map dpID 1, which is energy, to channel 1
    linkTuyaMCUOutputToChannel 1 val 1
    
    

    json:
    
    
      {
        "id": 109,
        "type": 3,
        "data": "AAAA"
      },
      {
        "id": 106,
        "type": 3,
        "data": "EwAAAAAAAAAAAA=="
      },
      {
        "id": 105,
        "type": 2,
        "data": 0
      },
      {
        "id": 104,
        "type": 1,
        "data": 1
      },
      {
        "id": 102,
        "type": 2,
        "data": 5
      },
      {
        "id": 107,
        "type": 2,
        "data": 10
      },
      {
        "id": 18,
        "type": 0,
        "data": "01010276"
      },
      {
        "id": 12,
        "type": 1,
        "data": 0
      },
      {
        "id": 13,
        "type": 2,
        "data": 0
      },
      {
        "id": 11,
        "type": 1,
        "data": 0
      },
      {
        "id": 9,
        "type": 5,
        "data": "00"
      },
      {
        "id": 111,
        "type": 4,
        "data": 0
      },
      {
        "id": 1,
        "type": 2,
        "data": 25
      },
      {
        "id": 6,
        "type": 206,
        "data": "0931000000000000"
      },
      {
        "id": 16,
        "type": 1,
        "data": 1
      }
    
  • ADVERTISEMENT
  • #2 21589425
    p.kaczmarek2
    Moderator Smart Home
    OpenBeken supports automatic Home Assistant Discovery. It should work well once you have already set the channel types. Follow this guide:


    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 21589456
    lubopetrov
    Level 2  
    I already have MQTT set. The problem is that it is showing some data, but not the one I'm interested in. I need power consumption, voltage and power, but instead I see this.
    Tuya Smart Breaker with OpenBK: MQTT Integration for HomeAssistant Energy, Voltage, Power, Toggle
  • #4 21589608
    p.kaczmarek2
    Moderator Smart Home
    p.kaczmarek2 wrote:
    OpenBeken supports automatic Home Assistant Discovery. It should work well once you have already set the channel types.

    Home Assistant Discovery configures Home Assistant to show channel types you have set when you do Discovery. If you add some new channels or remove them, you need to do Home Assistant Discovery again. You may also need to manually remove first device from HA.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 21589715
    lubopetrov
    Level 2  
    Thank you. It worked.
  • ADVERTISEMENT
  • #6 21589716
    lubopetrov
    Level 2  
    I removed and re-added the device. Now it appears in my HomeAssistant under MQTT devices
  • #7 21589829
    p.kaczmarek2
    Moderator Smart Home
    Btw, Some people just use:
    
    scheduleHADiscovery 10
    

    in the startup command to automatically do HA discovery with 10 seconds when MQTT connects.
    Helpful post? Buy me a coffee.

Topic summary

The discussion addresses integrating a Tuya smart circuit breaker flashed with OpenBK firmware into Home Assistant via MQTT to monitor energy consumption, voltage, power, and control toggle functions. The user shared an autoexec script configuring TuyaMCU channels for energy, toggle, voltage, current, and power, including mapping TuyaMCU data points (dpIDs) to Home Assistant channels. The main issue was incomplete data visibility in Home Assistant despite MQTT setup. The solution involved using OpenBeken's automatic Home Assistant Discovery feature, which requires re-running discovery after modifying channel configurations and possibly removing the device from Home Assistant before re-adding it. Additionally, a startup command `scheduleHADiscovery 10` can automate Home Assistant discovery 10 seconds after MQTT connection, ensuring proper device and channel recognition.
Summary generated by the language model.
ADVERTISEMENT