logo elektroda
logo elektroda
X
logo elektroda

[BK7231N] OpenBeken - How do I change the Tuya WiFi Smart PIR function from Control to Sensor?

burba 2613 31
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 21072369
    burba
    Level 9  
    I have such a "PiR Multifunction Alarm" as in the attached pictures. I managed to flash it on OpenBeken, but I can't use it in the "Alarmo" plug-in in the home assistant because it is not detected as "sensor" but as "control". Is it possible to change this somehow? I'm using the dinput function, because the device is powered from USB, and DoorSnsrWSleep was putting it to sleep unnecessarily, but on both it is seen as "control".

    The second issue: the device has a speaker, which with the Tuya software in notification mode made a "ding dong" sound. Is it possible to get this in OpenBeken? When I set the LED option on this pin, the loudspeaker - understandably - only chirps.

    Wi-Fi motion sensor with Tuya box on wooden floor Packaging of Tuya WiFi Smart PIR Motion Sensor. Interior of an alarm device showing a PCB board, sensor, and electronic module. Interior of an alarm device showing a PCB board, sensor, and electronic module.
  • ADVERTISEMENT
  • #2 21072769
    p.kaczmarek2
    Moderator Smart Home
    To start with you could try setting the role of the speaker pin to PWM and play around with the PWM settings, apart from the fill adjustment there is also the command PWMFrequency . There are no pre-programmed tunes at the moment, but that shouldn't be a big problem either, you could try to do it...

    What about the sensor type, just out of curiosity, if you change the channel type from PIR value to OpenClosed does it change the type when you Ha Discovery again?
    Helpful post? Buy me a coffee.
  • #3 21072904
    burba
    Level 9  

    Setting the pin to PWM helped - the speaker came to life, the 'Toggle Light' button and 'LED Dimmer/Brightness' slider appeared on the OpenBeken home page, and a light switch appeared in the HA 'controls' panel next to the switch showing the PIR status, which turns on the speaker. Thanks :-) . I'll play with the settings later.

    Changing the channel type (ch1 in this case) to OpenClosed/OpenClosed_Inv unfortunately didn't help. After removing the sensor from HA and re HA discovery all the time the PIR is a switch. Obviously the switch switches itself reacting to movement - because I didn't mention that at the beginning. It's just the wrong type that prevents me from plugging it into Alarmo.

    PS. nods and admiration - amazing job, great design and responsiveness better than entire helpdesk teams in corporations!
  • #4 21072973
    p.kaczmarek2
    Moderator Smart Home
    burba wrote:

    Setting the pin to PWM helped - the speaker came to life, the 'Toggle Light' button and 'LED Dimmer/Brightness' slider appeared on the OpenBeken homepage, and a light switch appeared in the HA 'controls' panel next to the switch showing the PIR status, which turns the speaker on. Thanks to :-) .

    There is a flag to show raw PWM controls and this should disable treating this as an LED. Then this could be scripted in autoexec.bat and e.g. catch the channel state change event from the PIR...
    If you know the basics of C then you could add a simple driver for this to play a melody, but it depends if you want to play around...

    burba wrote:

    Changing the channel type (ch1 in this case) to OpenClosed/OpenClosed_Inv unfortunately did not help. After removing the sensor from HA and re HA discovery all the time the PIR is a switch. Obviously the switch switches itself reacting to movement - because I didn't mention that at the beginning. It's just that the wrong type doesn't allow me to plug it into the Alarmo.
    In that case I can add a new channel type for you (unless something else fits, but I'd have to check), just do you happen to know what specific settings the HA expects? Maybe you have some device with the correct Home Assistant Discovery and can capture it to peek at what is being sent?

    Otherwise.... what sensor class is this channel supposed to have?
    Screenshot of C source code configuring sensors for Home Assistant.

    Can you provide the entire configuration of your device so I can enter it into the simulator and check it for myself with HA?
    OpenBeken simulator with a circuit connected to WS2812 LEDs.

    This is an example from me:
    Screenshot of editing /autoexec.bat file with commands setChannelLabel and setChannelType.
    This is how HA sees it:
    Device control panel showing information on sensors and logs

    Added after 8 [minutes]:

    Is this the binary_sensor from motion?

    https://www.home-assistant.io/integrations/binary_sensor/#device-class

    Added after 5 [minutes]:2dd3e526464b

    This is what it would look like with motion:
    Home Assistant UI showing motion detection history for a device.

    Added after 25 [minutes]:2dd3e526464b

    I uploaded the Motion channel type, can you do an OTA to the latest version and see if it works? C
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 21073089
    burba
    Level 9  

    I guess I'm a bit short on time :-| . The OTA shows me as the latest version "Build on May 3 2024 21:03:04 version 1.17.571". I uploaded what was the latest anyway, just in case, but the Motion channel type didn't show up. On GitHub I actually see that you have made changes to the "http_fns.c" file. Should I compile this myself somehow?

    Configuration panel for PIR_TZ3000_TS0202 device in Zigbee Home Automation showing status and settings. Admin panel of BK7231N device with information and logs. Configuration screen for a TuYa smoke sensor showing device info, sensor unavailability, and no logbook events. Alarm panel with a list of configured sensors.

    This is the extracted device configurations from HA mqtt-b020b...df2f5-.zip Download (6.99 kB) .
    devices that can serve as alarm-triggering sensors are described in this way:
    "entity_id": "binary_sensor.0xa4c13847c35b3626_occupancy"
    "entity_id": "binary_sensor.0xa4c138c8c95d7439_smoke"

    a PIR sensor with which there is a problem in this one:
    "entity_id": "switch.multifunction_alarm_obke1552b06_1"
  • ADVERTISEMENT
  • #6 21073093
    p.kaczmarek2
    Moderator Smart Home
    I think I just messed up the compilation on the main page from Github:
    Screenshot of GitHub Actions showing a failed build for a project. I'll give the OTA file download or link here

    Added after 26 [minutes]:

    https://github.com/openshwprojects/OpenBK7231.../actions/runs/8984880294/artifacts/1480027898 select the correct OTA file for your platform from this zip
    Helpful post? Buy me a coffee.
  • #7 21073161
    burba
    Level 9  

    Ok, thanks. Motion has appeared in the list of channel types, although it's pointing a bit the other way round: in the ON state it shows "no motion", but that's unlikely to be a problem - I've changed the PIN setting to "dInput_n".
    Unfortunately, no change in HA - it's still in the "controls" panel, not "sensors".
  • ADVERTISEMENT
  • #8 21073168
    p.kaczmarek2
    Moderator Smart Home
    And did you do HASS Discovery?

    Do you have like in my screenshots?
    Helpful post? Buy me a coffee.
  • #9 21073250
    burba
    Level 9  

    I removed the device from the HA (in the MQTT extension), restarted via the OpenBK main page and added again via OpenBK Config->Home Assistant Configuration->Start Home Assistant Discovery. And all the time it looks like in the screens below.

    User interface displaying device details for BK7231N, controls, and event log.
    Integration panel of a multifunction device with Home Assistant using MQTT. OpenBK device configuration with MQTT and pin settings. OpenBK7231N application interface page with device status information.
    OpenBK7231N application interface page with device status information.
    .
  • #10 21073305
    p.kaczmarek2
    Moderator Smart Home
    Aha, you should have done that right away. I typed in your configuration and Found another problem, here is the new version to test:
    https://github.com/openshwprojects/OpenBK7231.../actions/runs/8987623720/artifacts/1480674831
    Helpful post? Buy me a coffee.
  • #11 21073699
    burba
    Level 9  
    Now the PIR has disappeared altogether :-) . Only the speaker pretending to be a light bulb remains in the "Controls" panel, but nothing new has appeared in "Sensors". Control panel for BK7231N device with diagnostic information and activity logs.

    [Edit] In the "Diagnostic" panel, in addition to RSSI, the items "Build" and "uptime" appeared after a while, along with the values.
  • #12 21073728
    p.kaczmarek2
    Moderator Smart Home
    So let's check again.
    Before:
    Screenshot of a device list in Home Assistant filtered for MQTT integration.
    Configuration:
    Configuration interface settings with MQTT and pin data.
    Result:
    Screenshot of the Home Assistant interface with details about the WT3145CAFF device. Hmm on me I think it is? After a while I have:
    Screenshot of Home Assistant interface showing device information and event log.

    If I listen to the discovery topic (see screenshot):
    Home Assistant interface with a message about WinTest binary sensor.
    This I have:
    Code: JSON
    Log in, to see the code

    Isn't this package at your place?

    My colleague @DeDaMrAz will also check on HA and we'll see

    Added after 1 [minutes]:

    Edit: Fellow @DeDaMrAz checked, his screenshots:
    Device settings panel for BK7231N in the MQTT interface. Screenshot of HA control panel with BK7231N device.
    He probably didn't set the Frequency channel no but there is motion in his....

    What version of HA do you have? Can you check again if you have done everything ok?
    Helpful post? Buy me a coffee.
  • #14 21073808
    burba
    Level 9  

    @DeDaMrAz yes, I've saved the type. Now for testing I've removed frequency, but the only effect is that frequency obviously disappeared from sensors.
    Screenshot of a home automation system interface showing device information, controls, logs, and diagnostics.
    @p.kaczmarek2 HA I have on proxmox (if that changes anything), version 2024.5.2 Home Assistant logo with version numbers for Core, Supervisor, Operating System, and Frontend.

    @p.kaczmarek2 where to look for this "listening theme"?
    I think I did everything ok, the only thing I can think of is: "Paste this to configuration yaml
    Make sure that you have "switch:" keyword only once! Home Assistant doesn't like dup keywords.
    You can also use "switch MyDeviceName:" to avoid keyword duplication!" this is something I haven't done - do I actually have to paste this somewhere? Doesn't it import itself at HA discovery?
    Device configuration screen with Home Assistant settings for a multifunction device.

    Added after 3 [minutes]:

    still in autoexec.whip I have it switch the LED to show wifi status on boot, but that probably shouldn't affect:Screenshot showing an edited autoexec.bat file with commands related to WiFi and LED settings.
    .
  • #15 21073815
    p.kaczmarek2
    Moderator Smart Home
    This field with OBK is obsolete. It is for the manual creation of YAML. We are discussing Discovery topics.


    Discovery can be tapped in Home Assistant itself, in MQTT, in Configure there is an option to manually publish a packet (redundant now) and to listen for packets (this will come in handy). If you do a listen under a topic (see my screenshot from the previous post) like I did, you'll be able to catch what OBK is publishing as Home Assistant Discovery. If you approach those JSONs there, we'll know if the problem is on OBK's side (maybe the JSON from Motion isn't published after all?) or maybe on HA's side (the Json from Motion is published but HA doesn't read it)

    My HA:
    Screenshot of Home Assistant version information. .
    Helpful post? Buy me a coffee.
  • #16 21073830
    burba
    Level 9  
    Looks like the sensor is not sending this binary_sensor/motion to MQTT at all:
    WebApp OpenBK screen showing MQTT messages about various sensors.


    "Message 26 received on homeassistant/sensor/multifunction_alarm_OpenBK7231N_E1552B06_build/config at 12:48 AM:

    {
    "dev": {
    "ids": [
    "multifunction_alarm_OpenBK7231N_E1552B06"
    ],
    "name": "multifunction_alarm_obkE1552B06",
    "sw": "1215_merge_dd32e251ff32",
    "mf": "Beken Corporation",
    "mdl": "BK7231N",
    "cu": "http://192.168.11.110/index"
    },
    "name": "Build",
    "~": "obkE1552B06",
    "avty_t": "~/connected",
    "uniq_id": "multifunction_alarm_OpenBK7231N_E1552B06_build",
    "qos": 1,
    "stat_t": "~/build",
    "entity_category": "diagnostic"
    }

    QoS: 0 - Retain: false
    Message 25 received on homeassistant/sensor/multifunction_alarm_OpenBK7231N_E1552B06_uptime/config at 12:48 AM:

    {
    "dev": {
    "ids": [
    "multifunction_alarm_OpenBK7231N_E1552B06"
    ],
    "name": "multifunction_alarm_obkE1552B06",
    "sw": "1215_merge_dd32e251ff32",
    "mf": "Beken Corporation",
    "mdl": "BK7231N",
    "cu": "http://192.168.11.110/index"
    },
    "name": "Uptime",
    "~": "obkE1552B06",
    "avty_t": "~/connected",
    "uniq_id": "multifunction_alarm_OpenBK7231N_E1552B06_uptime",
    "qos": 1,
    "dev_cla": "duration",
    "stat_t": "~/uptime",
    "unit_of_meas": "s",
    "entity_category": "diagnostic",
    "stat_cla": "total_increasing"
    }

    QoS: 0 - Retain: false
    Message 24 received on homeassistant/sensor/multifunction_alarm_OpenBK7231N_E1552B06_rssi/config at 12:48 AM:

    {
    "dev": {
    "ids": [
    "multifunction_alarm_OpenBK7231N_E1552B06"
    ],
    "name": "multifunction_alarm_obkE1552B06",
    "sw": "1215_merge_dd32e251ff32",
    "mf": "Beken Corporation",
    "mdl": "BK7231N",
    "cu": "http://192.168.11.110/index"
    },
    "name": "RSSI",
    "~": "obkE1552B06",
    "avty_t": "~/connected",
    "uniq_id": "multifunction_alarm_OpenBK7231N_E1552B06_rssi",
    "qos": 1,
    "dev_cla": "signal_strength",
    "stat_t": "~/rssi",
    "unit_of_meas": "dBm",
    "entity_category": "diagnostic",
    "stat_cla": "measurement"
    }

    QoS: 0 - Retain: false
    Message 23 received on homeassistant/sensor/multifunction_alarm_OpenBK7231N_E1552B06_sensor_2/config at 12:48 AM:

    {
    "dev": {
    "ids": [
    "multifunction_alarm_OpenBK7231N_E1552B06"
    ],
    "name": "multifunction_alarm_obkE1552B06",
    "sw": "1215_merge_dd32e251ff32",
    "mf": "Beken Corporation",
    "mdl": "BK7231N",
    "cu": "http://192.168.11.110/index"
    },
    "name": "2",
    "~": "obkE1552B06",
    "avty_t": "~/connected",
    "uniq_id": "multifunction_alarm_OpenBK7231N_E1552B06_sensor_2",
    "qos": 1,
    "dev_cla": "frequency",
    "unit_of_meas": "Hz",
    "stat_t": "~/2/get",
    "stat_cla": "measurement",
    "val_tpl": "{{ '%0.3f'|format(float(value)*0.1) }}"
    }

    QoS: 0 - Retain: false
    Message 22 received on homeassistant/light/multifunction_alarm_OpenBK7231N_E1552B06_light_1/config at 12:48 AM:

    {
    "dev": {
    "ids": [
    "multifunction_alarm_OpenBK7231N_E1552B06"
    ],
    "name": "multifunction_alarm_obkE1552B06",
    "sw": "1215_merge_dd32e251ff32",
    "mf": "Beken Corporation",
    "mdl": "BK7231N",
    "cu": "http://192.168.11.110/index"
    },
    "name": "1",
    "~": "obkE1552B06",
    "avty_t": "~/connected",
    "pl_on": "1",
    "pl_off": "0",
    "uniq_id": "multifunction_alarm_OpenBK7231N_E1552B06_light_1",
    "qos": 1,
    "stat_t": "~/led_enableAll/get",
    "cmd_t": "cmnd/obkE1552B06/led_enableAll",
    "bri_stat_t": "~/led_dimmer/get",
    "bri_cmd_t": "cmnd/obkE1552B06/led_dimmer",
    "bri_scl": 100
    }

    "

    Added after 8 [minutes]:

    The OpenBK WebApp log shows something like this when the sensor detects motion:
    Screenshot showing logs from WebApp OpenBK related to motion sensor activity and MQTT channel.
    Screenshot showing logs from WebApp OpenBK related to motion sensor activity and MQTT channel.
    .
  • #17 21073841
    p.kaczmarek2
    Moderator Smart Home
    In that case, I suggest you save your configuration (you can even paste it here in a reply, just use the code tag) and then set up the device so that there is only a channel with the Motion type and then retry along with listening to MQTT.

    In this way, I want to eliminate the option that something gets lost or cut off somewhere.... remove unnecessary variables from the equation
    Helpful post? Buy me a coffee.
  • #18 21073847
    DeDaMrAz
    Level 19  
    @burba

    I've tried adding multiple channels to test and this is the result from my side:


    Device settings interface with pin configuration and channel types.


    User interface of a system for managing devices with confirmed state changes.

    Here are some hints that you can try, delete your device from HA and reboot your HA (not reload), also try and restart your OBK module before activating HA discovery.

    EDIT: also change the LED channel to anything other than 1 - dInput and LED on different channels.
  • #19 21073854
    p.kaczmarek2
    Moderator Smart Home
    Helpful post? Buy me a coffee.
  • #20 21074223
    burba
    Level 9  

    I knocked out the whole pin configuration, rebooted. I just set dinput/motion on the PIR pin - nothing changed, it still wasn't sending to the HA that. The HA itself was rebooted by me several times during all these procedures. The sensor almost every time. I decided to clear the configuration completely, blew out the Wi-Fi settings - set to open access point and lost contact with the device. It doesn't show up as an access point. I tried five launches under 5s - nothing appears either. Only the LED is on continuously. So far brick. I'll try some more - as a last resort soldering and flashing again.
  • #21 21074237
    p.kaczmarek2
    Moderator Smart Home
    Something we must be leaving out relevant since it works:
    - at @DeDaMrAz on BK7231N - you also have BK7231N so strange...
    - at me on simulator
    - at me in code in unit test, see here:
    https://github.com/openshwprojects/OpenBK7231...c/selftest/selftest_hass_discovery_ext.c#L305
    Generally there are now 2 situations in the tests (motion channel, motion channel + LED + dinput), code in spoiler:
    Code: C / C++
    Log in, to see the code

    All tests pass correctly.

    So there must be some other, external factor.

    Maybe special characters in the names? But I don't think so, because that would make the other publishe not work either...


    @burba as to the brick problem then UART RX give it to TX2 (not TX1) and see the log output at 115200. You could also upload a 2MB backup of the original flash (flasher does it by default on the read backup and flash option)
    Helpful post? Buy me a coffee.
  • #22 21074667
    burba
    Level 9  
    The debug from TX2 looks like this:

    ޹i-
    V:BK7231N_1.0.1
    REG:cpsr     spsr     r13      r14
    SVC:000000D3          00401C1C 000033AC
    IRQ:000000d2 00000010 00401e0c ceadc727
    FIR:000000d1 00000010 00401ffc 09d56de6
    SYS:000000df          0040192c 00000158
    ST:00000000
    J 0x10000
    bk_misc_init_start_type 0 0
    prvHeapInit-start addr:0x414400, size:113664
    [Flash]id:0xeb6015
    sctrl_sta_ps_init
    cset:0 0 0 0
    Entering initLog()...
    Commands registered!
    initLog() done!
    Info:MAIN:Main_Init_Before_Delay
    Info:CFG:####### Boot Count 196 #######
    Info:MAIN:###### safe mode activated - boot failures 59
    Warn:CFG:CFG_InitAndLoad: Correct config has been loaded with 516 changes count.
    Info:MAIN:Main_Init_Before_Delay done
    
    Main_Init_Before_Delay done
    Info:MAIN:Main_Init_Delay
    
    Main_Init_Delay
    
    delaying start
    bandgap_calm_in_efuse=0x63
    [load]bandgap_calm=0x63->0x23,vddig=4->5
    [FUNC]rwnxl_init
    [bk]tx_txdesc_flush
    #Startup delayed 0ms#
    [FUNC]intc_init
    [FUNC]calibration_main
    gpio_level=1,txpwr_state=15
                               user define rfcali mode:1
    get rfcali_mode:1
    #Startup delayed 10ms#
    #Startup delayed 20ms#
    #Startup delayed 30ms#
    #Startup delayed 40ms#
    #Startup delayed 50ms#
    #Startup delayed 60ms#
    #Startup delayed 70ms#
    #Startup delayed 80ms#
    #Startup delayed 90ms#
    #Startup delayed 100ms#
    #Startup delayed 110ms#
    #Startup delayed 120ms#
    #Startup delayed 130ms#
    #Startup delayed 140ms#
    #Startup delayed 150ms#
    #Startup delayed 160ms#
    #Startup delayed 170ms#
    #Startup delayed 180ms#
    #Startup delayed 190ms#
    #Startup delayed 200ms#
    #Startup delayed 210ms#
    #Startup delayed 220ms#
    #Startup delayed 230ms#
    #Startup delayed 240ms#
    #Startup delayed 250ms#
    #Startup delayed 260ms#
    #Startup delayed 270ms#
    #Startup delayed 280ms#
    #Startup delayed 290ms#
    #Startup delayed 300ms#
    #Startup delayed 310ms#
    #Startup delayed 320ms#
    #Startup delayed 330ms#
    #Startup delayed 340ms#
    #Startup delayed 350ms#
    #Startup delayed 360ms#
    #Startup delayed 370ms#
    #Startup delayed 380ms#
    #Startup delayed 390ms#
    #Startup delayed 400ms#
    #Startup delayed 410ms#
    #Startup delayed 420ms#
    #Startup delayed 430ms#
    #Startup delayed 440ms#
    calibration_main over
                         flash txpwr table:0xf
    dif g and n20 ID in flash:4
    dif g and n40 ID in flash:4
    read txpwr tab from flash success
    temp in flash is:342
    xtal in flash is:80
    xtal_cali:80
    --init_xtal = 80
                    [FUNC]ps_#Startup delayed 450ms#
    ielayed 450ms#
    [FUNC]func_init_extended OVER!!!
    
    start_type:0
    Version:
    Initializing TCP/IP stack
    #Startup delayed 460ms#
    app_init finished
    #Startup delayed 470ms#
    #Startup delayed 480ms#
    #Startup delayed 490ms#
    #Startup delayed 500ms#
    #Startup delayed 510ms#
    #Startup delayed 520ms#
    #Startup delayed 530ms#
    #Startup delayed 540ms#
    #Startup delayed 550ms#
    #Startup delayed 560ms#
    #Startup delayed 570ms#
    #Startup delayed 580ms#
    #Startup delayed 590ms#
    #Startup delayed 600ms#
    #Startup delayed 610ms#
    #Startup delayed 620ms#
    #Startup delayed 630ms#
    #Startup delayed 640ms#
    #Startup delayed 650ms#
    #Startup delayed 660ms#
    #Startup delayed 670ms#
    #Startup delayed 680ms#
    #Startup delayed 690ms#
    #Startup delayed 700ms#
    #Startup delayed 710ms#
    #Startup delayed 720ms#
    #Startup delayed 730ms#
    #Startup delayed 740ms#
    
    starting....
    Info:MAIN:Main_Init_Delay done
    
    Main_Init_Delay done
    Info:MAIN:Main_Init_After_Delay
    Info:MAIN:###### safe mode activated - boot failures 59
    Info:MAIN:Using SSID []
    Info:MAIN:Using Pass []
    Info:MAIN:Main_Init_After_Delay done
    Info:MAIN:[SAFE] Time 1, idle 209699/s, free 84936, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:[SAFE] Time 2, idle 142481/s, free 84936, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:[SAFE] Time 3, idle 142670/s, free 84936, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:[SAFE] Time 4, idle 142652/s, free 84936, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:[SAFE] Time 5, idle 142633/s, free 84936, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:no flash configuration, use default
    Info:MAIN:set ip info: 192.168.4.1,255.255.255.0,192.168.4.1
    Info:MAIN:ssid:multifunction_alarm_OpenBK7231N_E  key: mode:0
    hostapd_main_exiting
    hostapd_exit_handler
    hostapd_exit_done
    Soft_AP_start
    [saap]MM_RESET_REQ
    [bk]tx_txdesc_flush
    [saap]ME_CONFIG_REQ
    [saap]ME_CHAN_CONFIG_REQ
    [saap]MM_START_REQ
    hapd_intf_add_vif,type:3, s:0, id:0
    rw_ieee80211_get_centre_frequency:220
    
    .
  • #23 21074733
    p.kaczmarek2
    Moderator Smart Home
    Have you moved anything with the RF partition? I've seen virtually no such errors.
    Helpful post? Buy me a coffee.
  • #24 21075134
    burba
    Level 9  
    p.kaczmarek2 wrote:
    Have you moved anything with the RF partition? I've practically never seen this type of error.
    Consciously certainly not. Unless in the flashing software some tickbox I could have ticked. And certainly not before the flashing itself.

    The hardware was successfully recovered. Uploading openBeken did not help - I had to upload the tuya firmware first and then openBeken. I then uploaded the build with "motion" via OTA.
    In the meantime, I removed all MQTT from the HA and Zigbee by the way. I reinstalled from scratch, set only pin 22 to dinput, changed a few channels to "motion" and tried adding and deleting the device with MQTT on different channels - unfortunately without success. HA and the device were rebooted several times each.
    Screenshot showing the configuration of an OpenBeken BK7231N device. Screenshot of Home Assistant interface with information about device BK7231N.
    Message 21 received on homeassistant/sensor/multifunction_PIR_OpenBK7231N_E1552B06_build/config at 12:00 AM:
    
    {
        "dev": {
            "ids": [
                "multifunction_PIR_OpenBK7231N_E1552B06"
            ],
            "name": "multifunction_PIR_obkE1552B06",
            "sw": "1215_merge_b99f04ae6cce",
            "mf": "Beken Corporation",
            "mdl": "BK7231N",
            "cu": "http://192.168.11.110/index"
        },
        "name": "Build",
        "~": "multifunction_PIR_obkE1552B06",
        "avty_t": "~/connected",
        "uniq_id": "multifunction_PIR_OpenBK7231N_E1552B06_build",
        "qos": 1,
        "stat_t": "~/build",
        "entity_category": "diagnostic"
    }
    
    QoS: 0 - Retain: true
    Message 20 received on homeassistant/sensor/multifunction_PIR_OpenBK7231N_E1552B06_uptime/config at 12:00 AM:
    
    {
        "dev": {
            "ids": [
                "multifunction_PIR_OpenBK7231N_E1552B06"
            ],
            "name": "multifunction_PIR_obkE1552B06",
            "sw": "1215_merge_b99f04ae6cce",
            "mf": "Beken Corporation",
            "mdl": "BK7231N",
            "cu": "http://192.168.11.110/index"
        },
        "name": "Uptime",
        "~": "multifunction_PIR_obkE1552B06",
        "avty_t": "~/connected",
        "uniq_id": "multifunction_PIR_OpenBK7231N_E1552B06_uptime",
        "qos": 1,
        "dev_cla": "duration",
        "stat_t": "~/uptime",
        "unit_of_meas": "s",
        "entity_category": "diagnostic",
        "stat_cla": "total_increasing"
    }
    
    QoS: 0 - Retain: true
    Message 19 received on homeassistant/sensor/multifunction_PIR_OpenBK7231N_E1552B06_rssi/config at 12:00 AM:
    
    {
        "dev": {
            "ids": [
                "multifunction_PIR_OpenBK7231N_E1552B06"
            ],
            "name": "multifunction_PIR_obkE1552B06",
            "sw": "1215_merge_b99f04ae6cce",
            "mf": "Beken Corporation",
            "mdl": "BK7231N",
            "cu": "http://192.168.11.110/index"
        },
        "name": "RSSI",
        "~": "multifunction_PIR_obkE1552B06",
        "avty_t": "~/connected",
        "uniq_id": "multifunction_PIR_OpenBK7231N_E1552B06_rssi",
        "qos": 1,
        "dev_cla": "signal_strength",
        "stat_t": "~/rssi",
        "unit_of_meas": "dBm",
        "entity_category": "diagnostic",
        "stat_cla": "measurement"
    }
    
    QoS: 0 - Retain: true
    
    I'm running out of ideas
  • #25 21075300
    p.kaczmarek2
    Moderator Smart Home
    As it goes on, we'll just use the publishFile command added yesterday to artificially publish JSON with the motion class:
    
    1. Create LittleFS file with any string
    2. Use command: PublishFile [TopicName] [FileName] [bOptionalForRemoveGet]
    	Like: PublishFile myTopic myFile.txt 1
    

    but it shouldn't be like that, something is wrong, so we test further:
    User interface screen of BK7231T_FourRelays application showing relay status
    Last version build:
    https://github.com/openshwprojects/OpenBK7231.../actions/runs/9013302087/artifacts/1486811338
    OTA:
    Screenshot of the OTA interface for BK7231T chipset with update options.
    Now Motion channel:
    Screenshot of pin settings and channel types for a TuyaMCU device.
    Discovery:
    Configuration screen of BK7231T_FourRelays device for Home Assistant with MQTT settings.

    Result - is:
    Screenshot of the BK7231T device configuration interface with firmware information and controls.

    Try again with dInput on the same channel (4):
    Screenshot of the interface with channel settings for an electronic device.

    It is:
    IoT system user interface with device information and controls

    Maybe try this version what I gave the compilation?

    maybe you have something in the flags?
    Configuration flags settings list for smart home devices. .
    Helpful post? Buy me a coffee.
  • #26 21075610
    burba
    Level 9  

    I've got the flags clear - apart from the MQTT broadcast - but I guess that's supposed to be there? Autoexec.bat, nor anything else post-brick either, I haven't done anymore. Absolute minimum.
    Screenshot of OpenBeken interface with device flag settings.
    With the latest build no change.
    If I understand correctly from the screenshots, with you the dinput pin appears in the HA "sensors" panel even with the channel set to default? And the channel next to it set as "motion" appears in "sensors" even if no active pin is paired with it? Interesting

    I also have a relay previously converted to OpenBeken. Everything works - but it's unlikely to do anything for us, as there are no sensors there.
    MINI Smart Switch and its packaging. Close-up of a circuit board with an integrated circuit and various electronic components.

    I have another PIR tuya, but only yesterday after a hard battle did I manage to flash it. Interestingly the flashing worked on the three wires (GND, RX, TX), right from the GND connection, without any contact shorting or power cycle, but each time it was interrupted before the end. I guessed it was probably the TuyaMCU cutting off (even though the chip on the board looks different to the ones in the photos), plugged GND and 3.3V directly into CB3S and it finally went. Unfortunately it's nightmarishly troublesome - it keeps disconnecting from wifi. In order to connect to its AP at all and set up the MQTT and SSID of its network, I had to power the CB3S board directly again. Now it switches on to wifi every 10-15s or so for 2s or so. The OBK web interface when connected like this with an annoying hiccup but it works. Is it possible to somehow force TuyaMCU not to save power as much? I'll let you know when I manage to get it under control enough for the sensor to check in HA.
    Circuit board and Tuya motion sensor box. Image of an electronic module with components on a circuit board, including a CB3S module..
  • Helpful post
    #27 21075733
    p.kaczmarek2
    Moderator Smart Home
    burba wrote:
    I've got the flags clear - except for the MQTT broadcast - but I guess that's supposed to be there?

    This doesn't change anything.


    burba wrote:

    If I understand correctly from the screenshots, in you the dinput pin appears in the HA "sensors" panel even with the channel set to default? And the channel next to it set as "motion" appears in "sensors" even if no active pin is paired with it? Interesting.

    A completely clean OBK with just the Motion channel will be seen correctly by HA. Likewise, a pure OBK with dInput will be seen correctly by HA (but no longer as Motion).
    It is worth noting here that the channel types have priority. If they are not set then OBK guesses at the pins.

    burba wrote:

    I also have a relay previously converted to OpenBeken. Everything works - but it's unlikely to do anything for us, as there are no sensors there.

    Upload the latest version of OBK onto anything (but from these links what I'm giving, as the main build is broken temporarily), set the Motion channel, save ("Save"), do HA Discovery and you should be able to see this channel in HA. You don't need anything else, no pins.


    burba wrote:

    I have another PIR tuya, but I only managed to flash it yesterday after hard battles. Interestingly the flashing worked on three wires (GND, RX, TX), immediately after connecting GND, without any contact shorting or power cycle, but every time it was interrupted before the end.
    Maybe this is a phenomenon?
    Microcontroller works without power connection? Running on GND and UART alone, a conundrum.
    burba wrote:
    I guessed that it was probably the TuyaMCU cutting off (even though the chip on the board looks different to the ones in the photos), plugged GND and 3.3V directly into CB3S and it finally went. Unfortunately it's nightmarishly troublesome - it keeps disconnecting from wifi. In order to connect to its AP at all and set up the MQTT and SSID of its network, I had to power the CB3S board directly again. It now switches on to wifi every 10-15s or so for 2s or so. The OBK web interface when connected like this with an annoying hiccup but it works. Is it somehow possible to force TuyaMCU not to save power as much? I'll let you know when I've managed to get it under control enough to check the sensor in HA.

    And no, MCU though. I don't like devices of this type, we have tmSensor for that but they are problematic:
    https://www.elektroda.pl/rtvforum/find.php?q=tmSensor
    We have no control over the MCU. Maybe it is better to convert to DeepSleep


    Since further motion does not work then let's do it differently.
    You can artificially do a HASS discovery.
    1. create a file myFile.txt in LittleFS
    2. put a JSON HASS in it, for example:
    Code: JSON
    Log in, to see the code

    3. use the command:
    
    publishFile homeassistant/binary_sensor/WinTest_3145CAFF_binary_sensor_1/config myFile.txt 1
    

    This should artificially publish the Discovery with Motion channel and HA should detect it. Of course to use this in practice you need to correct the fields in the JSON to match yours.
    Helpful post? Buy me a coffee.
  • #28 21076009
    burba
    Level 9  

    Well, success!"
    But not in the way anyone would expect at this point.
    Manually uploading a file with the fake Discovery corrected to my settings did not help. There was no trace of it at all in the MQTT logs in HA.
    On the other hand, on this second PIR from tuyaMCU after uploading the custom build with motion sensor it appears.

    And then it occurred to me that maybe just the device name is too long and "doesn't come through". And bingo! All I had to do was shorten the "multifunction" part of the name to "mf". Then, just to be sure, I restored the long name for a test and again it didn't work.
    Screenshot of MQTT control panel displaying device information.
    But without that "motion" channel type you added, it doesn't show the PIR as a sensor. So that means, however, that the thread was very productive and the motion channel is needed.

    Now I won't swear anymore, but in this relay, whose pictures I inserted I think also openBeken loaded on just GND, RX, TX.

    I will read about this conversion from tuyaMCU to DeepSleep. And for future battery-powered devices I'll just take ZigBee.

    Big thanks!
  • #29 21076203
    p.kaczmarek2
    Moderator Smart Home
    That's valuable information, but in that case, didn't you get an error in the log that the name was too long?
    Screenshot from Microsoft Visual Studio editor showing C code for MQTT function in OpenBK7231T project
    I can increase those buffers anyway...

    Added after 5 [minutes]:

    Fixed:
    https://github.com/openshwprojects/OpenBK7231...mmit/32de473ed45b5bea5cddee9a65d6928d41a99a31
    And to set a test to verify that it already works:
    https://github.com/openshwprojects/OpenBK7231...mmit/c525a0002e46c63c3d3c94b02b7614302661cfbc
    Helpful post? Buy me a coffee.
  • #30 21076385
    burba
    Level 9  
    Well now actually when I checked it the error was showing. Just need to know what and where to look ;-)


    was like this:

    Info:MAIN:Time 7501, idle 181852/s, free 71072, MQTT 1(5), bWifi 1, secondsWithNoPing 7436, socks 2/38 
    Info:HTTP:HASS counts: 1 rels, 1 pwms, 1 inps, 0 excluded
    Info:MQTT:Queued topic=homeassistant/light/multifunction_PIR_OBK7231N_E1552B06_light_1/config, 1 items in queue
    Error:MQTT:Unable to queue! Topic (13), channel (72) or value (406) exceeds size limit
    Info:MQTT:Queued topic=homeassistant/sensor/multifunction_PIR_OBK7231N_E1552B06_rssi/config, 2 items in queue
    Info:MQTT:Queued topic=homeassistant/sensor/multifunction_PIR_OBK7231N_E1552B06_uptime/config, 3 items in queue
    Info:MQTT:Queued topic=homeassistant/sensor/multifunction_PIR_OBK7231N_E1552B06_build/config, 4 items in queue
    


    and with the short name is like this:

    Info:HTTP:HASS counts: 1 rels, 1 pwms, 1 inps, 0 excluded
    Info:MQTT:Queued topic=homeassistant/light/mf_PIR_OBK7231N_E1552B06_light_1/config, 1 items in queue
    Info:MQTT:Queued topic=homeassistant/binary_sensor/mf_PIR_OBK7231N_E1552B06_binary_sensor_1/config, 2 items in queue
    Info:MQTT:Queued topic=homeassistant/sensor/mf_PIR_OBK7231N_E1552B06_rssi/config, 3 items in queue
    Info:MQTT:Queued topic=homeassistant/sensor/mf_PIR_OBK7231N_E1552B06_uptime/config, 4 items in queue
    Info:MQTT:Queued topic=homeassistant/sensor/mf_PIR_OBK7231N_E1552B06_build/config, 5 items in queue
    
    .

Topic summary

The discussion revolves around configuring a "PiR Multifunction Alarm" device flashed with OpenBeken firmware to function correctly as a motion sensor in Home Assistant (HA). The user initially faced issues with the device being recognized as a "control" instead of a "sensor." Solutions proposed included adjusting the pin settings to PWM for the speaker and changing the channel type to Motion. Despite attempts to configure the device correctly, including using the latest firmware and performing HA discovery, the device continued to be detected incorrectly. Eventually, it was discovered that shortening the device name resolved the issue, allowing the motion channel to be recognized properly in HA. The conversation also touched on the importance of MQTT configuration and the potential impact of long names on device recognition.
Summary generated by the language model.
ADVERTISEMENT