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
8 changes: 4 additions & 4 deletions tests/data/devices/ubisys-s1-5501.json
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@
"unique_id": "ab:cd:ef:12:e4:d6:5c:c2-3-1794-summation_delivered",
"migrate_unique_ids": [],
"platform": "sensor",
"class_name": "SmartEnergySummation",
"class_name": "ExposedFeaturePolledSmartEnergySummation",
"translation_key": "summation_delivered",
"translation_placeholders": null,
"device_class": "energy",
Expand Down Expand Up @@ -1027,7 +1027,7 @@
"unit": "kWh"
},
"state": {
"class_name": "SmartEnergySummation",
"class_name": "ExposedFeaturePolledSmartEnergySummation",
"available": true,
"state": 0.0,
"status": "NO_ALARMS",
Expand All @@ -1045,7 +1045,7 @@
"unique_id": "ab:cd:ef:12:e4:d6:5c:c2-3-1794-summation_received",
"migrate_unique_ids": [],
"platform": "sensor",
"class_name": "SmartEnergySummationReceived",
"class_name": "ExposedFeaturePolledSmartEnergySummationReceived",
"translation_key": "summation_received",
"translation_placeholders": null,
"device_class": "energy",
Expand Down Expand Up @@ -1078,7 +1078,7 @@
"unit": "kWh"
},
"state": {
"class_name": "SmartEnergySummationReceived",
"class_name": "ExposedFeaturePolledSmartEnergySummationReceived",
"available": true,
"state": 0.0,
"status": "NO_ALARMS",
Expand Down
3 changes: 3 additions & 0 deletions zha/application/platforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class PlatformFeatureGroup(StrEnum):
# Model-specific overrides for Smart Energy Summation
SMART_ENERGY_SUMMATION = "smart_energy_summation"

# Overrides for Smart Energy Summation Received
SMART_ENERGY_SUMMATION_RECEIVED = "smart_energy_summation_received"

# Model-specific overrides for local temperature calibration
LOCAL_TEMPERATURE_CALIBRATION = "local_temperature_calibration"

Expand Down
27 changes: 26 additions & 1 deletion zha/application/platforms/sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from typing import TYPE_CHECKING, Any, cast

from zhaquirks.danfoss import thermostat as danfoss_thermostat
from zhaquirks.quirk_ids import DANFOSS_ALLY_THERMOSTAT
from zhaquirks.quirk_ids import DANFOSS_ALLY_THERMOSTAT, SE_POLL_SUMMATION
from zigpy import types
from zigpy.quirks.v2 import ZCLEnumMetadata, ZCLSensorMetadata
from zigpy.state import Counter, State
Expand Down Expand Up @@ -1479,6 +1479,17 @@ class PolledSmartEnergySummation(SmartEnergySummation):
)


@register_entity(Metering.cluster_id)
class ExposedFeaturePolledSmartEnergySummation(PolledSmartEnergySummation):
"""Polled Smart Energy Metering summation sensor via exposed feature."""

_cluster_handler_match = ClusterHandlerMatch(
cluster_handlers=frozenset({CLUSTER_HANDLER_SMARTENERGY_METERING}),
exposed_features=frozenset({SE_POLL_SUMMATION}),
feature_priority=(PlatformFeatureGroup.SMART_ENERGY_SUMMATION, 1),
)


@register_entity(Metering.cluster_id)
class Tier1SmartEnergySummation(PolledSmartEnergySummation):
"""Tier 1 Smart Energy Metering summation sensor."""
Expand Down Expand Up @@ -1595,6 +1606,20 @@ class SmartEnergySummationReceived(PolledSmartEnergySummation):

_cluster_handler_match = ClusterHandlerMatch(
cluster_handlers=frozenset({CLUSTER_HANDLER_SMARTENERGY_METERING}),
feature_priority=(PlatformFeatureGroup.SMART_ENERGY_SUMMATION_RECEIVED, 0),
)


@register_entity(Metering.cluster_id)
class ExposedFeaturePolledSmartEnergySummationReceived(SmartEnergySummationReceived):
"""Polled Smart Energy Metering summation received sensor via exposed feature."""

_use_custom_polling = True

_cluster_handler_match = ClusterHandlerMatch(
cluster_handlers=frozenset({CLUSTER_HANDLER_SMARTENERGY_METERING}),
exposed_features=frozenset({SE_POLL_SUMMATION}),
feature_priority=(PlatformFeatureGroup.SMART_ENERGY_SUMMATION_RECEIVED, 1),
)


Expand Down
Loading