Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/data/devices/lumi-lumi-sensor-86sw2.json
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@
"entity_category": "diagnostic",
"entity_registry_enabled_default": true,
"enabled": true,
"primary": true,
"primary": false,
"extra_state_attribute_names": [],
"device_ieee": "00:15:8d:00:02:54:cb:fa",
"endpoint_id": 1,
Expand Down
2 changes: 1 addition & 1 deletion tests/data/devices/lumi-lumi-sensor-magnet-aq2.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
"entity_category": null,
"entity_registry_enabled_default": true,
"enabled": true,
"primary": false,
"primary": true,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This flip is the most interesting one in the PR and isn't mentioned in the description. On dev this device has no primary entity — Opening (weight 1) tied with DeviceTemperature (weight 1), and _compute_primary_entity fails both candidates on a tie. So besides preventing the wrong entity from being primary, this PR also gives a very common Aqara door sensor its correct primary entity back.

@TheJulianJES TheJulianJES Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That is a very good point. I've added it to the PR body.

"extra_state_attribute_names": [],
"device_ieee": "00:15:8d:00:01:ab:40:52",
"endpoint_id": 1,
Expand Down
2 changes: 1 addition & 1 deletion tests/data/devices/lumi-lumi-sensor-switch-aq2.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
"entity_category": "diagnostic",
"entity_registry_enabled_default": true,
"enabled": true,
"primary": true,
"primary": false,
"extra_state_attribute_names": [],
"device_ieee": "00:15:8d:00:02:13:91:38",
"endpoint_id": 1,
Expand Down
2 changes: 1 addition & 1 deletion tests/data/devices/lumi-lumi-sensor-switch-aq3.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
"entity_category": "diagnostic",
"entity_registry_enabled_default": true,
"enabled": true,
"primary": true,
"primary": false,
"extra_state_attribute_names": [],
"device_ieee": "00:15:8d:00:02:b0:e5:91",
"endpoint_id": 1,
Expand Down
1 change: 0 additions & 1 deletion zha/application/platforms/sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2740,7 +2740,6 @@ class DeviceTemperature(Sensor):
_divisor = 100
_attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS
_attr_entity_category = EntityCategory.DIAGNOSTIC

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Correct removal — and this line right here is the argument for it: an entity that is permanently EntityCategory.DIAGNOSTIC should never be a candidate for "the entity that represents this device".

Optional: consider locking the behaviour in with a case in test_primary_entity_computation (tests/test_device.py:891) rather than leaving it to the snapshots alone. Two cheap additions would document both halves of the intent:

# Door sensor whose diagnostic device-temperature sensor previously tied with it
(
    "tests/data/devices/lumi-lumi-sensor-magnet-aq2.json",
    Platform.BINARY_SENSOR,
    Opening,
),
# Remote with no user-facing entities: device temperature must not become primary
(
    "tests/data/devices/lumi-lumi-sensor-switch-aq2.json",
    None,
    None,
),

The snapshots do cover this today, but as four unlabelled boolean flips among ~870 files — a future regen would re-bless a regression without anyone reading the intent. #859 adds an explicit test for its half; this is the symmetric one.

_attr_primary_weight = 1
_cluster_id = DeviceTemperatureCluster.cluster_id

_cluster_match = ClusterMatch(
Expand Down
Loading