From 5ac50a56b4c9ecab02521efb1eb6f9d4faea510f Mon Sep 17 00:00:00 2001 From: Jc2k Date: Mon, 24 Jan 2022 08:42:55 +0000 Subject: [PATCH] Make sensor name consistent with other homekit_controller entity names (#64821) --- .../homekit_controller/diagnostics.py | 2 + .../components/homekit_controller/sensor.py | 2 +- .../specific_devices/test_arlo_baby.py | 2 +- .../specific_devices/test_connectsense.py | 12 +-- .../specific_devices/test_ecobee3.py | 2 +- .../specific_devices/test_eve_degree.py | 2 +- .../specific_devices/test_koogeek_p1eu.py | 2 +- .../specific_devices/test_koogeek_sw2.py | 2 +- .../specific_devices/test_mysa_living.py | 4 +- .../test_vocolinc_flowerbud.py | 2 +- .../specific_devices/test_vocolinc_vp3.py | 2 +- .../homekit_controller/test_diagnostics.py | 76 +++++++++---------- 12 files changed, 56 insertions(+), 54 deletions(-) diff --git a/homeassistant/components/homekit_controller/diagnostics.py b/homeassistant/components/homekit_controller/diagnostics.py index 83f781013d2..bdf19b6d593 100644 --- a/homeassistant/components/homekit_controller/diagnostics.py +++ b/homeassistant/components/homekit_controller/diagnostics.py @@ -60,6 +60,8 @@ def _async_get_diagnostics_for_device( include_disabled_entities=True, ) + hass_entities.sort(key=lambda entry: entry.original_name) + for entity_entry in hass_entities: state = hass.states.get(entity_entry.entity_id) state_dict = None diff --git a/homeassistant/components/homekit_controller/sensor.py b/homeassistant/components/homekit_controller/sensor.py index fb1c42ceac4..f2f77cfe71b 100644 --- a/homeassistant/components/homekit_controller/sensor.py +++ b/homeassistant/components/homekit_controller/sensor.py @@ -365,7 +365,7 @@ class SimpleSensor(CharacteristicEntity, SensorEntity): @property def name(self) -> str: """Return the name of the device if any.""" - return f"{super().name} - {self.entity_description.name}" + return f"{super().name} {self.entity_description.name}" @property def native_value(self): diff --git a/tests/components/homekit_controller/specific_devices/test_arlo_baby.py b/tests/components/homekit_controller/specific_devices/test_arlo_baby.py index 166f662347e..9f05baf2a60 100644 --- a/tests/components/homekit_controller/specific_devices/test_arlo_baby.py +++ b/tests/components/homekit_controller/specific_devices/test_arlo_baby.py @@ -68,7 +68,7 @@ async def test_arlo_baby_setup(hass): entity_id="sensor.arlobabya0_air_quality", unique_id="homekit-00A0000000000-aid:1-sid:800-cid:802", capabilities={"state_class": SensorStateClass.MEASUREMENT}, - friendly_name="ArloBabyA0 - Air Quality", + friendly_name="ArloBabyA0 Air Quality", state="1", ), EntityTestInfo( diff --git a/tests/components/homekit_controller/specific_devices/test_connectsense.py b/tests/components/homekit_controller/specific_devices/test_connectsense.py index 0b87c5fe4f1..371ee360adc 100644 --- a/tests/components/homekit_controller/specific_devices/test_connectsense.py +++ b/tests/components/homekit_controller/specific_devices/test_connectsense.py @@ -36,7 +36,7 @@ async def test_connectsense_setup(hass): entities=[ EntityTestInfo( entity_id="sensor.inwall_outlet_0394de_real_time_current", - friendly_name="InWall Outlet-0394DE - Real Time Current", + friendly_name="InWall Outlet-0394DE Real Time Current", unique_id="homekit-1020301376-aid:1-sid:13-cid:18", capabilities={"state_class": SensorStateClass.MEASUREMENT}, unit_of_measurement=ELECTRIC_CURRENT_AMPERE, @@ -44,7 +44,7 @@ async def test_connectsense_setup(hass): ), EntityTestInfo( entity_id="sensor.inwall_outlet_0394de_real_time_energy", - friendly_name="InWall Outlet-0394DE - Real Time Energy", + friendly_name="InWall Outlet-0394DE Real Time Energy", unique_id="homekit-1020301376-aid:1-sid:13-cid:19", capabilities={"state_class": SensorStateClass.MEASUREMENT}, unit_of_measurement=POWER_WATT, @@ -52,7 +52,7 @@ async def test_connectsense_setup(hass): ), EntityTestInfo( entity_id="sensor.inwall_outlet_0394de_energy_kwh", - friendly_name="InWall Outlet-0394DE - Energy kWh", + friendly_name="InWall Outlet-0394DE Energy kWh", unique_id="homekit-1020301376-aid:1-sid:13-cid:20", capabilities={"state_class": SensorStateClass.MEASUREMENT}, unit_of_measurement=ENERGY_KILO_WATT_HOUR, @@ -66,7 +66,7 @@ async def test_connectsense_setup(hass): ), EntityTestInfo( entity_id="sensor.inwall_outlet_0394de_real_time_current_2", - friendly_name="InWall Outlet-0394DE - Real Time Current", + friendly_name="InWall Outlet-0394DE Real Time Current", unique_id="homekit-1020301376-aid:1-sid:25-cid:30", capabilities={"state_class": SensorStateClass.MEASUREMENT}, unit_of_measurement=ELECTRIC_CURRENT_AMPERE, @@ -74,7 +74,7 @@ async def test_connectsense_setup(hass): ), EntityTestInfo( entity_id="sensor.inwall_outlet_0394de_real_time_energy_2", - friendly_name="InWall Outlet-0394DE - Real Time Energy", + friendly_name="InWall Outlet-0394DE Real Time Energy", unique_id="homekit-1020301376-aid:1-sid:25-cid:31", capabilities={"state_class": SensorStateClass.MEASUREMENT}, unit_of_measurement=POWER_WATT, @@ -82,7 +82,7 @@ async def test_connectsense_setup(hass): ), EntityTestInfo( entity_id="sensor.inwall_outlet_0394de_energy_kwh_2", - friendly_name="InWall Outlet-0394DE - Energy kWh", + friendly_name="InWall Outlet-0394DE Energy kWh", unique_id="homekit-1020301376-aid:1-sid:25-cid:32", capabilities={"state_class": SensorStateClass.MEASUREMENT}, unit_of_measurement=ENERGY_KILO_WATT_HOUR, diff --git a/tests/components/homekit_controller/specific_devices/test_ecobee3.py b/tests/components/homekit_controller/specific_devices/test_ecobee3.py index d2c8a793798..2d540f31850 100644 --- a/tests/components/homekit_controller/specific_devices/test_ecobee3.py +++ b/tests/components/homekit_controller/specific_devices/test_ecobee3.py @@ -123,7 +123,7 @@ async def test_ecobee3_setup(hass): ), EntityTestInfo( entity_id="sensor.homew_current_temperature", - friendly_name="HomeW - Current Temperature", + friendly_name="HomeW Current Temperature", unique_id="homekit-123456789012-aid:1-sid:16-cid:19", capabilities={"state_class": SensorStateClass.MEASUREMENT}, unit_of_measurement=TEMP_CELSIUS, diff --git a/tests/components/homekit_controller/specific_devices/test_eve_degree.py b/tests/components/homekit_controller/specific_devices/test_eve_degree.py index 446ebb712d9..51880bc076a 100644 --- a/tests/components/homekit_controller/specific_devices/test_eve_degree.py +++ b/tests/components/homekit_controller/specific_devices/test_eve_degree.py @@ -49,7 +49,7 @@ async def test_eve_degree_setup(hass): EntityTestInfo( entity_id="sensor.eve_degree_aa11_air_pressure", unique_id="homekit-AA00A0A00000-aid:1-sid:30-cid:32", - friendly_name="Eve Degree AA11 - Air Pressure", + friendly_name="Eve Degree AA11 Air Pressure", unit_of_measurement=PRESSURE_HPA, capabilities={"state_class": SensorStateClass.MEASUREMENT}, state="1005.70001220703", diff --git a/tests/components/homekit_controller/specific_devices/test_koogeek_p1eu.py b/tests/components/homekit_controller/specific_devices/test_koogeek_p1eu.py index 162cbaf9ecb..78d3efb64bb 100644 --- a/tests/components/homekit_controller/specific_devices/test_koogeek_p1eu.py +++ b/tests/components/homekit_controller/specific_devices/test_koogeek_p1eu.py @@ -38,7 +38,7 @@ async def test_koogeek_p1eu_setup(hass): ), EntityTestInfo( entity_id="sensor.koogeek_p1_a00aa0_real_time_energy", - friendly_name="Koogeek-P1-A00AA0 - Real Time Energy", + friendly_name="Koogeek-P1-A00AA0 Real Time Energy", unique_id="homekit-EUCP03190xxxxx48-aid:1-sid:21-cid:22", unit_of_measurement=POWER_WATT, capabilities={"state_class": SensorStateClass.MEASUREMENT}, diff --git a/tests/components/homekit_controller/specific_devices/test_koogeek_sw2.py b/tests/components/homekit_controller/specific_devices/test_koogeek_sw2.py index 8e44fc34f07..7c7688be4ee 100644 --- a/tests/components/homekit_controller/specific_devices/test_koogeek_sw2.py +++ b/tests/components/homekit_controller/specific_devices/test_koogeek_sw2.py @@ -44,7 +44,7 @@ async def test_koogeek_sw2_setup(hass): ), EntityTestInfo( entity_id="sensor.koogeek_sw2_187a91_real_time_energy", - friendly_name="Koogeek-SW2-187A91 - Real Time Energy", + friendly_name="Koogeek-SW2-187A91 Real Time Energy", unique_id="homekit-CNNT061751001372-aid:1-sid:14-cid:18", unit_of_measurement=POWER_WATT, capabilities={"state_class": SensorStateClass.MEASUREMENT}, diff --git a/tests/components/homekit_controller/specific_devices/test_mysa_living.py b/tests/components/homekit_controller/specific_devices/test_mysa_living.py index b26ce713a80..1d99e9358c8 100644 --- a/tests/components/homekit_controller/specific_devices/test_mysa_living.py +++ b/tests/components/homekit_controller/specific_devices/test_mysa_living.py @@ -46,7 +46,7 @@ async def test_mysa_living_setup(hass): ), EntityTestInfo( entity_id="sensor.mysa_85dda9_current_humidity", - friendly_name="Mysa-85dda9 - Current Humidity", + friendly_name="Mysa-85dda9 Current Humidity", unique_id="homekit-AAAAAAA000-aid:1-sid:20-cid:27", unit_of_measurement=PERCENTAGE, capabilities={"state_class": SensorStateClass.MEASUREMENT}, @@ -54,7 +54,7 @@ async def test_mysa_living_setup(hass): ), EntityTestInfo( entity_id="sensor.mysa_85dda9_current_temperature", - friendly_name="Mysa-85dda9 - Current Temperature", + friendly_name="Mysa-85dda9 Current Temperature", unique_id="homekit-AAAAAAA000-aid:1-sid:20-cid:25", unit_of_measurement=TEMP_CELSIUS, capabilities={"state_class": SensorStateClass.MEASUREMENT}, diff --git a/tests/components/homekit_controller/specific_devices/test_vocolinc_flowerbud.py b/tests/components/homekit_controller/specific_devices/test_vocolinc_flowerbud.py index b02be9bfd64..16bd3830dfc 100644 --- a/tests/components/homekit_controller/specific_devices/test_vocolinc_flowerbud.py +++ b/tests/components/homekit_controller/specific_devices/test_vocolinc_flowerbud.py @@ -69,7 +69,7 @@ async def test_vocolinc_flowerbud_setup(hass): ), EntityTestInfo( entity_id="sensor.vocolinc_flowerbud_0d324b_current_humidity", - friendly_name="VOCOlinc-Flowerbud-0d324b - Current Humidity", + friendly_name="VOCOlinc-Flowerbud-0d324b Current Humidity", unique_id="homekit-AM01121849000327-aid:1-sid:30-cid:33", capabilities={"state_class": SensorStateClass.MEASUREMENT}, unit_of_measurement=PERCENTAGE, diff --git a/tests/components/homekit_controller/specific_devices/test_vocolinc_vp3.py b/tests/components/homekit_controller/specific_devices/test_vocolinc_vp3.py index 6fdad72b8a5..a082683cf21 100644 --- a/tests/components/homekit_controller/specific_devices/test_vocolinc_vp3.py +++ b/tests/components/homekit_controller/specific_devices/test_vocolinc_vp3.py @@ -38,7 +38,7 @@ async def test_vocolinc_vp3_setup(hass): ), EntityTestInfo( entity_id="sensor.vocolinc_vp3_123456_real_time_energy", - friendly_name="VOCOlinc-VP3-123456 - Real Time Energy", + friendly_name="VOCOlinc-VP3-123456 Real Time Energy", unique_id="homekit-EU0121203xxxxx07-aid:1-sid:48-cid:97", unit_of_measurement=POWER_WATT, capabilities={"state_class": SensorStateClass.MEASUREMENT}, diff --git a/tests/components/homekit_controller/test_diagnostics.py b/tests/components/homekit_controller/test_diagnostics.py index 86b3ed42ce3..bd9aa30f6ae 100644 --- a/tests/components/homekit_controller/test_diagnostics.py +++ b/tests/components/homekit_controller/test_diagnostics.py @@ -234,26 +234,6 @@ async def test_config_entry(hass: HomeAssistant, hass_client: ClientSession, utc "sw_version": "2.2.15", "hw_version": "", "entities": [ - { - "device_class": None, - "disabled": False, - "disabled_by": None, - "entity_category": "diagnostic", - "icon": None, - "original_device_class": None, - "original_icon": None, - "original_name": "Koogeek-LS1-20833F Identify", - "state": { - "attributes": { - "friendly_name": "Koogeek-LS1-20833F Identify" - }, - "entity_id": "button.koogeek_ls1_20833f_identify", - "last_changed": "2023-01-01T00:00:00+00:00", - "last_updated": "2023-01-01T00:00:00+00:00", - "state": "unknown", - }, - "unit_of_measurement": None, - }, { "original_name": "Koogeek-LS1-20833F", "disabled": False, @@ -276,6 +256,26 @@ async def test_config_entry(hass: HomeAssistant, hass_client: ClientSession, utc "last_updated": "2023-01-01T00:00:00+00:00", }, }, + { + "device_class": None, + "disabled": False, + "disabled_by": None, + "entity_category": "diagnostic", + "icon": None, + "original_device_class": None, + "original_icon": None, + "original_name": "Koogeek-LS1-20833F Identify", + "state": { + "attributes": { + "friendly_name": "Koogeek-LS1-20833F Identify" + }, + "entity_id": "button.koogeek_ls1_20833f_identify", + "last_changed": "2023-01-01T00:00:00+00:00", + "last_updated": "2023-01-01T00:00:00+00:00", + "state": "unknown", + }, + "unit_of_measurement": None, + }, ], } ], @@ -504,24 +504,6 @@ async def test_device(hass: HomeAssistant, hass_client: ClientSession, utcnow): "sw_version": "2.2.15", "hw_version": "", "entities": [ - { - "device_class": None, - "disabled": False, - "disabled_by": None, - "entity_category": "diagnostic", - "icon": None, - "original_device_class": None, - "original_icon": None, - "original_name": "Koogeek-LS1-20833F Identify", - "state": { - "attributes": {"friendly_name": "Koogeek-LS1-20833F Identify"}, - "entity_id": "button.koogeek_ls1_20833f_identify", - "last_changed": "2023-01-01T00:00:00+00:00", - "last_updated": "2023-01-01T00:00:00+00:00", - "state": "unknown", - }, - "unit_of_measurement": None, - }, { "original_name": "Koogeek-LS1-20833F", "disabled": False, @@ -544,6 +526,24 @@ async def test_device(hass: HomeAssistant, hass_client: ClientSession, utcnow): "last_updated": "2023-01-01T00:00:00+00:00", }, }, + { + "device_class": None, + "disabled": False, + "disabled_by": None, + "entity_category": "diagnostic", + "icon": None, + "original_device_class": None, + "original_icon": None, + "original_name": "Koogeek-LS1-20833F Identify", + "state": { + "attributes": {"friendly_name": "Koogeek-LS1-20833F Identify"}, + "entity_id": "button.koogeek_ls1_20833f_identify", + "last_changed": "2023-01-01T00:00:00+00:00", + "last_updated": "2023-01-01T00:00:00+00:00", + "state": "unknown", + }, + "unit_of_measurement": None, + }, ], }, }