logo elektroda
logo elektroda
X
logo elektroda

Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942

p.kaczmarek2 90534 372
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #91 20529001
    p.kaczmarek2
    Moderator Smart Home
    The discussion about new devices with BL0942 not receiving any data (while my old LSPA9 still works - probably a different connection on PCB is the issue) has been moved here:
    OpenBeken - new BL0942 device is not receiving any data from energy meter
    Those new devices are not even in LSPA9 form, so let's keep it in the separate topic so people can google the issue. Thanks!
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #92 20545305
    mminkov
    Level 5  
    kokskrustnagla wrote:
    Hello,
    I am new in this project. I need some information. I flash 2 devices BK7231N CB2S Model: 4B2-39G1-01 ZN366877_01 with openbk7231N_1.15.452. But one of this device did not shows total consumption. In the front page I se Total consumption=inf Wh.
    I try to reset, calibrate the voltage but nothing change. Below I added photo. Maybe You have some solution for that.
    Best regards Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942

    I too use same socket, but variable "energycounter_last_hour" is 0 and not change, please tell something
  • #93 20548059
    p.kaczmarek2
    Moderator Smart Home
    Hello @mminkov , do you have NTP running? Do you have energy stats enabled?

    Here is an example short startup command for BL0942 socket:
    
    backlog startDriver BL0942; SetupEnergyStats 1 30 120 1; startDriver NTP; ntp_timeZoneOfs 1
    
    Helpful post? Buy me a coffee.
  • #94 20552058
    Nargo
    Level 22  
    After programming and connecting, it shows
    Energy Total per kWh
    in the nest tab and in HA
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942 Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
  • #95 20552079
    p.kaczmarek2
    Moderator Smart Home
    The topic has already been discussed, you can clear the counter:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    EnergyCntReset
    Let me know if it helped.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #96 20552154
    Nargo
    Level 22  
    Thanks. Works.
    I didn't read the thread properly.
    And it's a pity that the documentation is only in English, it's hard to read for a person with little knowledge of a foreign language.
  • #98 20554515
    p.kaczmarek2
    Moderator Smart Home
    Hello, please post a picture of this device.
    Here is the OBK template (Web App -> Import and paste it there, then accept):
    Code: JSON
    Log in, to see the code

    Verbal description:
    - Relay (channel 1) on P26
    - WiFi LED on P6
    - Button (channel 1) on P10
    - BL0937 ELE on P7
    - BL0937 VI on P8
    - BL0937 SEL on P24

    Check if it works, because I'm not sure if I have swapped pins of BL0937.
    Helpful post? Buy me a coffee.
  • #99 20554529
    piratee
    Level 13  
    I will add that you do not need to desolder the chip plate, just connect to VCC, GND RX and TX.

    Photos Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942 Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942 Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942 [img-3] [img-4] Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942 [img-6]

    Added after 26 [minutes]:

    When confirming the configuration, I get a message
    Switching on the relay from the button and it works programmatically, I'm checking the measurement right now

    edit:
    Energy measurement is working properly.
    Thank you for your help.

    Build on Apr 25 2023 08:12:33 version 1.17.47

    script execution log:
    Send started... send 0/12... send 1/12... send 2/12... send 3/12... send 4/12... send 5/12... send 6/ 12... send 7/12... send 8/12... send 9/12... send 10/12...FAILED! Invalid command "StartupCommand".
  • #100 20555763
    piratee
    Level 13  
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942 Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942 Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942 Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942 To już ciekawostka, gniazdko bez pomiaru energii CB2S

    P8 -WiFiLED
    P10 -Btn
    P26-Rel

    konfiguracja:
    {
    "vendor": "Tuya",
    "bDetailed": "0",
    "name": "Full Device Name Here",
    "model": "enter short model name here",
    "chip": "BK7231N",
    "board": "TODO",
    "flags": "1024",
    "keywords": [
    "TODO",
    "TODO",
    "TODO"
    ],
    "pins": {
    "8": "WifiLED;1",
    "10": "Btn;1",
    "26": "Rel;1"
    },
    "command": "startDriver NTP",
    "image": "https://obrazki.elektroda.pl/YOUR_IMAGE.jpg",
    "wiki": "https://www.elektroda.com/rtvforum/topic_YOUR_TOPIC.html"
    }
  • #101 20555768
    p.kaczmarek2
    Moderator Smart Home
    Is it some new device? You need to provide some photo and information what it is if we want to add it to the list of templates.
    Helpful post? Buy me a coffee.
  • #102 20555773
    piratee
    Level 13  
    I already pasted the configuration and photos.
    I'm uploading photos from my phone, the rest from my computer.
    Therefore, a little in installments.
    A no name socket cost PLN 13.

    Added after 14 [minutes]:

    Two questions:
    1. Is it possible to make the undo menu at the top and bottom?
    It's about this line:
    "Return to cfg | Read more | Devices List | Commands | Support project"
    Always less mouse scrolling :)
    2. can it be done programmatically so that if we click from the "Restart" application, it does not disconnect and connect the relay?
  • ADVERTISEMENT
  • #103 20557270
    p.kaczmarek2
    Moderator Smart Home
    In every possible menu, would you like undo at the top? Only in options? And where/how exactly?

    It is rather impossible for the reboot not to disconnect the relay, unless even in the case of the option with state memory, and such a short moment when the firmware starts up is long enough that the relay loses power for a moment and opens.
    Helpful post? Buy me a coffee.
  • #104 20557279
    piratee
    Level 13  
    It seems to me that it would be enough only in the configuration in the first 2 groups, i.e.:
    "Configure Module"
    "Configure General/Flags"
    Because the lists are long and you have to scroll down.
    But that's just mine I see.
    I would care more about an alternative network and DS18B20 temperature measurement.
  • #105 20557383
    p.kaczmarek2
    Moderator Smart Home
    Let's start with the alternative SSID. How is it supposed to behave? After how long after failed connection attempts with the first SSID should it try to connect to the second?
    Helpful post? Buy me a coffee.
  • #106 20557406
    piratee
    Level 13  
    For me, maybe after 5 tries I think that's enough
  • ADVERTISEMENT
  • #107 20557412
    p.kaczmarek2
    Moderator Smart Home
    It would be counted in seconds.
    Helpful post? Buy me a coffee.
  • #108 20557416
    piratee
    Level 13  
    I am indifferent to the method of implementation, I am willing to test
  • #109 20558767
    mminkov
    Level 5  
    piratee wrote:
    DS18B20 temperature measurement.

    I interesting too... alternative SSID needed when moving device in 2 places on long distance, where APs is diferent, and lose time to preconfigure
  • #110 20561916
    Dark Man
    Level 13  
    I would like to add a new command to change the display in the GUI and sending the precision of the results via MQTT:
    Voltage 253.2V
    Current 0.000A
    Active Power 0.0W
    Apparent Power 0.0VA
    Reactive Power 0.0 var
    PowerFactor 1.00
    Energy Today 0.0 Wh
    Energy Yesterday 0.2 Wh
    Energy Total 8.197 kWh
    so that instead of giving the energy consumed in Wh, it can be immediately converted into kWh with one decimal place.

    This is dictated by the fact that other smart sockets that I have on ESP from Tasmot always send in kWh and I have universal automations to many sockets in Node-red calculated per kWh.

    It would also be helpful to limit/round the results to e.g. 1 decimal place - because accuracy to 6 decimal places is not so necessary :)
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
    Thanks

    P.S
    This voltage on the dump is correctly shown and at night without the operation of photovoltaics - such are my jumps.
  • #111 20562072
    piratee
    Level 13  
    @.:Darkman:.
    I at Home Assistsnt moved the comma in the template.
    But the option is good to be able to move the decimal point.
    It should be noted that, for example, for voltage you have to cut the numbers and for energy divide by 1000 to get it in kWh. Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
  • #112 20562139
    Dark Man
    Level 13  
    I would not like to create new sensors using a template, so it would be useful to set the precision at the OpenBeken level
  • #113 20562546
    p.kaczmarek2
    Moderator Smart Home
    Dark Man wrote:

    It would also be helpful to limit/round the results to e.g. 1 decimal place - because accuracy to 6 decimal places is not so necessary :)
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
    Thanks


    I can very easily add this to you from the built-in Home Assistant Discovery:
    
    val_tpl {{ float(value)|round(3) }}
    

    This is the value_template for Home Assistant rounded to 3 places, I haven't checked how well it works yet, but maybe it would work?

    Of course, there is also the question of how many places we round up to. It's best to choose the number of seats rigidly, it's the easiest way.
    Helpful post? Buy me a coffee.
  • #114 20562748
    piratee
    Level 13  
    I have this template for this socket:
    Of course, the name G5 and unique are by. my needs

    Templates:
    - sensor:
    - name: "G5 Energy kWh"
    unique_id: "temp_1"
    unit_of_measurement: "kWh"
    state: "{{ ( states('sensor.g5_energy' ) | float / 1000 ) | round(3) }}"
    - sensor:
    - name: "G5 Energy today kWh"
    unique_id: "temp_2"
    unit_of_measurement: "kWh"
    state: "{{ ( states('sensor.g5_energy_today' ) | float / 1000 ) | round(3) }}"
    - sensor:
    - name: "G5 Energy yesterday kWh"
    unique_id: "temp_3"
    unit_of_measurement: "kWh"
    state: "{{ ( states('sensor.g5_energy_1h' ) | float / 1000 ) | round(3) }}"
    - sensor:
    - name: "G5 Power kW"
    unique_id: "temp_4"
    unit_of_measurement: "kW"
    state: "{{ ( states('sensor.g5_moc' ) | float / 1000 ) | round(3) }}"
    - sensor:
    - name: "G5 Voltage V"
    unique_id: "temp_5"
    unit_of_measurement: "V"
    state: "{{ states('sensor.g5_voltage' ) | round(3) }}"
    - sensor:
    - name: "G5 Current I"
    unique_id: "temp_6"
    unit_of_measurement: "I"
    state: "{{ states('sensor.g5_prad' ) | round(3) }}"
  • #115 20562802
    p.kaczmarek2
    Moderator Smart Home
    I can do exactly the same on the Hass Discovery side of yours and then you will automatically have it. Without writing yaml by hand.

    Only @piratee why always round(3)? Voltage up to 3 decimal places until you need?

    I have a virtual socket here on BL0942, we'll try to work something out:
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
    This is what it looks like:
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
    And after changes with an example rounding it looks like this:
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
    Would such a solution suit you? Ew. for voltage e.g. less decimal places
    Helpful post? Buy me a coffee.
  • #116 20562810
    piratee
    Level 13  
    I somehow rounded up 3 places out of habit. For current and voltage it can be 2.
    But let colleague @dark Mansia do the talking.

    Ps
    In the second discharge, the power is W, not kW
  • #117 20562946
    Dark Man
    Level 13  
    According to me it should be like this:
    Voltage - to integers
    Power - W unit, to one decimal place
    Current - unit A, to two decimal places
    all Energycounter entities - kWh unit, to two decimal places
    From what I remember, it sends Tasmota and it is sufficient :)
  • #118 20563182
    p.kaczmarek2
    Moderator Smart Home
    So opinions are divided. I added the VCPPrecision command that allows you to specify how many decimal places there are for different values separately, along with the default setting:
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
    I can't rather change the OBK publishes from Wh to kWh at the very level. This would break current users' systems. Ew. I could add to Discovery the ability to change the unit with a flag or something similar.
    Helpful post? Buy me a coffee.
  • #119 20564219
    Dark Man
    Level 13  
    p.kaczmarek2 wrote:
    I could add to Discovery the ability to change the unit with a flag or something similar

    Great idea!
    In that case, please add a flag so that after selecting it, the sensor units are sent in the Tasmot style with their default precisions (example below) and the VCPPrecision command itself could possibly change the accuracy of the given values.
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942
  • #120 20565858
    piratee
    Level 13  
    When the change with the number of digits after the decimal point will be introduced (I am asking out of curiosity), I have a free mini switch with measurement - I can test on it
    Is it possible to change the time of data publication after mqtt - I can't find it?

    I noticed one more thing that after reboot the state of "channel"=1 is 0.0 instead of 1
    Build on May 1 2023 06:08:19 version 1.17.77
    When I turn it on and off it does 1.
    Restart misreads the state of the relay.
    Tuya LSPA9 smart socket - teardown, OpenBeken flashing guide for CB2S, BL0942

Topic summary

The discussion revolves around the Tuya LSPA9 smart socket, focusing on its teardown, flashing OpenBeken firmware, and configuring the BL0942 energy metering chip. Users share their experiences with various versions of the LSPA9, including issues with calibration, communication protocols (UART vs. SPI), and the stability of energy readings. Solutions include using specific commands for calibration, adjusting baud rates, and troubleshooting connectivity issues. The conversation also touches on the integration of these devices with Home Assistant and the challenges faced in ensuring accurate power measurements and MQTT communication.
Summary generated by the language model.
ADVERTISEMENT