logo elektroda
logo elektroda
X
logo elektroda

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

burba 5625 31
Best answers

How can I make an OpenBeken Tuya PIR device appear as a Home Assistant sensor instead of a control/switch, and can I make its speaker play the original Tuya notification sound?

Use a Motion channel type for the PIR and run Home Assistant Discovery; a clean OBK with only the Motion channel is discovered as a `binary_sensor`, while a plain `dInput` is treated as a switch/control [#21075733] In this case the discovery packet was not being queued because the generated MQTT topic/value exceeded size limits (`Unable to queue! Topic (13), channel (72) or value (406) exceeds size limit`), so shortening the device name from `multifunction...` to `mf...` made the `binary_sensor` appear in HA [#21076385][#21076009][#21076396] If you need to debug it, remove extra channels/pins and listen to the MQTT discovery topic directly; `publishFile` can also be used to publish a test HASS discovery JSON [#21075733] For the speaker, set that pin to `PWM` and adjust `PWMFrequency`; OBK has no built-in melodies yet, so a ding-dong sound would need to be scripted or added in a custom driver [#21072769]
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • Helpful post
    #31 21076396
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14440
    Help: 650
    Rate: 12410
    It should now be working and I will still add some more situations with long names to the automatic tests tomorrow
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • Helpful post
    #32 21100003
    Zogdan
    Level 10  
    Posts: 25
    Help: 6
    Rate: 13

    >>21075610
    Some references (for those searching this device): Model P01 Board ID = P01-CB3S_v1.4 Wifi pir motion sensor SKU 760269890742

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.
Generated by the language model.

FAQ

TL;DR: In a 15-question troubleshooting thread, the fix was twofold: add the new Motion channel type and shorten the device name. As one maintainer put it, "I can increase those buffers." This FAQ helps OpenBeken and Home Assistant users turn a BK7231N Tuya PIR from a wrongly discovered switch into a working motion sensor for Alarmo. [#21076203]

Why it matters: If Home Assistant discovers a PIR as a light or switch, Alarmo cannot use it as a proper motion-triggering binary sensor.

Option Home Assistant result Best use case Main limitation
dInput only Often discovered as switch/control Simple digital input Not enough for Alarmo motion use
Motion channel type Discovered as binary_sensor with motion class PIR for Alarmo Required newer test build
DoorSnsrWSleep Can sleep the device Battery-oriented sensors Unwanted on USB-powered PIR
Speaker pin as LED Chirps only Quick pin test Not a real chime mode
Speaker pin as PWM Speaker works Buzzer/chime experiments No built-in tunes yet

Key insight: The final blocker was not only channel mapping. A long OpenBeken device name overflowed the MQTT discovery queue, so Home Assistant never received the motion binary_sensor payload until the name was shortened.

Quick Facts

  • The affected PIR used BK7231N, and one working OTA shown in the thread reported version 1.17.571, built on May 3 2024 21:03:04. [#21073089]
  • The Home Assistant instance under test ran 2024.5.2 on Proxmox, so the issue was not tied to an old HA release. [#21073808]
  • Recovery logs showed UART output on TX2 at 115200 baud, and the maintainer also suggested restoring from a 2MB flash backup if needed. [#21074237]
  • One unstable TuyaMCU PIR connected to Wi‑Fi for only about 2 seconds every 10–15 seconds, which made web UI access and testing difficult. [#21075610]
  • The recovered access point used default network settings of 192.168.4.1/255.255.255.0, confirming safe-mode AP startup even after configuration loss. [#21074667]

How do I make a BK7231N Tuya PIR running OpenBeken show up in Home Assistant as a motion sensor instead of a control or switch?

Set the PIR channel type to Motion, save the type, rerun Home Assistant Discovery, and keep the device name short enough to avoid MQTT queue overflows. In this case, shortening multifunction to mf made Home Assistant finally receive the binary_sensor discovery payload. Without the new Motion type, the PIR stayed a control or switch and Alarmo could not use it correctly. [#21076009]

Why does a PIR channel set to dInput in OpenBeken get discovered by Home Assistant as a switch instead of a binary_sensor?

Because dInput describes the pin role, not the Home Assistant device class. The maintainer stated that if channel types are not set, OpenBeken guesses from the pins, and a pure dInput input is seen correctly by HA but not as Motion. That is why a PIR wired as dInput alone can appear as a switch or control instead of a motion binary_sensor. [#21075733]

What channel type should I use in OpenBeken for a Tuya WiFi Smart PIR so Alarmo in Home Assistant recognizes it correctly?

Use the Motion channel type. The maintainer added that channel specifically so Home Assistant Discovery could publish dev_cla: motion under binary_sensor, which is the format Alarmo expects. The thread confirmed that OpenClosed and OpenClosed_Inv did not solve the problem for this PIR. [#21072973]

How can I trigger Home Assistant Discovery again in OpenBeken after changing a PIR channel from OpenClosed to Motion?

Do it in three steps. 1. Remove the device from Home Assistant’s MQTT integration. 2. Reboot or restart the OpenBeken device. 3. In OpenBeken, open Config -> Home Assistant Configuration -> Start Home Assistant Discovery. That exact sequence was used during testing after switching channel types. [#21073250]

What is the Motion channel type in OpenBeken, and how does it affect Home Assistant MQTT discovery?

"Motion" is a channel type that marks a channel as a motion-class binary sensor, overriding generic pin guessing and shaping Home Assistant Discovery output. In the thread, the maintainer showed the resulting MQTT JSON used homeassistant/binary_sensor/.../config with "dev_cla": "motion", "pl_on": "1", and "pl_off": "0". That is what makes HA treat the entity as motion instead of a switch. [#21073728]

What is dInput in OpenBeken, and when should I use it instead of DoorSnsrWSleep for a USB-powered PIR sensor?

Use dInput when the PIR is USB-powered and should stay awake. "dInput" is a digital-input pin role that reads binary state changes from a GPIO, without adding sleep behavior designed for low-power door or wake-up sensors. The original user explicitly chose dInput because DoorSnsrWSleep was putting a USB-powered device to sleep unnecessarily. [#21072369]

How can I use PWM on an OpenBeken device to drive the built-in speaker and recreate the Tuya 'ding dong' sound?

Set the speaker pin role to PWM and tune the PWM settings, especially PWMFrequency. That immediately brought the speaker to life in the thread, and OpenBeken exposed a toggle plus a brightness slider for testing. There were no pre-programmed tunes at that time, so recreating a real ding dong required manual tuning, scripting, or writing a simple driver. [#21072769]

Why does setting the speaker pin as LED in OpenBeken only make the buzzer chirp, and how should PWMFrequency be configured instead?

It chirps because LED mode drives the pin like a light output, not like an audio signal. The maintainer advised switching the pin to PWM and experimenting with both fill and PWMFrequency, because frequency control determines how the buzzer sounds. The thread also notes that raw PWM controls can be exposed and automated from autoexec.bat if needed. [#21072973]

What steps should I follow in Home Assistant MQTT to listen to discovery topics and verify what OpenBeken is publishing?

Use this 3-step check. 1. Open the MQTT integration in Home Assistant. 2. Go to Configure and use the listen option on the homeassistant discovery topic tree. 3. Trigger OpenBeken Discovery and inspect the JSON payloads. That method let the user confirm which sensor, light, and missing binary_sensor configs were actually published. [#21073815]

Why would OpenBeken publish RSSI, uptime, and build sensors but fail to publish the Motion binary_sensor discovery payload?

Because the motion payload could be dropped before queueing, while shorter diagnostic payloads still fit. In the failing case, Home Assistant saw RSSI, uptime, and build topics, but no motion binary_sensor. The final diagnosis showed a name-length issue, so the motion payload path or value exceeded the internal queue size while smaller diagnostic entities still published. [#21076385]

How do long device names in OpenBeken break Home Assistant MQTT discovery, and which log message shows the topic or value size limit was exceeded?

Long names can overflow the MQTT discovery queue, preventing a motion entity from being published at all. The decisive log line was: Error:MQTT:Unable to queue! Topic (13), channel (72) or value (406) exceeds size limit. With the long name, the motion payload never queued; with the shortened name, the binary_sensor topic queued normally. [#21076385]

What's the difference between using a short device name and a long device name for OpenBeken MQTT discovery topics in Home Assistant?

A short name allows the full discovery topic and JSON to fit, while a long name can silently block the motion entity. In this case, renaming multifunction_PIR... to mf_PIR... changed the result immediately: the short-name logs showed homeassistant/binary_sensor/.../config queued successfully, while the long-name logs did not. That difference directly determined whether Home Assistant created a motion sensor. [#21076385]

How can I use the publishFile command in OpenBeken with LittleFS to manually publish a Home Assistant discovery JSON for a motion sensor?

Do it in three steps. 1. Create a file in LittleFS containing a valid Home Assistant discovery JSON. 2. Point the topic to a motion binary sensor config path. 3. Run publishFile homeassistant/binary_sensor/WinTest_3145CAFF_binary_sensor_1/config myFile.txt 1. The maintainer gave that exact pattern as a workaround for manually publishing a dev_cla: motion discovery packet. [#21075733]

What is LittleFS in OpenBeken, and how is it used for storing files like custom Home Assistant discovery payloads?

"LittleFS" is a small flash file system that stores user files directly on the device, including text files later published over MQTT or reused by scripts. In the thread, it was used to hold myFile.txt, which contained a custom Home Assistant discovery JSON later sent with the publishFile command. [#21075733]

For battery-powered PIR devices, how does a TuyaMCU-based sensor compare with a DeepSleep conversion or ZigBee option for stability and power saving?

The thread favors DeepSleep conversion or ZigBee over TuyaMCU for battery PIRs. One TuyaMCU sensor was described as connecting to Wi‑Fi for only about 2 seconds every 10–15 seconds, making it hard to configure and unstable to use. The maintainer said there is no control over the MCU’s power behavior and suggested DeepSleep instead; the user concluded future battery devices would be ZigBee. [#21076009]
Generated by the language model.
ADVERTISEMENT