diff --git a/homeassistant/components/homekit_controller/sensor.py b/homeassistant/components/homekit_controller/sensor.py index da9305a2ae5..150f2badc6b 100644 --- a/homeassistant/components/homekit_controller/sensor.py +++ b/homeassistant/components/homekit_controller/sensor.py @@ -32,6 +32,7 @@ from homeassistant.const import ( POWER_WATT, PRESSURE_HPA, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, + SOUND_PRESSURE_DB, TEMP_CELSIUS, Platform, ) @@ -309,6 +310,12 @@ SIMPLE_SENSOR: dict[str, HomeKitSensorEntityDescription] = { entity_category=EntityCategory.DIAGNOSTIC, format=thread_status_to_str, ), + CharacteristicsTypes.VENDOR_NETATMO_NOISE: HomeKitSensorEntityDescription( + key=CharacteristicsTypes.VENDOR_NETATMO_NOISE, + name="Noise", + state_class=SensorStateClass.MEASUREMENT, + native_unit_of_measurement=SOUND_PRESSURE_DB, + ), } diff --git a/tests/components/homekit_controller/fixtures/netatmo_home_coach.json b/tests/components/homekit_controller/fixtures/netatmo_home_coach.json new file mode 100644 index 00000000000..b17c1bc542c --- /dev/null +++ b/tests/components/homekit_controller/fixtures/netatmo_home_coach.json @@ -0,0 +1,249 @@ +[ + { + "aid": 1, + "services": [ + { + "iid": 1, + "type": "0000003E-0000-1000-8000-0026BB765291", + "characteristics": [ + { + "type": "00000023-0000-1000-8000-0026BB765291", + "iid": 2, + "perms": ["pr"], + "format": "string", + "value": "Healthy Home Coach", + "description": "Name", + "maxLen": 64 + }, + { + "type": "00000020-0000-1000-8000-0026BB765291", + "iid": 3, + "perms": ["pr"], + "format": "string", + "value": "Netatmo", + "description": "Manufacturer", + "maxLen": 64 + }, + { + "type": "00000021-0000-1000-8000-0026BB765291", + "iid": 4, + "perms": ["pr"], + "format": "string", + "value": "Healthy Home Coach", + "description": "Model", + "maxLen": 64 + }, + { + "type": "00000030-0000-1000-8000-0026BB765291", + "iid": 5, + "perms": ["pr"], + "format": "string", + "value": "AAAAAAAAAAAAA", + "description": "Serial Number", + "maxLen": 64 + }, + { + "type": "00000052-0000-1000-8000-0026BB765291", + "iid": 6, + "perms": ["pr"], + "format": "string", + "value": "59", + "description": "Firmware Revision", + "maxLen": 64 + }, + { + "type": "00000014-0000-1000-8000-0026BB765291", + "iid": 7, + "perms": ["pw"], + "format": "bool", + "description": "Identify" + } + ] + }, + { + "iid": 25, + "type": "000000A2-0000-1000-8000-0026BB765291", + "characteristics": [ + { + "type": "00000037-0000-1000-8000-0026BB765291", + "iid": 26, + "perms": ["pr"], + "format": "string", + "value": "1.1.0", + "description": "Version", + "maxLen": 64 + } + ] + }, + { + "iid": 27, + "type": "EA22EA53-6227-55EA-AC24-73ACF3EEA0E8", + "characteristics": [ + { + "type": "4D05AE82-5A22-5BD6-A730-B7F8B4F3218D", + "iid": 28, + "perms": ["pw"], + "format": "bool" + }, + { + "type": "00F44C18-042E-5C4E-9A4C-561D44DCD804", + "iid": 29, + "perms": ["pr"], + "format": "string", + "value": "g262d1a", + "maxLen": 64 + } + ] + }, + { + "iid": 24, + "type": "0000008D-0000-1000-8000-0026BB765291", + "characteristics": [ + { + "type": "00000095-0000-1000-8000-0026BB765291", + "iid": 8, + "perms": ["pr", "ev"], + "format": "uint8", + "value": 1, + "description": "Air Quality", + "minValue": 0, + "maxValue": 5 + }, + { + "type": "00000023-0000-1000-8000-0026BB765291", + "iid": 9, + "perms": ["pr"], + "format": "string", + "value": "Air quality sensor", + "description": "Name", + "maxLen": 64 + } + ] + }, + { + "iid": 10, + "type": "00000097-0000-1000-8000-0026BB765291", + "characteristics": [ + { + "type": "00000092-0000-1000-8000-0026BB765291", + "iid": 11, + "perms": ["pr", "ev"], + "format": "uint8", + "value": 0, + "description": "Carbon Dioxide Detected", + "minValue": 0, + "maxValue": 1 + }, + { + "type": "00000093-0000-1000-8000-0026BB765291", + "iid": 12, + "perms": ["pr", "ev"], + "format": "float", + "value": 804, + "description": "Carbon Dioxide Level", + "minValue": 0, + "maxValue": 10000 + }, + { + "type": "00000023-0000-1000-8000-0026BB765291", + "iid": 13, + "perms": ["pr"], + "format": "string", + "value": "Carbon Dioxide sensor", + "description": "Name", + "maxLen": 64 + } + ] + }, + { + "iid": 14, + "type": "00000082-0000-1000-8000-0026BB765291", + "characteristics": [ + { + "type": "00000010-0000-1000-8000-0026BB765291", + "iid": 15, + "perms": ["pr", "ev"], + "format": "float", + "value": 59, + "description": "Current Relative Humidity", + "unit": "percentage", + "minValue": 0, + "maxValue": 100, + "minStep": 1 + }, + { + "type": "00000023-0000-1000-8000-0026BB765291", + "iid": 16, + "perms": ["pr"], + "format": "string", + "value": "Humidity sensor", + "description": "Name", + "maxLen": 64 + } + ] + }, + { + "iid": 17, + "type": "0000008A-0000-1000-8000-0026BB765291", + "characteristics": [ + { + "type": "00000011-0000-1000-8000-0026BB765291", + "iid": 18, + "perms": ["pr", "ev"], + "format": "float", + "value": 22.9, + "description": "Current Temperature", + "unit": "celsius", + "minValue": 0, + "maxValue": 50, + "minStep": 0.1 + }, + { + "type": "00000023-0000-1000-8000-0026BB765291", + "iid": 19, + "perms": ["pr"], + "format": "string", + "value": "Temperature sensor", + "description": "Name", + "maxLen": 64 + } + ] + }, + { + "iid": 20, + "type": "6237CEFC-9F4D-54B2-8033-2EDA0053B811", + "characteristics": [ + { + "type": "B3BBFABC-D78C-5B8D-948C-5DAC1EE2CDE5", + "iid": 21, + "perms": ["pr", "ev"], + "format": "uint8", + "value": 0, + "minValue": 0, + "maxValue": 200, + "minStep": 1 + }, + { + "type": "627EA399-29D9-5DC8-9A02-08AE928F73D8", + "iid": 22, + "perms": ["pr", "ev"], + "format": "uint8", + "value": 0, + "minValue": 0, + "maxValue": 5, + "minStep": 1 + }, + { + "type": "00000023-0000-1000-8000-0026BB765291", + "iid": 23, + "perms": ["pr"], + "format": "string", + "value": "Noise sensor", + "description": "Name", + "maxLen": 64 + } + ] + } + ] + } +] diff --git a/tests/components/homekit_controller/specific_devices/test_netatmo_home_coach.py b/tests/components/homekit_controller/specific_devices/test_netatmo_home_coach.py new file mode 100644 index 00000000000..5769cc81129 --- /dev/null +++ b/tests/components/homekit_controller/specific_devices/test_netatmo_home_coach.py @@ -0,0 +1,45 @@ +""" +Regression tests for Netamo Healthy Home Coach. + +https://github.com/home-assistant/core/issues/73360 +""" +from homeassistant.components.sensor import SensorStateClass + +from ..common import ( + HUB_TEST_ACCESSORY_ID, + DeviceTestInfo, + EntityTestInfo, + assert_devices_and_entities_created, + setup_accessories_from_file, + setup_test_accessories, +) + + +async def test_netamo_smart_co_alarm_setup(hass): + """Test that a Netamo Smart CO Alarm can be correctly setup in HA.""" + accessories = await setup_accessories_from_file(hass, "netatmo_home_coach.json") + await setup_test_accessories(hass, accessories) + + await assert_devices_and_entities_created( + hass, + DeviceTestInfo( + unique_id=HUB_TEST_ACCESSORY_ID, + name="Healthy Home Coach", + model="Healthy Home Coach", + manufacturer="Netatmo", + sw_version="59", + hw_version="", + serial_number="1234", + devices=[], + entities=[ + EntityTestInfo( + entity_id="sensor.healthy_home_coach_noise", + friendly_name="Healthy Home Coach Noise", + unique_id="00:00:00:00:00:00_1_20_21", + state="0", + unit_of_measurement="dB", + capabilities={"state_class": SensorStateClass.MEASUREMENT}, + ), + ], + ), + )