logo elektroda
logo elektroda
X
logo elektroda

TuyaMCU flashing, setup and configuration guide - configure dpIDs for Home Assistant

p.kaczmarek2 13164 43
ADVERTISEMENT
📢 Listen (AI):
  • #31 21791988
    protectivedad
    Level 9  
    >>21791984

    I like powerSave, now. Regardless of what it does its purpose is to save power and the battery devices will work without it being on. But I'll do what you think is best.

    EDIT:
    Can you test it on a non-battery device? What does it do?

    EDIT AGAIN:
    Maybe you are right. I can see the confusion that will come from the perspective of non-battery powered devices using the command.
  • ADVERTISEMENT
  • #32 21791998
    p.kaczmarek2
    Moderator Smart Home
    PowerSave 1, in OBK, is used to reduce energy usage of OBK. So, by extension, users would think that once you enable TuyaMCU powersave, then you will get smaller energy usage. That's not accurate. They would be trying to enable it on any TuyaMCU device.
    Helpful post? Buy me a coffee.
  • #33 21792109
    protectivedad
    Level 9  
    >>21791998

    I've made the suggested changes the command is now tuyaMcu_batteryPoweredMode and it is ready to be released.
  • ADVERTISEMENT
  • #34 21792111
    p.kaczmarek2
    Moderator Smart Home
    Well, I guess it's acceptable. Thank you!

    Now, do we have a teardown for the device that requires it on our forum?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #35 21792142
    protectivedad
    Level 9  
    >>21792111

    I talk about the device here.
    protectivedad wrote:
    I purchased some ZY-D02 door sensors from AliExpress.


    I can rename the post and add some details with the new command once it is released. I will look at creating a template. One problem is that the "ZY-D02" devices have many different versions all the same name and they don't seem to be consistent. I've seen them mentioned a couple of times.

    daherbst85 wrote:
    I’m using the ZY-D02, which seems nearly identical to the D06 (mine uses a 2063P hall sensor and lacks the CB3S metal shield).

    They removed the TuyaMCU and directly wired the sensors to the WiFi module.

    meillagimeil wrote:
    I have this device ZY-D02-CB3S-V1.3, BK7231N, firmware 1.18.190.... and it's driving me nuts...

    They never got it working.
  • #36 21792144
    p.kaczmarek2
    Moderator Smart Home
    IF you have this device solved, please consider making a separate guide topic for it, so we can add it to our devices list here:
    https://openbekeniot.github.io/webapp/devicesList.html
    Helpful post? Buy me a coffee.
  • #37 21792369
    protectivedad
    Level 9  
    Is there a way for the tuyaMCU driver to be automatically loaded? One of the issues I noticed trying to program these TuyaMCU battery operated devices is that if the WiFi module doesn't talk to the TuyaMCU in the first few seconds the TuyaMCU will turn it off an on repeatedly. On initial programming this leads to the device AP showings up but never being able to connect to it because it is never available long enough to get the web page. I know there are solutions when flashing the device to change the OBK settings to include a startup command "backlog startDriver tuyaMCU;". I just think assigning the tuyaMCU driver to the RX/TX pins and using that to automatically load the driver is a more elegant solution. Which has the added benefit of documenting in the module screen that the device is a tuyaMCU.

    Has this been discussed or thought about before? I was looking for a solution which will make the battery operated devices easier to setup and test.
  • #38 21792372
    p.kaczmarek2
    Moderator Smart Home
    You are the first one to bring this topic. What would be the use case of that? In order to use TuyaMCU, you have to create autoexec.bat anyway, otherwise you can't map channels, so there is no reason to start TuyaMCU anywhere else, hm?
    Helpful post? Buy me a coffee.
  • #39 21792423
    protectivedad
    Level 9  
    >>21792372

    I get it. You need other stuff for it to function properly, but without the driver loading you can't get access to the battery device without taking it apart. So if you forget to create a backlog entry in the OBK on flash, or the autoexec.bat that loads the driver gets wiped, say on updating the firmware, you are taking the device apart. I also get that forgetting to assign the TuyaMCU to a dummy pin has the same problem, but I find remembering to make sure the pins are correct is more intuitive then looking at the Startup Command or the autoexec.bat. Especially when I am trying to access a device that is continually turning on and off.

    It was a bit of a learning curve which I think other new users can be saved if the driver is loaded automatically. How that would have been accomplished in other platforms is to assign the driver to a "dummy" pin. I mention the RX/TX (or just one) because we know they will never be used for anything else. I'm not actually saying use them in the driver. Just trigger driver loading.

    Having gone through the frustration of testing and pulling hair to figure out why all of a sudden my device is not accessible I use the "Startup Command" and NOT an autoexec.bat.

    So short answer, I think there is one main benefit:
    1) More resilient to firmware updates;
    - If you are using an autoexec.bat and it gets erase during a firmware update you will still be able to access the device through the AP.

    You already have drivers load based on assignment to a pin, so I figured adding the functionality would be simple. Add TuyaMCU to the pull down list and if it is assigned load the driver.

    Just a thought.
  • #40 21792464
    p.kaczmarek2
    Moderator Smart Home
    protectivedad wrote:

    I get it. You need other stuff for it to function properly, but without the driver loading you can't get access to the battery device without taking it apart.

    That's surely a new information. As far as I tested, I can keep up battery device AP or STA alive longer by pressing pair button many times, but I checked it in BK7231T/BK7231N era, when there was no sign of BK7238. Did something change, can you elaborate?
    Helpful post? Buy me a coffee.
  • #41 21792473
    protectivedad
    Level 9  
    p.kaczmarek2 wrote:
    That's surely a new information. As far as I tested, I can keep up battery device AP or STA alive longer by pressing pair button many times, but I checked it in BK7231T/BK7231N era, when there was no sign of BK7238. Did something change, can you elaborate?


    That's interesting. I don't think it has anything to do with the WiFi module, but the TuyaMCU implementation. I have only one type of TuyaMCU device. With my devices if the TuyaMCU has not communicated with the WiFi module (no heartbeat/product id) it will turn off and back on the WiFi module. Pressing the button (I tried it many times) will keep the TuyaMCU on, but the TuyaMCU will still turn the WiFi module on and off. Annoyingly, it leaves it on long enough that the AP looks solid, but the phone/computer will say can't connect. Only after I hooked up a voltmeter to the WiFi module power pins did I find out the TuyaMCU was cycling the power.

    When the driver runs it will send a heartbeat or ask for product information and at that point the TuyaMCU will start flashing the device LED and pressing the button will keep it alive. With my device holding it for 5+ seconds cause the TuyaMCU to keep the WiFi module powered for a while, but ONLY if the WiFi module has already sent a heartbeat/product ID request.

    I assumed they were all like that, but obviously not. I wonder if that is leading to some frustration on people trying to test the battery operated devices.

    So to test stop the driver from loading and see if the device LED flashes on a boot. Mine won't. Allow the driver to start and it will.
  • ADVERTISEMENT
  • #42 21793333
    p.kaczmarek2
    Moderator Smart Home
    Then why not use short startup command? In both cases it will be in two places...

    Adding THIRD place that can start TuyaMCU will only confuse people even more.
    Helpful post? Buy me a coffee.
  • #43 21793343
    protectivedad
    Level 9  
    p.kaczmarek2 wrote:
    Then why not use short startup command? In both cases it will be in two places...

    1) More elegant.
    2) Reduces the learning curve for new users used to Tasmota, like me.
    3) TuyaMCU detection and pin assignment can be added to GUI flasher again it is consistent with what the flasher already does.
    4) More efficient, reading a pin takes less resources than parsing a command.
    5) Documentation, you are documenting in the modules screen the pin is being used by the driver and you get double duty by using that to load the driver.

    p.kaczmarek2 wrote:
    Adding THIRD place that can start TuyaMCU will only confuse people even more.

    It's just a preference people used to looking in the modules page will put it there. People used to the startup will put it there. The idea is to automate the transition from the factory firmware to the use of OBK with as little chance to cause problems.

    The GUI flasher reads a device and assigns pins for most devices. The pin assignments cause drivers to automatically load. Why not try to make the TuyaMCU process as close to that as possible.

    Anyway, I think it will save people trouble let me know if you'd like me to close the https://github.com/openshwprojects/OpenBK7231T_App/pull/1919
  • #44 21793418
    p.kaczmarek2
    Moderator Smart Home
    Maybe... I didn't made final decision yet. One of the things I've been thinking about is adding live tuyamcu dpIDs preview to obk main http page.
    Helpful post? Buy me a coffee.
📢 Listen (AI):

Topic summary

The discussion provides a comprehensive guide on configuring TuyaMCU devices for cloudless operation with Home Assistant (HA). It emphasizes starting with research on the TuyaMCU protocol and official documentation before flashing devices, as some dpID extraction methods require unflashed devices. Multiple methods to obtain dpID lists are mentioned, including unpacking factory firmware and using Tuya API responses. Channel mapping is critical: OpenBeken firmware supports up to 64 channels, and channel numbers above 99 are unsupported in the GUI, so dpIDs must be mapped to valid channel numbers. Users can assign any dpID to any channel, allowing flexible configuration. Custom channel types such as toggles, text fields, and enums are used to represent device functions like temperature, humidity, battery status, and power. There is interest in creating custom channel types for complex dp values, such as multi-byte raw data representing multiple variables, with requests for types like Voltage_div10, Current_div10, Power_div10, and Percent_div10. Battery-powered devices require special handling to keep Wi-Fi active for configuration, with suggestions including safe mode activation and long button presses. The guide includes sample autoexec scripts demonstrating dpID-to-channel mapping and channel type assignments. The discussion also references tools like TuyaMCUAnalyzer and OpenBeken firmware for device integration and customization.
Summary generated by the language model.
ADVERTISEMENT