Skip to content

Add Sonoff SNZB-03P motion sensor - #4628

Open
3jam3 wants to merge 7 commits into
zigpy:devfrom
3jam3:dev
Open

Add Sonoff SNZB-03P motion sensor#4628
3jam3 wants to merge 7 commits into
zigpy:devfrom
3jam3:dev

Conversation

@3jam3

@3jam3 3jam3 commented Jan 7, 2026

Copy link
Copy Markdown

This PR adds a stable and practical quirk for the Sonoff SNZB‑03P motion sensor. It fixes incorrect motion behavior, exposes the illumination state, and provides a working motion timeout configuration.

Key features:
Adds vendor illumination cluster 0xFC11 with attribute 0x2001 (Dark/Light)

Maps motion timeout to OccupancySensing delay for full ZHA compatibility

Removes IAS Zone to avoid duplicate binary_sensor

Provides a working Number entity for motion timeout (5–60 seconds)

No vendor‑specific write overrides required — stable and ZHA‑safe

Fully tested with real hardware

Why this PR?
The existing PR (#3979) attempted to add support but relied on vendor‑specific clusters that caused issues with ZHA’s attribute handling. This version is simpler, more robust, and works reliably with the current ZHA architecture.

Tested on:
Sonoff SNZB‑03P (firmware 0x00002201)

ZHA with Sonoff Dongle‑M

Home Assistant 2024.x

Result:
Motion works correctly

Illumination updates reliably

Timeout slider works and writes successfully

No duplicate entities

No errors in logs

Proposed change

Additional information

Device diagnostics

Checklist

  • The changes are tested and work correctly
  • pre-commit checks pass / the code has been formatted using Black
  • Tests have been added to verify that the new code works
  • Device diagnostics data has been attached

3jam3 and others added 2 commits January 7, 2026 15:53
This PR adds a stable and practical quirk for the Sonoff SNZB‑03P motion sensor.
It fixes incorrect motion behavior, exposes the illumination state, and provides a working motion timeout configuration.

Key features:
Adds vendor illumination cluster 0xFC11 with attribute 0x2001 (Dark/Light)

Maps motion timeout to OccupancySensing delay for full ZHA compatibility

Removes IAS Zone to avoid duplicate binary_sensor

Provides a working Number entity for motion timeout (5–60 seconds)

No vendor‑specific write overrides required — stable and ZHA‑safe

Fully tested with real hardware

Why this PR?
The existing PR (zigpy#3979) attempted to add support but relied on vendor‑specific clusters that caused issues with ZHA’s attribute handling.
This version is simpler, more robust, and works reliably with the current ZHA architecture.

Tested on:
Sonoff SNZB‑03P (firmware 0x00002201)

ZHA with Sonoff Dongle‑M

Home Assistant 2024.x

Result:
Motion works correctly

Illumination updates reliably

Timeout slider works and writes successfully

No duplicate entities

No errors in logs

@3jam3 3jam3 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As requested, here is the updated and stable SNZB‑03P quirk.

Changes included:

  • Added vendor illumination cluster (0xFC11)
  • Added Dark/Light enum sensor
  • Removed IAS Zone to avoid duplicate motion entities
  • Implemented motion timeout using OccupancySensing delay (fully ZHA‑compatible)
  • Clean and stable implementation without vendor-specific write overrides

This PR replaces PR #3979 as discussed.

@codecov

codecov Bot commented Jan 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.08%. Comparing base (69bdc15) to head (3270922).
⚠️ Report is 16 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #4628   +/-   ##
=======================================
  Coverage   93.07%   93.08%           
=======================================
  Files         401      402    +1     
  Lines       13306    13322   +16     
=======================================
+ Hits        12385    12401   +16     
  Misses        921      921           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

3jam3 and others added 4 commits January 7, 2026 16:04
Updated the Sonoff SNZB-03P quirk with improved class definitions and added docstrings for clarity.
@panther7 panther7 mentioned this pull request Jan 7, 2026
3 tasks
@panther7

panther7 commented Jan 7, 2026

Copy link
Copy Markdown

@3jam3 modify PR title to: "Add Sonoff SNZB-03P motion sensor"

@3jam3

3jam3 commented Jan 14, 2026

Copy link
Copy Markdown
Author

CI fails due to zigpy not supporting Python 3.12/3.13 yet.
My PR is unaffected, will rerun once zigpy is updated.

@TheJulianJES TheJulianJES changed the title Add files via upload Add Sonoff SNZB-03P motion sensor Jan 14, 2026
@davidwoolterton1960-glitch

Copy link
Copy Markdown

I am relatively new to HA, but because I was having issues with what I thought were ZHA ones, I came across this post, but it started in another post from Jan 2024 from what I could see, but maybe earlier. Now I am also having all the same issues as everybody else on ZHA with these devices. By the sounds of it this is very close to resolved.

My question would be if this is the case then when can the community expect to see this incorporated with in Home Assistant.

Home Assistant Green user
OS 17.1
Core 1026.2.2
SLZB-MR4U for ZHA

I know HA is all developed by supporters / volunteers, but 2 years and sill no time scales for a fix date to incorporate within HA.

@GillesLT

GillesLT commented May 17, 2026

Copy link
Copy Markdown

I have installed this quirk for my SNZB-03P semsor, but the illumination entity remains in the "unknown" state, even thugh I have restarted my HA and reconfigured the sensor after applying the quirk. Any clue?

image

Environment
Installation method Home Assistant OS
Core 2026.5.2
Supervisor 2026.05.0
Operating System 17.3
Frontend 20260429.4

@danielcolquitt

Copy link
Copy Markdown

I have installed this quirk for my SNZB-03P semsor, but the illumination entity remains in the "unknown" state, even thugh I have restarted my HA and reconfigured the sensor after applying the quirk. Any clue?

I can confirm the same bug (illumination reports unknown).

Envionment

SNZB-03P (Firmware: 0x00002201)
Home Assistant (Docker) 2026.5.1
ZHA via ZBT-2

@danielcolquitt

Copy link
Copy Markdown

I tested this PR/custom quirk on:

  • Device: SONOFF SNZB-03P
  • Firmware: 0x00002201
  • HA: 2026.5.1 Container
  • ZHA
  • Coordinator: Home Assistant Connect ZBT-2

The quirk applies and creates the Illumination enum sensor, but with the current attribute definition the sensor remains unknown/null.

Debug log during a motion event shows that the device does report illumination:

[0xF90B:1:0xfc11] Received command 0x0A (TSN 123): Report_Attributes(attribute_reports=[Attribute(attrid=0x2001, value=TypeValue(type=uint8_t, value=1))])
[zha.zigbee.cluster_handlers] [0xF90B:1:0xfc11]: cluster_handler[sonoff_illumination] attribute_updated - cluster[SonoffIlluminationCluster] attr[None] value[1]

So attribute 0x2001 is being received on cluster 0xFC11, but it is not being mapped to last_illumination_state.

The working version for me defines the attribute as report-only and non-manufacturer-specific:

last_illumination_state = ZCLAttributeDef(
    id=0x2001,
    type=LastIlluminationState,
    access="p",
    is_manufacturer_specific=False,
)

After a full HA restart and a fresh motion event, the sensor updates correctly:

state:
  translated: Light
  raw: Light
attributes:
  device_class: enum

So the cluster is manufacturer-specific (0xFC11), but the reported attribute itself appears to arrive without a manufacturer-specific ZCL header.

The key change appears to be:

 last_illumination_state = ZCLAttributeDef(
     id=0x2001,
     type=LastIlluminationState,
-    access="rp",
-    is_manufacturer_specific=True,
+    access="p",
+    is_manufacturer_specific=False,
 )

@papp-a-benedek

Copy link
Copy Markdown

@danielcolquitt you are awesome professor!

@danielcolquitt

danielcolquitt commented May 26, 2026

Copy link
Copy Markdown

This and related issues have been open for several years. How can I help move this forward and get it merged?

@zigpy-review-bot zigpy-review-bot added bot: needs changes PR needs changes per LLM bot: 2.0 migration needed PR needs ZHA/quirks 2.0.0 migration per LLM new quirk Adds support for a new device bot: small PR PR is small per LLM labels Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot: needs changes PR needs changes per LLM bot: small PR PR is small per LLM bot: 2.0 migration needed PR needs ZHA/quirks 2.0.0 migration per LLM new quirk Adds support for a new device

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants