logo elektroda
logo elektroda
X
logo elektroda

BK7231T - WB3S UME Outdoor Security Floodlight: Motion-Activated LED, PIR Sensor, CW Lights

mbetter 2703 43
ADVERTISEMENT
  • Helpful post
    #1 20764976
    mbetter
    Level 5  
    This is a motion-activated outdoor LED floodlight.

    LED floodlight with two light panels and a motion sensor.

    It features a W3BS module, two CW LED lights, a PIR motion sensor, and an ambient light sensor.

    Close-up view of W3BS electronic module with wires soldered to pins. Close-up of an internal module with wires inside an LED floodlight.

    I was able to solder wires to the RX1 and TX1 pins on the module (as in the photo). The four wires in the lower right (VCE, GND, W, C) lead to a JST connector on the other board. I unplugged this and connected VCE and GND (9V worked, this goes to the AMS1117 regulator). The GND pin of the USB serial adapter was connected to the common ground with the power supply, and the 3.3V pin on the USB adapter was not used.

    I didn't succeed in flashing with the GUI flasher (got stuck immediately on reading 0x00), but was able to flash using "uartprogram" from hid_download.

    The SoC pins are connected as follows:
    P6Motion sensor
    P8LED (cool)
    P9LED (warm)
    P23/ADC3Ambient light sensor


    The motion sensor goes HIGH when motion is detected. The ambient light sensor readings range from 0 (brightest) to 3000 (darkest).

    My configuration is as follows:
    
    {
      "vendor": "UME",
      "bDetailed": "0",
      "name": "Tuya Smart LED Outdoor Security Floodlight",
      "model": "N/A",
      "chip": "BK7231T",
      "board": "TODO",
      "flags": "1024",
      "keywords": [
        "TODO",
        "TODO",
        "TODO"
      ],
      "pins": {
        "6": "dInput_NoPullUp;3",
        "8": "Rel;1",
        "9": "Rel;2",
        "23": "ADC;5"
      },
      "command": "",
      "image": "https://obrazki.elektroda.pl/2082550400_1696896808.jpg",
      "wiki": "https://www.elektroda.com/rtvforum/topic4007225.html"
    }
    

    This allows me to control the brightness and color temperature with the two PWM channels (CW mode).

    User interface for remote control of LED floodlight with motion sensor.

    A few outstanding questions:
    * How to tie the two CW LED channels to the motion sensor. If I assign the motion sensor to one of the LED channels, then the sensor only controls that LED and not the other, giving the wrong color temperature.
    * How to add a time delay so that the light stays on for some time after motion is detected.
    * The original firmware offers the possibility of adjusting the sensitivity of the motion sensor (four levels). I haven't figured out how this works.

    I can program this control logic in my openHAB installation, but would rather have the device handle it autonomously.
  • ADVERTISEMENT
  • #2 20768158
    p.kaczmarek2
    Moderator Smart Home
    mbetter wrote:

    * How to tie the two CW LED channels to the motion sensor. If I assign the motion sensor to one of the LED channels, then the sensor only controls that LED and not the other, giving the wrong color temperature.

    Add a change handler to the target channel of the ADC, when value is higher than a chosen constant (it will also act as a sensitivity), then run a command, let's say, led_enableAll 1

    mbetter wrote:

    * How to add a time delay so that the light stays on for some time after motion is detected.

    along with the led_enableAll 1 command, you can create a repeating event with single repeat and delay time of your choice, let's say, 30 seconds, and in that event, do led_enableAll 0

    This may not be a perfect solution, because you the delay will start when there is a change (and not as long as the value is over threshold), but if you need more advanced system, I can easily write a driver for you.

    Also see:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md
    Helpful post? Buy me a coffee.
  • #3 20776478
    piotrszulc1
    Level 9  

    Hi, I believe the hardware setup you described is similar (if not identical) to the one used in LSC outdoor lamp. It also uses WB3S and the pins seem to match.
    I have recently created a script that does what you need, please see this GitHub issue.
  • #4 20788588
    mbetter
    Level 5  

    p.kaczmarek2 wrote:
    Add a change handler to the target channel of the ADC, when value is higher than a chosen constant (it will also act as a sensitivity), then run a command, let's say, led_enableAll 1


    Thanks, I was able to get it working with a script along these lines. However, the ADC is an ambient light sensor, not a proximity sensor. I still don't know how to adjust the sensitivity for the proximity sensor, as that seems to give a 0/1 value.

    Added after 34 [seconds]:

    piotrszulc1 wrote:
    Hi, I believe the hardware setup you described is similar (if not identical) to the one used in LSC outdoor lamp. It also uses WB3S and the pins seem to match. I have recently created a script that does what you need, please see this GitHub issue.


    Thanks for that, I was able to get it working with a script based on yours.
  • #5 20788839
    piotrszulc1
    Level 9  

    As for the PIR sensor, I have the same problem - there seems to be no way to control its sensitivity. However, the original Tuya firmware had this option, so it must be possible. I suspect the PIR sensor is connected to one of the I2C buses. Have you tried scanning I2C for devices? There's a description on how to do it here: https://www.elektroda.com/rtvforum/topic4000858.html#20739000.
    Even if you do find a device there, there's still a matter of:
    1) guessing which PIR sensor type exactly this is
    and
    2) determining if any existing driver supports it.

    For 1), it might be helpful to open the lamp physically, trace the I2C connections, and read the markings on the sensor. Still, this is something I don't want to do yet.
    For 2), you can ask the openbk author. If not, try switching to ESPHome, where you can define your own sensor (https://esphome.io/components/sensor/custom.html), which can use an external library (from https://registry.platformio.org/).
  • #6 20789157
    p.kaczmarek2
    Moderator Smart Home
    I will be happy to write a driver for you. Please check the connection of the PIR sensor and try to determine which part number is it, so we can find a datasheet
    Helpful post? Buy me a coffee.
  • #7 20790017
    mbetter
    Level 5  

    The lamp is already installed and I'm not able to open it up again, unfortunately.

    To scan for I2C, I would have to guess the SDA and SCK pins, right? That sounds very time-consuming. Maybe it could be scripted?
  • ADVERTISEMENT
  • #8 20790096
    p.kaczmarek2
    Moderator Smart Home
    Maybe they are stored in Tuya config, give it a try:
    https://www.youtube.com/watch?v=WunlqIMAdgw
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #9 20790634
    mbetter
    Level 5  

    Ok, that worked, got this config:
    
    {
    	"Jsonver":"Jsonver_1594302982573",
    	"brightmin":"10",
    	"title20":"0",
    	"dimval":"0",
    	"dusk":"157",
    	"cdsval":"4",
    	"pirsense_lv":"1",
    	"wfcfg":"spcl",
    	"colormin":"10",
    	"lockt":"6",
    	"preheatt":"20",
    	"pmemory":"1",
    	"pairt":"6",
    	"cmod":"cw",
    	"evenfall":"1800",
    	"cwtype":"0",
    	"day":"0",
    	"pirin_lv":"1",
    	"rstbr":"50",
    	"colormax":"100",
    	"c_pin":"8",
    	"pirhduty":"2",
    	"notdisturb":"0",
    	"night":"2180",
    	"module":"module_1594302982573",
    	"pirrange":"1",
    	"cwmaxp":"100",
    	"dmod":"0",
    	"brightmax":"100",
    	"trigmod":"1",
    	"wfct":"3",
    	"pwmhz":"600",
    	"pirsense_pin":"26",
    	"defbright":"100",
    	"rstnum":"3",
    	"rstcor":"c",
    	"dimt":"1",
    	"deftemp":"100",
    	"c_lv":"1",
    	"pirfreq":"1000",
    	"trigdelay":"15",
    	"pirmod":"0",
    	"pirlduty":"9",
    	"wt":"20",
    	"prodagain":"0",
    	"remdmode":"1",
    	"pirmduty":"6",
    	"cagt":"20",
    	"w_lv":"1",
    	"dimmod":"1",
    	"colorpfun":"0",
    	"pirin_pin":"6",
    	"rgbt":"0",
    	"colormaxp":"100",
    	"onoffmode":"0",
    	"w_pin":"9",
    	"pirwarn":"0",
    	"rsttemp":"100",
    	"evening":"2100",
    	"category":"0502",
    	"defcolor":"c",
    	"crc":"44",
    	"cdv":"1.0.0",
    	"dev_swv":"1.1.7",
    	"s_id":"null",
    	"dtp":"0",
    	"sync":"0",
    	"attr_num":"0",
    	"mst_tp_0":"0",
    	"mst_ver_0":"null",
    	"mst_tp_1":"0",
    	"mst_ver_1":"null",
    	"mst_tp_2":"0",
    	"mst_ver_2":"null",
    	"mst_tp_3":"0",
    	"mst_ver_3":"null",
    	"dminfo_name":"null",
    	"dminfo_code":"null",
    	"dminfo_report_code":"null",
    	"dminfo_sn":"null "
    }
    


    Description:
    
    Device configuration, as extracted from Tuya: 
    - LED Cool (Channel 4) on P8
    - LED Warm (Channel 5) on P9
    Device seems to be using module_1594302982573 module.
    And the Tuya section starts at UNCOMMON POSITION 0
    


    Added after 4 [minutes]:

    hmm "pirsense_pin":"26", that looks interesting. I'm configuring it as ADC, hoping that it's the raw PIR sensor reading.
  • #10 20790668
    p.kaczmarek2
    Moderator Smart Home
    Those are interesting:
    
    	"pwmhz":"600",
    	"pirsense_pin":"26",
    	"pirfreq":"1000",
    	"pirlduty":"9",
    	"pirmduty":"6",
    	"pirin_pin":"6",
    

    I would say that pirin_pin is output (1 or 0) and pirsense_pin is PWM that controls the sensitivity of PIR?
    @piotrszulc11 what do you think?
    Helpful post? Buy me a coffee.
  • #11 20791461
    mbetter
    Level 5  

    Pin 26 as ADC gave a small range of values, something like 1490-1530, which seems odd but possibly correlated with motion activity.

    Setting it as PWM was a little hard to test, as the LED controls were immediately replaced with an RGB picker. Is there a way of preventing that? I need to test more but it didn't seem like I could control sensitivity that way.
  • #12 20791743
    p.kaczmarek2
    Moderator Smart Home
    Maybe for now we can settle with "show raw PWMs" flag, before I come up with something better?
    Helpful post? Buy me a coffee.
  • #13 20803268
    piotrszulc1
    Level 9  
    I was able to set this up using esphome - I have now a slider that controls exact values to be sent via this PWM.
    Control panel with sliders for device settings using esphome.
    Screenshot of system logs for PIR sensor configuration using ESPHome.

    The esphome yaml contains this:
    
    output:
      - platform: libretiny_pwm
        id: output_pirsense
        pin: P26
        frequency: 1000 Hz
    
    ...
    
      - platform: template
        id: pirduty_pwm
        restore_value: yes
        name: P26 output PWM
        icon: "mdi:chip"
        entity_category: config
        min_value: 0
        max_value: 255
        initial_value: 0
        step: 1
        optimistic: true
        on_value:
          then:
            lambda: !lambda |-
              id(output_pirsense).set_level(x/255);
    


    I was not sure what max_value should I set here. And how to actually test this (inside of a building)? I tried to move away a bit while changing the PWM, but I see little difference in how PIR sensor detects...

    By the way, I have bought a dual-led Brennenstuhl WFD 3050 P, which seems to be using exactly the same setup and was cloudcuttable using ume-motion-security-light profile. So we know know of 3 models with the same setup. I also have Nedis floodlight (WIFILOFS20FBK) and it also was cloudcut with the same profile, so I bet it's the same (have not tried flashing yet).

    Added after 9 [minutes]:

    Actually, I was wrong, Brennenstuhl's setup (which I use for testing at the moment) might be identical, but UPK settings seem a bit different than yours:
    
            "pirfreq": 1000,
            "pirhduty": 0,
            "pirin_lv": 1,
            "pirin_pin": 6,
            "pirlduty": 100,
            "pirmduty": 50,
            "pirmod": 1,
            "pirrange": 0,
            "pirsense_lv": 1,
            "pirsense_pin": 26,
    


    This seems to be a kind of calibration of PIR sensor, but how to use it... ?
  • #14 20861005
    Kosygor
    Level 10  

    Hi there. I just bought Brennenstuhl WF2050P Floodlight aiming to integrate it into HA. If there is any data I can share, I will.
  • #16 20861818
    Kosygor
    Level 10  

    Not a "real" one, but I have Fnirsi DSO-TC3 and some Chinese Saleas logic analyzers knockoff.
  • #17 20861876
    p.kaczmarek2
    Moderator Smart Home
    What happens on this pin:
    
            "pirsense_pin": 26,
    

    when you adjust the sensitivity of the PIR in Tuya app?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #18 20862391
    Kosygor
    Level 10  

    Just to clarify, it is PIN No. 5 according to the WB3S datasheet.
    If so: I have installed the Brennenstuhl Connect app, and I have 3 settings for "Distance":
    Near: it outputs around 3V
    Medium: 3V 50% duty
    Far: 0V
    Kind of obvious, but keep in mind that I have used pretty long wires to pins 1-16, so probably 3V is really 3V3. < Ready for further testing.
  • #19 20862397
    p.kaczmarek2
    Moderator Smart Home
    So far is 0% duty cycle, medium is 50% duty cycle, and near is 100% duty cycle?

    So basically duty cycle is used to determine the sensitivity?
    Helpful post? Buy me a coffee.
  • #20 20862428
    Kosygor
    Level 10  

    Yes, I have additionally confirmed that with a logic analyzer.
  • #21 20862441
    p.kaczmarek2
    Moderator Smart Home
    This should work with OpenBeken easily, I think you can now try to first do 2MB backup of flash and then flash OpenBeken:
    https://github.com/openshwprojects/BK7231GUIFlashTool
    Here are our tutorials: https://www.youtube.com/@elektrodacom
    Helpful post? Buy me a coffee.
  • #22 20862539
    Kosygor
    Level 10  

    Ok, I have just got back from testing, so I will share my findings before I flash it:

    Pin No. 2 / ADC3 / P23 - light sensor with a range of 0 V = max light and 1.9 V = completely dark
    App settings - voltage above which PIR input triggers light (*-setting without name):
    Dark triggered at 1.9V
    * 1.65V
    Evening - 1.0V
    * 0.1V
    Day - ignoring setting
    I know they are inconsistent; should have gone with a potentiometer rather than a flashlight...

    Pin No. 7 / PWM0 / P6 - I can confirm that it triggers Hi when movement is detected

    Pin No. 13 / PWM3 / P9 - PWM for white balance
    Warm white = 0%
    Balanced = 50%
    Cold White 100%

    Pin No. 14 / PWM2 / P8 - PWM for emitted light intensity:
    App setting / PWM duty:
    1% - 5%
    50% - 52%
    100% - 100%

    If the existing solution will not work, I will move this data to another thread.
  • #23 20866509
    szaman89
    Level 10  
    >>20803268
    Could you share your esphome configuration?
  • #24 20866739
    p.kaczmarek2
    Moderator Smart Home
    Kosygor wrote:

    Ok, I have just got back from testing, so I will share my findings before I flash it:

    I think I know how to support this device. Please make 2MB backup and flash OBK:
    https://github.com/openshwprojects/OpenBK7231T_App
    https://github.com/openshwprojects/BK7231GUIFlashTool
    Helpful post? Buy me a coffee.
  • #25 20866799
    piotrszulc1
    Level 9  
    >>20866509
    Here you go:
    
    esphome:
      name: lsc-floodlight-1
      friendly_name: LSC Floodlight 1
    
    bk72xx:
      board: wb3s
        framework:
          version: dev
    
    logger:
    
    web_server:
    
    captive_portal:
    
    mdns:
    
    api:
      password: ""
    
    ota:
      password: ""
    
    wifi:
      ssid: !secret wifi_ssid
      password: !secret wifi_password
      use_address: 192.168.2.219
      manual_ip:
        static_ip: 192.168.2.219
        gateway: 192.168.2.1
        subnet: 255.255.255.0
      ap:
        ssid: "lsc-floodlight-1"
        password: !secret fallback_wifi_password
        ap_timeout: 5min
    
    button:
      - platform: restart
        name: Restart
    
    debug:
      update_interval: 30s
    
    globals:
      - id: manual_mode
        type: bool
        restore_value: yes
        initial_value: 'false'
      - id: light_sensitivity
        type: int
        restore_value: no
        initial_value: '0'
    
    script:
      - id: fullOnWhenMotion
        then:
          - logger.log:
              format: "fullOnWhenMotion"
          - light.turn_on:
              id: light_led
              brightness: 100%
      - id: waitThenDIM
        then:
          - logger.log:
              format: "waitThenDIM (%d, %d)"
              args: ["id(full_light_duration_s).state", "id(dim_light_percent).state"]
          - delay: !lambda "return id(full_light_duration_s).state;"
          - if:
              condition:
                - light.is_on: light_led
              then:
                - light.dim_relative:
                    id: light_led
                    relative_brightness: !lambda "return id(dim_light_percent).state;"
                - script.execute: waitThenOff
      - id: waitThenOff
        then:
          - logger.log:
              format: "waitThenOff (%d)"
              args: ["id(dim_light_duration_s).state"]
          - if:
              condition:
                - light.is_on: light_led
              then:
              - delay: !lambda "return id(dim_light_duration_s).state;"
              - light.turn_off: light_led
    
    text_sensor:
      - platform: debug
        reset_reason:
          name: Reset Reason
      - platform: libretiny
        version:
          name: LibreTiny Version
    
    sensor:
      - platform: uptime
        name: Uptime
      - platform: adc
        id: ambient
        name: Ambient
        unit_of_measurement: "V"
        state_class: "measurement"
        update_interval: 5s
        pin: P23
    
    binary_sensor:
      - platform: gpio
        id: pir_sensor
        name: Motion
        device_class: motion
        pin:
          number: P6
          mode:
            input: true
        on_press:
          then:
            - if:
                condition:
                  - lambda: !lambda return (!id(manual_mode) && (id(ambient).state > id(light_sensitivity)));
                then:
                  - script.stop: waitThenDIM
                  - script.stop: fullOnWhenMotion
                  - script.execute: fullOnWhenMotion
        on_release:
          then:
            - if:
                condition:
                  - lambda: !lambda return (!id(manual_mode) && (id(light_led).current_values.is_on()));
                then:
                  - logger.log:
                      format: "Executing on_release"
                  - script.execute: waitThenDIM
    
    output:
      - platform: libretiny_pwm
        id: output_pirsense
        pin: P26
        inverted: True
      - platform: libretiny_pwm
        id: out_warm
        pin: P9
      - platform: libretiny_pwm
        id: out_cold
        pin: P8
    
    light:
      - platform: cwww
        id: light_led
        name: Light
        restore_mode: RESTORE_AND_OFF
        cold_white_color_temperature: 6500 K
        warm_white_color_temperature: 2700 K
        warm_white: out_warm
        cold_white: out_cold
    
    switch:
      - platform: template
        id: manual_mode_switch
        name: "Manual mode"
        lambda: !lambda |-
          return id(manual_mode);
        turn_on_action:
          then:
            if:
              condition:
                - lambda: "return !id(manual_mode);"
              then:
                - globals.set:
                    id: manual_mode
                    value: 'true'
                - script.stop: waitThenDIM
                - script.stop: waitThenOff
                - light.turn_on: light_led
        turn_off_action:
          then:
            if:
              condition:
                - lambda: "return id(manual_mode);"
              then:
                - script.stop: waitThenDIM
                - script.stop: waitThenOff
                - light.turn_off: light_led
                - globals.set:
                    id: manual_mode
                    value: 'false'
    
    number:
      - platform: template
        id: full_light_duration_s
        restore_value: yes
        name: Full light duration
        icon: "mdi:clock"
        entity_category: config
        unit_of_measurement: "s"
        min_value: 0
        max_value: 600
        initial_value: 10
        step: 1
        optimistic: true
    
      - platform: template
        id: dim_light_duration_s
        restore_value: yes
        name: Dim light duration
        icon: "mdi:clock"
        entity_category: config
        unit_of_measurement: "s"
        min_value: 0
        max_value: 60
        initial_value: 10
        step: 1
        optimistic: true
    
      - platform: template
        id: dim_light_percent
        restore_value: yes
        name: Dim light percent
        icon: "mdi:clock"
        entity_category: config
        unit_of_measurement: "%"
        min_value: 0
        max_value: 100
        initial_value: 50
        step: 1
        optimistic: true
    
      - platform: template
        id: pirduty_pwm
        restore_value: yes
        initial_value: 50
        name: PIR sensitivity
        icon: "mdi:chip"
        entity_category: config
        min_value: 0
        max_value: 100
        step: 10
        optimistic: true
        on_value:
          then:
            lambda: !lambda |-
              id(output_pirsense).set_level(x/100);
    
    select:
      - platform: template
        id: light_sensitivity_setting
        name: "Ambient light trigger"
        entity_category: config
        restore_value: yes
        options:
         - "Day"
         - "Dusk"
         - "Evenfall"
         - "Evening"
         - "Night"
        initial_option: "Evenfall"
        optimistic: true
        set_action:
          - logger.log:
              format: "Chosen option: %s"
              args: ["x.c_str()"]
        on_value:
          then:
            lambda: !lambda |-
              if (i == 1)
              {
                id(light_sensitivity) = 0.157f;
              }
              else
              if (i == 2)
              {
                id(light_sensitivity) = 1.800f;
              }
              else
              if (i == 3)
              {
                id(light_sensitivity) = 2.100f;
              }
              else
              if (i == 4)
              {
                id(light_sensitivity) = 2.180f;
              }
              else id(light_sensitivity) = 0.0f;
    


    Edit: I've noticed that I posted the wrong yaml (not for LSC), so edited the post and now it should be correct.
  • #26 20942487
    lionboy
    Level 10  
    Hello,

    I have a simillar device only my is powered by Battery:

    
    esphome:
      name: lumina-hol3
    
    external_components:
      - source: github://Xmister/libretuya-esphome@deep-sleep-compat
        components: [ esp32, deep_sleep ]
    
    bk72xx:
      board: generic-bk7231n-qfn32-tuya
      framework:
        version: dev
    
    logger:
    
    web_server:
    
    captive_portal:
    
    mdns:
    
    api:
      password: ""
    
    ota:
      password: ""
    
    wifi:
      ssid: !secret wifi_smart
      password: !secret wifi_smart_pass
      ap:
        ssid: "Lumina_Hol_3"
        password: ""
    
    button:
      - platform: restart
        name: Restart
    
    debug:
      update_interval: 30s
    
    globals:
      - id: manual_mode
        type: bool
        restore_value: yes
        initial_value: 'false'
      - id: light_sensitivity
        type: int
        restore_value: no
        initial_value: '0'
    
    script:
      - id: fullOnWhenMotion
        then:
          - logger.log:
              format: "fullOnWhenMotion"
          - light.turn_on:
              id: light_monochromatic
              brightness: 50%
      - id: waitThenDIM
        then:
          - logger.log:
              format: "waitThenDIM (%d, %d)"
              args: ["id(full_light_duration_s).state", "id(dim_light_percent).state"]
          - delay: !lambda "return id(full_light_duration_s).state;"
          - if:
              condition:
                - light.is_on: light_monochromatic
              then:
                - light.dim_relative:
                    id: light_monochromatic
                    relative_brightness: !lambda "return id(dim_light_percent).state;"
                - script.execute: waitThenOff
      - id: waitThenOff
        then:
          - logger.log:
              format: "waitThenOff (%d)"
              args: ["id(dim_light_duration_s).state"]
          - if:
              condition:
                - light.is_on: light_monochromatic
              then:
              - delay: !lambda "return id(dim_light_duration_s).state;"
              - light.turn_off: light_monochromatic
    
    text_sensor:
      - platform: debug
        reset_reason:
          name: Reset Reason
      - platform: libretiny
        version:
          name: LibreTiny Version
    
    sensor:
      - platform: uptime
        name: Uptime
      - platform: adc
        id: ambient
        name: Ambient
        unit_of_measurement: "V"
        state_class: "measurement"
        update_interval: 5s
        pin: P23
    
    binary_sensor:
      - platform: gpio
        id: pir_sensor
        name: Motion
        device_class: motion
        pin:
          number: P6
          mode:
            input: true
        on_press:
          then:
            - if:
                condition:
                  - lambda: !lambda return (!id(manual_mode) && (id(ambient).state > id(light_sensitivity)));
                then:
                  - script.stop: waitThenDIM
                  - script.stop: fullOnWhenMotion
                  - script.execute: fullOnWhenMotion
        on_release:
          then:
            - if:
                condition:
                  - lambda: !lambda return (!id(manual_mode) && (id(light_monochromatic).current_values.is_on()));
                then:
                  - logger.log:
                      format: "Executing on_release"
                  - script.execute: waitThenDIM
    
    output:
      - platform: libretiny_pwm
        id: output_pirsense
        pin: P8
        inverted: True
      - platform: libretiny_pwm
        id: output_cold
        pin: P24
        frequency: 1000 Hz
    
    
    light:
      - platform: monochromatic
        id: light_monochromatic
        name: Lumina Hol 3
        output: output_cold
    
    switch:
      - platform: template
        id: manual_mode_switch
        name: "Manual mode"
        lambda: !lambda |-
          return id(manual_mode);
        turn_on_action:
          then:
            if:
              condition:
                - lambda: "return !id(manual_mode);"
              then:
                - globals.set:
                    id: manual_mode
                    value: 'true'
                - script.stop: waitThenDIM
                - script.stop: waitThenOff
                - light.turn_on: light_monochromatic
        turn_off_action:
          then:
            if:
              condition:
                - lambda: "return id(manual_mode);"
              then:
                - script.stop: waitThenDIM
                - script.stop: waitThenOff
                - light.turn_off: light_monochromatic
                - globals.set:
                    id: manual_mode
                    value: 'false'
    
    number:
      - platform: template
        id: full_light_duration_s
        restore_value: yes
        name: Full light duration
        icon: "mdi:clock"
        entity_category: config
        unit_of_measurement: "s"
        min_value: 0
        max_value: 600
        initial_value: 10
        step: 1
        optimistic: true
    
      - platform: template
        id: dim_light_duration_s
        restore_value: yes
        name: Dim light duration
        icon: "mdi:clock"
        entity_category: config
        unit_of_measurement: "s"
        min_value: 0
        max_value: 60
        initial_value: 10
        step: 1
        optimistic: true
    
      - platform: template
        id: dim_light_percent
        restore_value: yes
        name: Dim light percent
        icon: "mdi:clock"
        entity_category: config
        unit_of_measurement: "%"
        min_value: 0
        max_value: 100
        initial_value: 50
        step: 1
        optimistic: true
    
      - platform: template
        id: pirduty_pwm
        restore_value: yes
        initial_value: 50
        name: PIR sensitivity
        icon: "mdi:chip"
        entity_category: config
        min_value: 0
        max_value: 100
        step: 10
        optimistic: true
        on_value:
          then:
            lambda: !lambda |-
              id(output_pirsense).set_level(x/100);
    
    select:
      - platform: template
        id: light_sensitivity_setting
        name: "Ambient light trigger"
        entity_category: config
        restore_value: yes
        options:
         - "Day"
         - "Dusk"
         - "Evenfall"
         - "Evening"
         - "Night"
        initial_option: "Evenfall"
        optimistic: true
        set_action:
          - logger.log:
              format: "Chosen option: %s"
              args: ["x.c_str()"]
        on_value:
          then:
            lambda: !lambda |-
              if (i == 1)
              {
                id(light_sensitivity) = 0.157f;
              }
              else
              if (i == 2)
              {
                id(light_sensitivity) = 1.800f;
              }
              else
              if (i == 3)
              {
                id(light_sensitivity) = 2.100f;
              }
              else
              if (i == 4)
              {
                id(light_sensitivity) = 2.180f;
              }
              else id(light_sensitivity) = 0.0f;
    


    I succesfully manage to adapt you code to my device, you can finde details on this post if anyone want to know about this:

    Now i am waiting to implement Deep Sleep on this libretiny version because is very hard to manage battery without deep sleep,
    From 3 device on 1 a change CBU with ESP8685-WROOM-06-H4 and with deep sleep implemented i am at 4 day's without charging.

    https://www.elektroda.com/rtvforum/topic4031757.html

    Thanks

    Added after 1 [hours] 49 [minutes]:

    At me i have a problem with that lux because is show me max value when is light and zero when is night and on Volts don't go much more then 0.8

    Added after 1 [hours] 21 [minutes]:

    >>20866799
    I don't understand why at me is this and don't go up then 1.88

    
    [16:17:58][D][sensor:093]: 'Ambient': Sending state 1.57200 V with 2 decimals of accuracy
    [16:18:03][D][sensor:093]: 'Ambient': Sending state 1.87300 V with 2 decimals of accuracy
    [16:18:08][D][sensor:093]: 'Ambient': Sending state 1.88100 V with 2 decimals of accuracy
    [16:18:13][D][sensor:093]: 'Ambient': Sending state 1.88300 V with 2 decimals of accuracy
    


    
    {
    	"Jsonver":"1.0.8",
    	"brightmin":"10",
    	"gmwb":"75",
    	"title20":"0",
    	"dimval":"0",
    	[b]"dusk":"265",[/b]
    	"gmwg":"70",
    	"cdsval":"2",
    	"pirsense_lv":"1",
    	"wfcfg":"spcl",
    	"colormin":"10",
    	"lockt":"7",
    	"preheatt":"20",
    	"pmemory":"1",
    	"gmkb":"60",
    	"cmod":"c",
    	[b]"evenfall":"460",[/b]
    	"cwtype":"0",
    	[b]"day":"0",[/b]
    	"pirin_lv":"1",
    	"rstbr":"10",
    	"colormax":"100",
    	"c_pin":"24",
    	"pirhduty":"0",
    	"notdisturb":"0",
    	[b]"night":"2180",[/b]
    	"module":"CBU",
    	"pirrange":"0",
    	"ctrl_lv":"1",
    	"cwmaxp":"100",
    	"dmod":"0",
    	"brightmax":"100",
    	"trigmod":"0",
    	"wfct":"3",
    	"pwmhz":"1000",
    	"pirsense_pin":"8",
    	"defbright":"100",
    	"rstnum":"5",
    	"rstcor":"c",
    	"dimt":"1",
    	"deftemp":"100",
    	"c_lv":"1",
    	"pirfreq":"20000",
    	"trigdelay":"10",
    	"keyfunc":"0",
    	"ctrl_pin":"26",
    	"pirmod":"0",
    	"pirlduty":"16",
    	"pirir":"7",
    	"wt":"0",
    	"prodagain":"1",
    	"remdmode":"0",
    	"pirmduty":"7",
    	"cagt":"20",
    	"dimmod":"1",
    	"colorpfun":"0",
    	"pirin_pin":"6",
    	"gmwr":"100",
    	"rgbt":"0",
    	"colormaxp":"100",
    	"gmkg":"60",
    	"onoffmode":"1",
    	"pirwarn":"0",
    	"rsttemp":"100",
    	[b]"evening":"1400",[/b]
    	"category":"0501",
    	"gmkr":"80",
    	"defcolor":"c",
    	"crc":"46"
    }
    


    
    select:
      - platform: template
        id: light_sensitivity_setting
        name: "Ambient light trigger"
        entity_category: config
        restore_value: yes
        options:
         - "Day"
         - "Dusk"
         - "Evenfall"
         - "Evening"
         - "Night"
        initial_option: "Evenfall"
        optimistic: true
        set_action:
          - logger.log:
              format: "Chosen option: %s"
              args: ["x.c_str()"]
        on_value:
          then:
            lambda: !lambda |-
              if (i == 1)
              {
                id(light_sensitivity) = 0.265f;
              }
              else
              if (i == 2)
              {
                id(light_sensitivity) = 0.460f;
              }
              else
              if (i == 3)
              {
                id(light_sensitivity) = 1.400f;
              }
              else
              if (i == 4)
              {
                id(light_sensitivity) = 2.180f;
              }
              else id(light_sensitivity) = 0.0f;
    


    Maybe i miss something because i don't get it why one lamp go max to 1.8 amd amother one go max to 1.55

    Thanks

    Added after 2 [minutes]:

    At me there are a new PIN and i don't know what this pin do:

    "ctrl_pin":"26",

    Added after 1 [minutes]:

    >>20866739
    I can give from my device 2 MB full dump
  • #27 20950930
    airdrummingfool
    Level 3  

    Hello, I have a device that appears to be very similar to the devices being discussed here. It is an Amico Smart LED Motion Sensor Floodlight with BK7231T / WB3S. I was able to upload custom firmware with CloudCutter, and now I have it running the latest version of OBK.

    I would love to get a full configuration set up and then shared, but I'm running into some issues and I can't tell if it's incorrect configuration or just a defective device. I'm working on the PIR sensor input (P6), which does trigger when I walk in front of it, but it also triggers randomly, sometimes repeatedly for many minutes at a time. I tried using a pullup configuration ("6": "dInput_n;57") and also the configuration from this thread ("6": "dInput_NoPullUp;3") but neither fixed the phantom triggering problem. I also tried setting the PIR sensitivity to low (P26 PWM 1000hz 100% duty cycle), but it didn't seem to work (though I'm not positive I configured the sensitivity pin correctly).

    I've also found what seems like a bug somewhere in the Home Assistant Discovery configuration. I have OBK connected to Home Assistant via MQTT, and the device successfully shows up using Discovery. However, the PIR sensor shows as ON in Home Assistant when it is low/off in OBK. If I manually publish a "1" via MQTT for the discovery topic of the PIR sensor, HA shows the sensor as OFF. I grabbed the discovery config that OBK published and it looks like the values for on and off might be reversed - pl_on should be 1 and pl_off should be 0, I think?
    Code: JSON
    Log in, to see the code


    Please let me know if there's any information I can share or anything I can try to help get the configuration ironed out for these devices!
  • #28 20952296
    lionboy
    Level 10  
    Can you upload 2 Mb dump file here?

    Thanks
  • #29 20952388
    airdrummingfool
    Level 3  
    Is this what you're looking for, or do you need a full flash dump? I've redacted some sensitive info (like wifi) but otherwise this should be the full storage data JSON:

    Code: JSON
    Log in, to see the code
  • #30 20952591
    lionboy
    Level 10  

    Hello,

    Please like this video:

    https://www.youtube.com/watch?v=WunlqIMAdgw

    For ESPHome, the configuration is only for PWM light:

    
    esphome:
      name: upk2esphome-bk7231t
    bk72xx:
      board: generic-bk7231t-qfn32-tuya
    logger:
    web_server:
    captive_portal:
    mdns:
    api:
      password: ""
    ota:
      password: ""
    wifi:
      ssid: !secret wifi_ssid
      password: !secret wifi_password
      ap:
    button:
      - platform: restart
        name: Restart
    debug:
      update_interval: 30s
    text_sensor:
      - platform: debug
        reset_reason:
          name: Reset Reason
      - platform: libretiny
        version:
          name: LibreTiny Version
    sensor:
      - platform: uptime
        name: Uptime
    output:
      - platform: libretiny_pwm
        id: output_cold
        pin: P24
      - platform: libretiny_pwm
        id: output_warm
        pin: P9
    light:
      - platform: cwww
        id: light_cwww
        name: Light
        cold_white_color_temperature: 6500 K
        warm_white_color_temperature: 2700 K
        cold_white: output_cold
        warm_white: output_warm
    


    Thanks

Topic summary

The discussion revolves around the BK7231T-based WB3S UME Outdoor Security Floodlight, focusing on its motion-activated features, including a PIR sensor and ambient light sensor. Users share experiences with flashing firmware, specifically OpenBeken and ESPHome, to control the floodlight's settings. Key issues include adjusting the sensitivity of the PIR sensor, which appears to trigger randomly, and the challenges of configuring PWM outputs for light intensity and sensor sensitivity. Solutions discussed involve using scripts, scanning I2C devices, and experimenting with different configurations to mitigate false triggers caused by environmental factors. Users also share their configurations and findings related to the device's performance in various settings.
Summary generated by the language model.
ADVERTISEMENT