1
0
mirror of https://github.com/home-assistant/core.git synced 2026-02-14 23:28:42 +00:00

Add Matter CO alarm state (#162627)

Co-authored-by: Ludovic BOUÉ <lboue@users.noreply.github.com>
This commit is contained in:
LeoXie
2026-02-11 06:43:32 +08:00
committed by GitHub
parent 692d3d35cc
commit 3be089d2a5
7 changed files with 1141 additions and 0 deletions

View File

@@ -251,6 +251,18 @@ DISCOVERY_SCHEMAS = [
entity_class=MatterBinarySensor,
required_attributes=(clusters.SmokeCoAlarm.Attributes.SmokeState,),
),
MatterDiscoverySchema(
platform=Platform.BINARY_SENSOR,
entity_description=MatterBinarySensorEntityDescription(
key="SmokeCoAlarmCOStateSensor",
device_class=BinarySensorDeviceClass.CO,
device_to_ha=lambda x: (
x != clusters.SmokeCoAlarm.Enums.AlarmStateEnum.kNormal
),
),
entity_class=MatterBinarySensor,
required_attributes=(clusters.SmokeCoAlarm.Attributes.COState,),
),
MatterDiscoverySchema(
platform=Platform.BINARY_SENSOR,
entity_description=MatterBinarySensorEntityDescription(

View File

@@ -95,6 +95,7 @@ async def integration_fixture(
"eve_weather_sensor",
"extended_color_light",
"haojai_switch",
"heiman_co_sensor",
"heiman_motion_sensor_m1",
"heiman_smoke_detector",
"ikea_air_quality_monitor",

View File

@@ -0,0 +1,396 @@
{
"node_id": 6,
"date_commissioned": "2026-02-09T17:58:04.619000",
"last_interview": "2026-02-09T18:59:51.436000",
"interview_version": 6,
"available": true,
"is_bridge": false,
"attributes": {
"0/29/0": [
{
"0": 18,
"1": 1
},
{
"0": 22,
"1": 3
}
],
"0/29/1": [29, 31, 40, 42, 43, 48, 49, 51, 53, 60, 62, 63, 64, 65, 70],
"0/29/2": [41],
"0/29/3": [1],
"0/29/65533": 2,
"0/29/65532": 0,
"0/29/65531": [0, 1, 2, 3, 65528, 65529, 65531, 65532, 65533],
"0/29/65529": [],
"0/29/65528": [],
"0/31/0": [
{
"1": 5,
"2": 2,
"3": [112233],
"4": null,
"254": 6
}
],
"0/31/2": 4,
"0/31/3": 3,
"0/31/4": 4,
"0/31/65533": 2,
"0/31/65532": 1,
"0/31/65531": [0, 1, 2, 3, 4, 65528, 65529, 65531, 65532, 65533],
"0/31/65529": [],
"0/31/65528": [],
"0/31/1": [],
"0/40/0": 18,
"0/40/1": "HEIMAN",
"0/40/2": 4619,
"0/40/3": "Smart CO sensor",
"0/40/4": 4103,
"0/40/5": "",
"0/40/6": "**REDACTED**",
"0/40/7": 0,
"0/40/8": "0.0",
"0/40/9": 22,
"0/40/10": "1.6",
"0/40/11": "20260106",
"0/40/12": "",
"0/40/14": "",
"0/40/15": "2510104103001841",
"0/40/16": false,
"0/40/18": "6C2B42B9D78134FE",
"0/40/19": {
"0": 3,
"1": 3
},
"0/40/21": 17039360,
"0/40/22": 1,
"0/40/24": 1,
"0/40/65533": 4,
"0/40/65532": 0,
"0/40/65531": [
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 18, 19, 21, 22,
65528, 65529, 65531, 65532, 65533
],
"0/40/65529": [],
"0/40/65528": [],
"0/42/0": [],
"0/42/1": true,
"0/42/2": 1,
"0/42/3": null,
"0/42/65533": 1,
"0/42/65532": 0,
"0/42/65531": [0, 1, 2, 3, 65528, 65529, 65531, 65532, 65533],
"0/42/65529": [0],
"0/42/65528": [],
"0/43/0": "en-US",
"0/43/1": [
"en-US",
"de-DE",
"fr-FR",
"en-GB",
"es-ES",
"zh-CN",
"it-IT",
"ja-JP"
],
"0/43/65533": 1,
"0/43/65532": 0,
"0/43/65531": [0, 1, 65528, 65529, 65531, 65532, 65533],
"0/43/65529": [],
"0/43/65528": [],
"0/48/0": 0,
"0/48/1": {
"0": 60,
"1": 900
},
"0/48/2": 0,
"0/48/3": 0,
"0/48/4": true,
"0/48/65533": 2,
"0/48/65532": 0,
"0/48/65531": [0, 1, 2, 3, 4, 65528, 65529, 65531, 65532, 65533],
"0/48/65529": [0, 2, 4],
"0/48/65528": [1, 3, 5],
"0/49/0": 1,
"0/49/1": [
{
"0": "ETRyIaJlZag=",
"1": true
}
],
"0/49/4": true,
"0/49/5": 0,
"0/49/6": "ETRyIaJlZag=",
"0/49/7": null,
"0/49/2": 10,
"0/49/3": 20,
"0/49/9": 4,
"0/49/10": 4,
"0/49/65533": 2,
"0/49/65532": 2,
"0/49/65531": [
0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 65528, 65529, 65531, 65532, 65533
],
"0/49/65529": [0, 3, 4, 6, 8],
"0/49/65528": [1, 5, 7],
"0/51/0": [
{
"0": "OpenThread-da2f",
"1": true,
"2": null,
"3": null,
"4": "UmVBffa2WG4=",
"5": [],
"6": [
"/XJSo4t2AAGhqBaAXM3P4Q==",
"/WATBiMcSfkAAAD//gA8AQ==",
"/WATBiMcSfkwzwQTN3VNlQ==",
"/oAAAAAAAABQZUF99rZYbg=="
],
"7": 4
}
],
"0/51/1": 1,
"0/51/2": 158,
"0/51/8": true,
"0/51/65533": 2,
"0/51/65532": 0,
"0/51/65531": [0, 1, 2, 8, 65528, 65529, 65531, 65532, 65533],
"0/51/65529": [0, 1],
"0/51/65528": [2],
"0/53/0": 20,
"0/53/1": 2,
"0/53/2": "OpenThread-da2f",
"0/53/3": 5201,
"0/53/4": 1239741286217770408,
"0/53/5": "QP1gEwYjHEn5",
"0/53/7": [
{
"0": 7092274385890922468,
"1": 11,
"2": 15360,
"3": 11857,
"4": 1708,
"5": 3,
"6": -56,
"7": -56,
"8": 0,
"9": 0,
"10": true,
"11": true,
"12": true,
"13": false
}
],
"0/53/8": [
{
"0": 7092274385890922468,
"1": 15360,
"2": 15,
"3": 0,
"4": 0,
"5": 3,
"6": 3,
"7": 11,
"8": true,
"9": true
}
],
"0/53/9": 698808881,
"0/53/10": 65,
"0/53/11": 90,
"0/53/12": 196,
"0/53/13": 15,
"0/53/59": {
"0": 672,
"1": 8335
},
"0/53/60": "AB//4A==",
"0/53/61": {
"0": true,
"1": false,
"2": true,
"3": true,
"4": true,
"5": true,
"6": false,
"7": true,
"8": true,
"9": true,
"10": true,
"11": true
},
"0/53/62": [],
"0/53/63": null,
"0/53/64": null,
"0/53/65533": 3,
"0/53/65532": 0,
"0/53/65531": [
0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 59, 60, 61, 62, 65528, 65529,
65531, 65532, 65533
],
"0/53/65529": [],
"0/53/65528": [],
"0/60/0": 0,
"0/60/1": null,
"0/60/2": null,
"0/60/65533": 1,
"0/60/65532": 0,
"0/60/65531": [0, 1, 2, 65528, 65529, 65531, 65532, 65533],
"0/60/65529": [0, 2],
"0/60/65528": [],
"0/62/0": [
{
"1": "FTABAQIkAgE3AyQUABgmBJA4Oy8mBRBv6EM3BiQVASQRBhgkBwEkCAEwCUEEI2tGh1VniaIRX8d99XSEKx0NKqXmH2kRhFjFTi8KND8zpIz94wdsxVudOaNeuNptrTJkeKf+eh3ZHoSv1UkNsTcKNQEoARgkAgE2AwQCBAEYMAQU/KgBHg+GXJuHIoIrmPmr2G4JnxMwBRRUGg83ufDcSdGsQaCmiKnCGL6eexgwC0AmvSNfmSmFXyZuXrqDzvntfvjNdCfpni6WZFVFsa8Eio1rAKXzq7LqfAlDi/CrBAYNRIJ1IzXbI8b2cykkOk10GA==",
"2": null,
"254": 6
}
],
"0/62/1": [
{
"1": "BPZGSp6/spsH7Bo+QzivWJor24Z6s2FDp2HM8TUsIqaZh7f7mii5vN57HW1Jb/tPw1C7S3HFRjIYjzVvjlKTo1Y=",
"2": 65521,
"3": 1,
"4": 6,
"5": "Home",
"254": 6
}
],
"0/62/2": 5,
"0/62/3": 1,
"0/62/4": [
"FTABAQAkAgE3AyQUABgmBMf0NS8mBUcr40M3BiQUABgkBwEkCAEwCUEE9kZKnr+ymwfsGj5DOK9YmivbhnqzYUOnYczxNSwippmHt/uaKLm83nsdbUlv+0/DULtLccVGMhiPNW+OUpOjVjcKNQEpARgkAmAwBBRUGg83ufDcSdGsQaCmiKnCGL6eezAFFFQaDze58NxJ0axBoKaIqcIYvp57GDALQPv2thbQpdbySFLSNLKsA9wFW+bFFDpW1DvOFcFBOK4KlgBoZhH3lEYxA+GRIvt+povc6TrDnQ65UtocnboT+TQY"
],
"0/62/5": 6,
"0/62/65533": 1,
"0/62/65532": 0,
"0/62/65531": [0, 1, 2, 3, 4, 5, 65528, 65529, 65531, 65532, 65533],
"0/62/65529": [0, 2, 4, 6, 7, 9, 10, 11],
"0/62/65528": [1, 3, 5, 8],
"0/63/0": [],
"0/63/1": [],
"0/63/2": 4,
"0/63/3": 3,
"0/63/65533": 2,
"0/63/65532": 0,
"0/63/65531": [0, 1, 2, 3, 65528, 65529, 65531, 65532, 65533],
"0/63/65529": [0, 1, 3, 4],
"0/63/65528": [2, 5],
"0/64/0": [
{
"0": "room",
"1": "bedroom 2"
},
{
"0": "orientation",
"1": "North"
},
{
"0": "floor",
"1": "2"
},
{
"0": "direction",
"1": "up"
}
],
"0/64/65533": 1,
"0/64/65532": 0,
"0/64/65531": [0, 65528, 65529, 65531, 65532, 65533],
"0/64/65529": [],
"0/64/65528": [],
"0/65/0": [],
"0/65/65533": 1,
"0/65/65532": 0,
"0/65/65531": [0, 65528, 65529, 65531, 65532, 65533],
"0/65/65529": [],
"0/65/65528": [],
"0/70/0": 3600,
"0/70/1": 0,
"0/70/2": 20000,
"0/70/7": "Restart the application",
"0/70/65533": 3,
"0/70/65532": 15,
"0/70/65531": [
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 65528, 65529, 65531, 65532, 65533
],
"0/70/65529": [0, 2, 3],
"0/70/65528": [1, 4],
"0/70/3": [],
"0/70/4": 3985523609,
"0/70/5": 2,
"0/70/6": 4381,
"0/70/8": 0,
"0/70/9": 3600,
"1/3/0": 0,
"1/3/1": 2,
"1/3/65533": 5,
"1/3/65532": 0,
"1/3/65531": [0, 1, 65528, 65529, 65531, 65532, 65533],
"1/3/65529": [0],
"1/3/65528": [],
"1/29/0": [
{
"0": 17,
"1": 1
},
{
"0": 118,
"1": 1
}
],
"1/29/1": [3, 29, 47, 92, 1036],
"1/29/2": [],
"1/29/3": [],
"1/29/65533": 2,
"1/29/65532": 0,
"1/29/65531": [0, 1, 2, 3, 65528, 65529, 65531, 65532, 65533],
"1/29/65529": [],
"1/29/65528": [],
"1/47/0": 0,
"1/47/1": 0,
"1/47/2": "",
"1/47/31": [],
"1/47/11": 3000,
"1/47/12": 200,
"1/47/13": 0,
"1/47/14": 0,
"1/47/15": false,
"1/47/16": 0,
"1/47/19": "AA",
"1/47/24": 0,
"1/47/25": 0,
"1/47/65533": 3,
"1/47/65532": 10,
"1/47/65531": [
0, 1, 2, 11, 12, 13, 14, 15, 16, 19, 24, 25, 31, 65528, 65529, 65531,
65532, 65533
],
"1/47/65529": [],
"1/47/65528": [],
"1/92/0": 0,
"1/92/3": 0,
"1/92/4": 0,
"1/92/5": false,
"1/92/6": false,
"1/92/7": 0,
"1/92/2": 0,
"1/92/65533": 1,
"1/92/65532": 2,
"1/92/65531": [0, 2, 3, 4, 5, 6, 7, 65528, 65529, 65531, 65532, 65533],
"1/92/65529": [0],
"1/92/65528": [],
"1/1036/9": 0,
"1/1036/0": 0,
"1/1036/1": 0,
"1/1036/2": 1000,
"1/1036/8": 0,
"1/1036/65533": 3,
"1/1036/65532": 1,
"1/1036/65531": [0, 1, 2, 3, 8, 9, 65528, 65529, 65531, 65532, 65533],
"1/1036/65529": [],
"1/1036/65528": []
},
"attribute_subscriptions": []
}

View File

@@ -347,6 +347,305 @@
'state': 'off',
})
# ---
# name: test_binary_sensors[heiman_co_sensor][binary_sensor.smart_co_sensor_battery_alert-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.smart_co_sensor_battery_alert',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Battery alert',
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.BATTERY: 'battery'>,
'original_icon': None,
'original_name': 'Battery alert',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'battery_alert',
'unique_id': '00000000000004D2-0000000000000006-MatterNodeDevice-1-SmokeCoAlarmBatteryAlertSensor-92-3',
'unit_of_measurement': None,
})
# ---
# name: test_binary_sensors[heiman_co_sensor][binary_sensor.smart_co_sensor_battery_alert-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'battery',
'friendly_name': 'Smart CO sensor Battery alert',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.smart_co_sensor_battery_alert',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_binary_sensors[heiman_co_sensor][binary_sensor.smart_co_sensor_carbon_monoxide-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': None,
'entity_id': 'binary_sensor.smart_co_sensor_carbon_monoxide',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Carbon monoxide',
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.CO: 'carbon_monoxide'>,
'original_icon': None,
'original_name': 'Carbon monoxide',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': '00000000000004D2-0000000000000006-MatterNodeDevice-1-SmokeCoAlarmCOStateSensor-92-2',
'unit_of_measurement': None,
})
# ---
# name: test_binary_sensors[heiman_co_sensor][binary_sensor.smart_co_sensor_carbon_monoxide-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'carbon_monoxide',
'friendly_name': 'Smart CO sensor Carbon monoxide',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.smart_co_sensor_carbon_monoxide',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_binary_sensors[heiman_co_sensor][binary_sensor.smart_co_sensor_end_of_service-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.smart_co_sensor_end_of_service',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'End of service',
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'End of service',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'end_of_service',
'unique_id': '00000000000004D2-0000000000000006-MatterNodeDevice-1-SmokeCoAlarmEndfOfServiceSensor-92-7',
'unit_of_measurement': None,
})
# ---
# name: test_binary_sensors[heiman_co_sensor][binary_sensor.smart_co_sensor_end_of_service-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'problem',
'friendly_name': 'Smart CO sensor End of service',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.smart_co_sensor_end_of_service',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_binary_sensors[heiman_co_sensor][binary_sensor.smart_co_sensor_hardware_fault-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.smart_co_sensor_hardware_fault',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Hardware fault',
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Hardware fault',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'hardware_fault',
'unique_id': '00000000000004D2-0000000000000006-MatterNodeDevice-1-SmokeCoAlarmHardwareFaultAlertSensor-92-6',
'unit_of_measurement': None,
})
# ---
# name: test_binary_sensors[heiman_co_sensor][binary_sensor.smart_co_sensor_hardware_fault-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'problem',
'friendly_name': 'Smart CO sensor Hardware fault',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.smart_co_sensor_hardware_fault',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_binary_sensors[heiman_co_sensor][binary_sensor.smart_co_sensor_muted-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.smart_co_sensor_muted',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Muted',
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Muted',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'muted',
'unique_id': '00000000000004D2-0000000000000006-MatterNodeDevice-1-SmokeCoAlarmDeviceMutedSensor-92-4',
'unit_of_measurement': None,
})
# ---
# name: test_binary_sensors[heiman_co_sensor][binary_sensor.smart_co_sensor_muted-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Smart CO sensor Muted',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.smart_co_sensor_muted',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_binary_sensors[heiman_co_sensor][binary_sensor.smart_co_sensor_test_in_progress-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.smart_co_sensor_test_in_progress',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Test in progress',
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.RUNNING: 'running'>,
'original_icon': None,
'original_name': 'Test in progress',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'test_in_progress',
'unique_id': '00000000000004D2-0000000000000006-MatterNodeDevice-1-SmokeCoAlarmTestInProgressSensor-92-5',
'unit_of_measurement': None,
})
# ---
# name: test_binary_sensors[heiman_co_sensor][binary_sensor.smart_co_sensor_test_in_progress-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'running',
'friendly_name': 'Smart CO sensor Test in progress',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.smart_co_sensor_test_in_progress',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_binary_sensors[heiman_motion_sensor_m1][binary_sensor.smart_motion_sensor_occupancy-entry]
EntityRegistryEntrySnapshot({
'aliases': set({

View File

@@ -1599,6 +1599,105 @@
'state': 'unknown',
})
# ---
# name: test_buttons[heiman_co_sensor][button.smart_co_sensor_identify-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'button',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'button.smart_co_sensor_identify',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Identify',
'options': dict({
}),
'original_device_class': <ButtonDeviceClass.IDENTIFY: 'identify'>,
'original_icon': None,
'original_name': 'Identify',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': '00000000000004D2-0000000000000006-MatterNodeDevice-1-IdentifyButton-3-1',
'unit_of_measurement': None,
})
# ---
# name: test_buttons[heiman_co_sensor][button.smart_co_sensor_identify-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'identify',
'friendly_name': 'Smart CO sensor Identify',
}),
'context': <ANY>,
'entity_id': 'button.smart_co_sensor_identify',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_buttons[heiman_co_sensor][button.smart_co_sensor_self_test-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'button',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'button.smart_co_sensor_self_test',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Self-test',
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Self-test',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'self_test_request',
'unique_id': '00000000000004D2-0000000000000006-MatterNodeDevice-1-SmokeCoAlarmSelfTestRequest-92-65529',
'unit_of_measurement': None,
})
# ---
# name: test_buttons[heiman_co_sensor][button.smart_co_sensor_self_test-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Smart CO sensor Self-test',
}),
'context': <ANY>,
'entity_id': 'button.smart_co_sensor_self_test',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_buttons[heiman_motion_sensor_m1][button.smart_motion_sensor_identify_1-entry]
EntityRegistryEntrySnapshot({
'aliases': set({

View File

@@ -4772,6 +4772,283 @@
'state': '0',
})
# ---
# name: test_sensors[heiman_co_sensor][sensor.smart_co_sensor_battery-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.smart_co_sensor_battery',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Battery',
'options': dict({
}),
'original_device_class': <SensorDeviceClass.BATTERY: 'battery'>,
'original_icon': None,
'original_name': 'Battery',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': '00000000000004D2-0000000000000006-MatterNodeDevice-1-PowerSource-47-12',
'unit_of_measurement': '%',
})
# ---
# name: test_sensors[heiman_co_sensor][sensor.smart_co_sensor_battery-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'battery',
'friendly_name': 'Smart CO sensor Battery',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': '%',
}),
'context': <ANY>,
'entity_id': 'sensor.smart_co_sensor_battery',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '100',
})
# ---
# name: test_sensors[heiman_co_sensor][sensor.smart_co_sensor_battery_type-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.smart_co_sensor_battery_type',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Battery type',
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Battery type',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'battery_replacement_description',
'unique_id': '00000000000004D2-0000000000000006-MatterNodeDevice-1-PowerSourceBatReplacementDescription-47-19',
'unit_of_measurement': None,
})
# ---
# name: test_sensors[heiman_co_sensor][sensor.smart_co_sensor_battery_type-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Smart CO sensor Battery type',
}),
'context': <ANY>,
'entity_id': 'sensor.smart_co_sensor_battery_type',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'AA',
})
# ---
# name: test_sensors[heiman_co_sensor][sensor.smart_co_sensor_battery_voltage-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.smart_co_sensor_battery_voltage',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Battery voltage',
'options': dict({
'sensor': dict({
'suggested_display_precision': 2,
}),
'sensor.private': dict({
'suggested_unit_of_measurement': <UnitOfElectricPotential.VOLT: 'V'>,
}),
}),
'original_device_class': <SensorDeviceClass.VOLTAGE: 'voltage'>,
'original_icon': None,
'original_name': 'Battery voltage',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'battery_voltage',
'unique_id': '00000000000004D2-0000000000000006-MatterNodeDevice-1-PowerSourceBatVoltage-47-11',
'unit_of_measurement': <UnitOfElectricPotential.VOLT: 'V'>,
})
# ---
# name: test_sensors[heiman_co_sensor][sensor.smart_co_sensor_battery_voltage-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'voltage',
'friendly_name': 'Smart CO sensor Battery voltage',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfElectricPotential.VOLT: 'V'>,
}),
'context': <ANY>,
'entity_id': 'sensor.smart_co_sensor_battery_voltage',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '3.0',
})
# ---
# name: test_sensors[heiman_co_sensor][sensor.smart_co_sensor_carbon_monoxide-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.smart_co_sensor_carbon_monoxide',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Carbon monoxide',
'options': dict({
}),
'original_device_class': <SensorDeviceClass.CO: 'carbon_monoxide'>,
'original_icon': None,
'original_name': 'Carbon monoxide',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': '00000000000004D2-0000000000000006-MatterNodeDevice-1-CarbonMonoxideSensor-1036-0',
'unit_of_measurement': 'ppm',
})
# ---
# name: test_sensors[heiman_co_sensor][sensor.smart_co_sensor_carbon_monoxide-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'carbon_monoxide',
'friendly_name': 'Smart CO sensor Carbon monoxide',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': 'ppm',
}),
'context': <ANY>,
'entity_id': 'sensor.smart_co_sensor_carbon_monoxide',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '0.0',
})
# ---
# name: test_sensors[heiman_co_sensor][sensor.smart_co_sensor_time_remaining-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.smart_co_sensor_time_remaining',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Time remaining',
'options': dict({
'sensor': dict({
'suggested_display_precision': 2,
}),
'sensor.private': dict({
'suggested_unit_of_measurement': <UnitOfTime.MINUTES: 'min'>,
}),
}),
'original_device_class': <SensorDeviceClass.DURATION: 'duration'>,
'original_icon': None,
'original_name': 'Time remaining',
'platform': 'matter',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'battery_time_remaining',
'unique_id': '00000000000004D2-0000000000000006-MatterNodeDevice-1-PowerSourceBatTimeRemaining-47-13',
'unit_of_measurement': <UnitOfTime.MINUTES: 'min'>,
})
# ---
# name: test_sensors[heiman_co_sensor][sensor.smart_co_sensor_time_remaining-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'duration',
'friendly_name': 'Smart CO sensor Time remaining',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfTime.MINUTES: 'min'>,
}),
'context': <ANY>,
'entity_id': 'sensor.smart_co_sensor_time_remaining',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '0.0',
})
# ---
# name: test_sensors[heiman_motion_sensor_m1][sensor.smart_motion_sensor_battery-entry]
EntityRegistryEntrySnapshot({
'aliases': set({

View File

@@ -653,3 +653,60 @@ async def test_smoke_detector(
state = hass.states.get("binary_sensor.smoke_sensor_smoke")
assert state
assert state.state == "off"
@pytest.mark.parametrize("node_fixture", ["heiman_co_sensor"])
async def test_co_detector(
hass: HomeAssistant,
matter_client: MagicMock,
matter_node: MatterNode,
) -> None:
"""Test CO detector sensor."""
co_state_attribute = clusters.SmokeCoAlarm.Attributes.COState
# Test initial state (COState = 0, kNormal)
state = hass.states.get("binary_sensor.smart_co_sensor_carbon_monoxide")
assert state
assert state.state == "off"
# Set COState to kWarning (value 1)
set_node_attribute(
matter_node,
1,
co_state_attribute.cluster_id,
co_state_attribute.attribute_id,
1,
)
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get("binary_sensor.smart_co_sensor_carbon_monoxide")
assert state
assert state.state == "on"
# Set COState to kCritical (value 2)
set_node_attribute(
matter_node,
1,
co_state_attribute.cluster_id,
co_state_attribute.attribute_id,
2,
)
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get("binary_sensor.smart_co_sensor_carbon_monoxide")
assert state
assert state.state == "on"
# Set COState back to kNormal (value 0)
set_node_attribute(
matter_node,
1,
co_state_attribute.cluster_id,
co_state_attribute.attribute_id,
0,
)
await trigger_subscription_callback(hass, matter_client)
state = hass.states.get("binary_sensor.smart_co_sensor_carbon_monoxide")
assert state
assert state.state == "off"