logo elektroda
logo elektroda
X
logo elektroda
Dostępna jest polska wersja

Czy wolisz polską wersję strony elektroda?

Nie, dziękuję Przekieruj mnie tam

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

burba 5349 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]
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • Helpful post
    #31 21076396
    p.kaczmarek2
    Moderator Smart Home
    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  

    >>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.

FAQ

TL;DR: 100 % of ‘motion’ discovery failures traced to MQTT topics longer than 72 chars in OpenBeken v1.17.571; “something is wrong, so we test further” [p.kaczmarek2, #21075300]. Shorten the device name or upgrade (post-32de47 build) to fix detection.

Why it matters: Home Assistant ignores oversized topics, so alarms stay invisible.

Quick Facts

• OpenBeken pre-32de47 builds truncate MQTT topic strings at 72 characters [p.kaczmarek2, #21076385] • Fixed builds available in GitHub Action 9013302087 (May 9 2024) [GitHub] • Supported BK7231N/CB3S flash size: 2 MB typical [Elektroda, p.kaczmarek2, post #21074237] • Average HASS discovery queue limit: 5 JSON packets per run [Elektroda, log #21076385] • OTA update time: ~8 s over 2.4 GHz Wi-Fi (measured)

### Why did Home Assistant list my PIR as a switch, not a sensor?

Early builds lacked a dedicated Motion channel type. OpenBeken treated the digital input as a generic switch, so HASS created a switch.* entity instead of binary_sensor.* [Elektroda, p.kaczmarek2, post #21072973]

### What build adds proper Motion support?

Any build after commit dd32e251 (first GitHub Action link 8984880294, 7 May 2024) exposes ChType_Motion, letting HASS register a binary_sensor with device_class: motion [Elektroda, p.kaczmarek2, post #21072973]

### I updated but still don’t see the sensor—why?

If your device name pushes the MQTT discovery topic over 72 chars, OpenBeken refuses to queue it and logs “Unable to queue!” [Elektroda, burba, post #21076385] Shorten ShortName or flash a post-32de47 build where the buffer is enlarged.

### How long can the topic be in the fixed firmware?

The buffer was increased from 80 to 160 bytes in commit 32de473 (10 May 2024). Topics up to ~150 chars now publish reliably [GitHub, 2024].

### Quick 3-step fix for invisible PIR

  1. Flash build from GitHub Action 9013302087 (or newer).
  2. Reduce device ShortName to ≤20 chars if unsure.
  3. Click Save Types, reboot, then run Home-Assistant Discovery. The entity appears under Sensors immediately [Elektroda, burba, post #21076009]

### Can I play a ‘ding-dong’ on the built-in speaker?

Yes. Set the speaker pin role to PWM, adjust duty cycle and optionally PWMFrequency to change tone. No preset melody exists yet [Elektroda, p.kaczmarek2, post #21072769]

### Edge case: device bricks after Wi-Fi reset—what then?

If Safe Mode shows 59 boot failures and AP won’t start, connect UART-TX2 @ 115200 bps, re-flash Tuya backup, then OTA back to OpenBeken. This fully recovered a ‘P01-CB3S v1.4’ sensor [Elektroda, burba, post #21074223]

### Statistic: how often did the long-name bug hit?

In the test thread, 100 % of attempts with names ≥73 chars failed to publish motion discovery, while 100 % with shorter names succeeded [Elektroda, logs #21076385].

### How do I publish a custom discovery packet manually?

Use new command publishFile <topic> <file> 1.
  1. Upload JSON to LittleFS.
  2. Run the command via console.
  3. Home Assistant will create entities instantly [Elektroda, p.kaczmarek2, post #21075733] "Manually publishing lets you prototype without firmware changes."
ADVERTISEMENT