From 5928a7d494cd3ba91c92c4ffc598bb0f5d07077d Mon Sep 17 00:00:00 2001 From: Brett Adams Date: Tue, 19 Jul 2022 07:02:58 +1000 Subject: [PATCH] Correct devices in Advantage Air (#75395) --- .../components/advantage_air/binary_sensor.py | 2 +- homeassistant/components/advantage_air/climate.py | 1 - homeassistant/components/advantage_air/entity.py | 8 +++++--- homeassistant/components/advantage_air/select.py | 2 +- homeassistant/components/advantage_air/sensor.py | 2 +- homeassistant/components/advantage_air/switch.py | 2 +- .../components/advantage_air/test_binary_sensor.py | 12 ++++++------ tests/components/advantage_air/test_climate.py | 6 +++--- tests/components/advantage_air/test_cover.py | 10 +++++----- tests/components/advantage_air/test_select.py | 2 +- tests/components/advantage_air/test_sensor.py | 14 +++++++------- tests/components/advantage_air/test_switch.py | 2 +- 12 files changed, 32 insertions(+), 31 deletions(-) diff --git a/homeassistant/components/advantage_air/binary_sensor.py b/homeassistant/components/advantage_air/binary_sensor.py index c87bf37ca92..9fc53d7e1dc 100644 --- a/homeassistant/components/advantage_air/binary_sensor.py +++ b/homeassistant/components/advantage_air/binary_sensor.py @@ -43,11 +43,11 @@ class AdvantageAirFilter(AdvantageAirEntity, BinarySensorEntity): _attr_device_class = BinarySensorDeviceClass.PROBLEM _attr_entity_category = EntityCategory.DIAGNOSTIC + _attr_name = "Filter" def __init__(self, instance, ac_key): """Initialize an Advantage Air Filter sensor.""" super().__init__(instance, ac_key) - self._attr_name = f'{self._ac["name"]} filter' self._attr_unique_id = ( f'{self.coordinator.data["system"]["rid"]}-{ac_key}-filter' ) diff --git a/homeassistant/components/advantage_air/climate.py b/homeassistant/components/advantage_air/climate.py index 192e1987902..1d89c313579 100644 --- a/homeassistant/components/advantage_air/climate.py +++ b/homeassistant/components/advantage_air/climate.py @@ -108,7 +108,6 @@ class AdvantageAirAC(AdvantageAirClimateEntity): def __init__(self, instance, ac_key): """Initialize an AdvantageAir AC unit.""" super().__init__(instance, ac_key) - self._attr_name = self._ac["name"] self._attr_unique_id = f'{self.coordinator.data["system"]["rid"]}-{ac_key}' if self._ac.get("myAutoModeEnabled"): self._attr_hvac_modes = AC_HVAC_MODES + [HVACMode.AUTO] diff --git a/homeassistant/components/advantage_air/entity.py b/homeassistant/components/advantage_air/entity.py index b0ff1bfb8c8..6c434518656 100644 --- a/homeassistant/components/advantage_air/entity.py +++ b/homeassistant/components/advantage_air/entity.py @@ -18,11 +18,13 @@ class AdvantageAirEntity(CoordinatorEntity): self.ac_key = ac_key self.zone_key = zone_key self._attr_device_info = DeviceInfo( - identifiers={(DOMAIN, self.coordinator.data["system"]["rid"])}, + via_device=(DOMAIN, self.coordinator.data["system"]["rid"]), + identifiers={ + (DOMAIN, f"{self.coordinator.data['system']['rid']}_{ac_key}") + }, manufacturer="Advantage Air", model=self.coordinator.data["system"]["sysType"], - name=self.coordinator.data["system"]["name"], - sw_version=self.coordinator.data["system"]["myAppRev"], + name=self._ac["name"], ) @property diff --git a/homeassistant/components/advantage_air/select.py b/homeassistant/components/advantage_air/select.py index 0edae258279..5dfa92c10ad 100644 --- a/homeassistant/components/advantage_air/select.py +++ b/homeassistant/components/advantage_air/select.py @@ -32,11 +32,11 @@ class AdvantageAirMyZone(AdvantageAirEntity, SelectEntity): _attr_options = [ADVANTAGE_AIR_INACTIVE] _number_to_name = {0: ADVANTAGE_AIR_INACTIVE} _name_to_number = {ADVANTAGE_AIR_INACTIVE: 0} + _attr_name = "MyZone" def __init__(self, instance, ac_key): """Initialize an Advantage Air MyZone control.""" super().__init__(instance, ac_key) - self._attr_name = f'{self._ac["name"]} myZone' self._attr_unique_id = ( f'{self.coordinator.data["system"]["rid"]}-{ac_key}-myzone' ) diff --git a/homeassistant/components/advantage_air/sensor.py b/homeassistant/components/advantage_air/sensor.py index 855a0e6d15f..370aab7b292 100644 --- a/homeassistant/components/advantage_air/sensor.py +++ b/homeassistant/components/advantage_air/sensor.py @@ -67,7 +67,7 @@ class AdvantageAirTimeTo(AdvantageAirEntity, SensorEntity): super().__init__(instance, ac_key) self.action = action self._time_key = f"countDownTo{action}" - self._attr_name = f'{self._ac["name"]} time to {action}' + self._attr_name = f"Time to {action}" self._attr_unique_id = ( f'{self.coordinator.data["system"]["rid"]}-{self.ac_key}-timeto{action}' ) diff --git a/homeassistant/components/advantage_air/switch.py b/homeassistant/components/advantage_air/switch.py index 3c0060c65b3..504578c72e2 100644 --- a/homeassistant/components/advantage_air/switch.py +++ b/homeassistant/components/advantage_air/switch.py @@ -32,11 +32,11 @@ class AdvantageAirFreshAir(AdvantageAirEntity, SwitchEntity): """Representation of Advantage Air fresh air control.""" _attr_icon = "mdi:air-filter" + _attr_name = "Fresh air" def __init__(self, instance, ac_key): """Initialize an Advantage Air fresh air control.""" super().__init__(instance, ac_key) - self._attr_name = f'{self._ac["name"]} Fresh Air' self._attr_unique_id = ( f'{self.coordinator.data["system"]["rid"]}-{ac_key}-freshair' ) diff --git a/tests/components/advantage_air/test_binary_sensor.py b/tests/components/advantage_air/test_binary_sensor.py index 9aa092a8679..4bd792808fb 100644 --- a/tests/components/advantage_air/test_binary_sensor.py +++ b/tests/components/advantage_air/test_binary_sensor.py @@ -34,7 +34,7 @@ async def test_binary_sensor_async_setup_entry(hass, aioclient_mock): assert len(aioclient_mock.mock_calls) == 1 # Test First Air Filter - entity_id = "binary_sensor.testname_ac_one_filter" + entity_id = "binary_sensor.ac_one_filter" state = hass.states.get(entity_id) assert state assert state.state == STATE_OFF @@ -44,7 +44,7 @@ async def test_binary_sensor_async_setup_entry(hass, aioclient_mock): assert entry.unique_id == "uniqueid-ac1-filter" # Test Second Air Filter - entity_id = "binary_sensor.testname_ac_two_filter" + entity_id = "binary_sensor.ac_two_filter" state = hass.states.get(entity_id) assert state assert state.state == STATE_ON @@ -54,7 +54,7 @@ async def test_binary_sensor_async_setup_entry(hass, aioclient_mock): assert entry.unique_id == "uniqueid-ac2-filter" # Test First Motion Sensor - entity_id = "binary_sensor.testname_zone_open_with_sensor_motion" + entity_id = "binary_sensor.ac_one_zone_open_with_sensor_motion" state = hass.states.get(entity_id) assert state assert state.state == STATE_ON @@ -64,7 +64,7 @@ async def test_binary_sensor_async_setup_entry(hass, aioclient_mock): assert entry.unique_id == "uniqueid-ac1-z01-motion" # Test Second Motion Sensor - entity_id = "binary_sensor.testname_zone_closed_with_sensor_motion" + entity_id = "binary_sensor.ac_one_zone_closed_with_sensor_motion" state = hass.states.get(entity_id) assert state assert state.state == STATE_OFF @@ -74,7 +74,7 @@ async def test_binary_sensor_async_setup_entry(hass, aioclient_mock): assert entry.unique_id == "uniqueid-ac1-z02-motion" # Test First MyZone Sensor (disabled by default) - entity_id = "binary_sensor.testname_zone_open_with_sensor_myzone" + entity_id = "binary_sensor.ac_one_zone_open_with_sensor_myzone" assert not hass.states.get(entity_id) @@ -96,7 +96,7 @@ async def test_binary_sensor_async_setup_entry(hass, aioclient_mock): assert entry.unique_id == "uniqueid-ac1-z01-myzone" # Test Second Motion Sensor (disabled by default) - entity_id = "binary_sensor.testname_zone_closed_with_sensor_myzone" + entity_id = "binary_sensor.ac_one_zone_closed_with_sensor_myzone" assert not hass.states.get(entity_id) diff --git a/tests/components/advantage_air/test_climate.py b/tests/components/advantage_air/test_climate.py index 47073f27fc1..6ee0a614b09 100644 --- a/tests/components/advantage_air/test_climate.py +++ b/tests/components/advantage_air/test_climate.py @@ -51,7 +51,7 @@ async def test_climate_async_setup_entry(hass, aioclient_mock): assert len(aioclient_mock.mock_calls) == 1 # Test Main Climate Entity - entity_id = "climate.testname_ac_one" + entity_id = "climate.ac_one" state = hass.states.get(entity_id) assert state assert state.state == HVACMode.FAN_ONLY @@ -122,7 +122,7 @@ async def test_climate_async_setup_entry(hass, aioclient_mock): assert aioclient_mock.mock_calls[-1][1].path == "/getSystemData" # Test Climate Zone Entity - entity_id = "climate.testname_zone_open_with_sensor" + entity_id = "climate.ac_one_zone_open_with_sensor" state = hass.states.get(entity_id) assert state assert state.attributes.get("min_temp") == 16 @@ -204,7 +204,7 @@ async def test_climate_async_failed_update(hass, aioclient_mock): await hass.services.async_call( CLIMATE_DOMAIN, SERVICE_SET_TEMPERATURE, - {ATTR_ENTITY_ID: ["climate.testname_ac_one"], ATTR_TEMPERATURE: 25}, + {ATTR_ENTITY_ID: ["climate.ac_one"], ATTR_TEMPERATURE: 25}, blocking=True, ) assert len(aioclient_mock.mock_calls) == 2 diff --git a/tests/components/advantage_air/test_cover.py b/tests/components/advantage_air/test_cover.py index c638c6a3c87..90cdf9a2168 100644 --- a/tests/components/advantage_air/test_cover.py +++ b/tests/components/advantage_air/test_cover.py @@ -45,7 +45,7 @@ async def test_cover_async_setup_entry(hass, aioclient_mock): assert len(aioclient_mock.mock_calls) == 1 # Test Cover Zone Entity - entity_id = "cover.testname_zone_open_without_sensor" + entity_id = "cover.ac_two_zone_open_without_sensor" state = hass.states.get(entity_id) assert state assert state.state == STATE_OPEN @@ -119,8 +119,8 @@ async def test_cover_async_setup_entry(hass, aioclient_mock): SERVICE_CLOSE_COVER, { ATTR_ENTITY_ID: [ - "cover.testname_zone_open_without_sensor", - "cover.testname_zone_closed_without_sensor", + "cover.ac_two_zone_open_without_sensor", + "cover.ac_two_zone_closed_without_sensor", ] }, blocking=True, @@ -134,8 +134,8 @@ async def test_cover_async_setup_entry(hass, aioclient_mock): SERVICE_OPEN_COVER, { ATTR_ENTITY_ID: [ - "cover.testname_zone_open_without_sensor", - "cover.testname_zone_closed_without_sensor", + "cover.ac_two_zone_open_without_sensor", + "cover.ac_two_zone_closed_without_sensor", ] }, blocking=True, diff --git a/tests/components/advantage_air/test_select.py b/tests/components/advantage_air/test_select.py index 2ba982fc384..20d42fdcffc 100644 --- a/tests/components/advantage_air/test_select.py +++ b/tests/components/advantage_air/test_select.py @@ -37,7 +37,7 @@ async def test_select_async_setup_entry(hass, aioclient_mock): assert len(aioclient_mock.mock_calls) == 1 # Test MyZone Select Entity - entity_id = "select.testname_ac_one_myzone" + entity_id = "select.ac_one_myzone" state = hass.states.get(entity_id) assert state assert state.state == "Zone open with Sensor" diff --git a/tests/components/advantage_air/test_sensor.py b/tests/components/advantage_air/test_sensor.py index 70322f4c9df..4dc2f1baaff 100644 --- a/tests/components/advantage_air/test_sensor.py +++ b/tests/components/advantage_air/test_sensor.py @@ -41,7 +41,7 @@ async def test_sensor_platform(hass, aioclient_mock): assert len(aioclient_mock.mock_calls) == 1 # Test First TimeToOn Sensor - entity_id = "sensor.testname_ac_one_time_to_on" + entity_id = "sensor.ac_one_time_to_on" state = hass.states.get(entity_id) assert state assert int(state.state) == 0 @@ -66,7 +66,7 @@ async def test_sensor_platform(hass, aioclient_mock): assert aioclient_mock.mock_calls[-1][1].path == "/getSystemData" # Test First TimeToOff Sensor - entity_id = "sensor.testname_ac_one_time_to_off" + entity_id = "sensor.ac_one_time_to_off" state = hass.states.get(entity_id) assert state assert int(state.state) == 10 @@ -91,7 +91,7 @@ async def test_sensor_platform(hass, aioclient_mock): assert aioclient_mock.mock_calls[-1][1].path == "/getSystemData" # Test First Zone Vent Sensor - entity_id = "sensor.testname_zone_open_with_sensor_vent" + entity_id = "sensor.ac_one_zone_open_with_sensor_vent" state = hass.states.get(entity_id) assert state assert int(state.state) == 100 @@ -101,7 +101,7 @@ async def test_sensor_platform(hass, aioclient_mock): assert entry.unique_id == "uniqueid-ac1-z01-vent" # Test Second Zone Vent Sensor - entity_id = "sensor.testname_zone_closed_with_sensor_vent" + entity_id = "sensor.ac_one_zone_closed_with_sensor_vent" state = hass.states.get(entity_id) assert state assert int(state.state) == 0 @@ -111,7 +111,7 @@ async def test_sensor_platform(hass, aioclient_mock): assert entry.unique_id == "uniqueid-ac1-z02-vent" # Test First Zone Signal Sensor - entity_id = "sensor.testname_zone_open_with_sensor_signal" + entity_id = "sensor.ac_one_zone_open_with_sensor_signal" state = hass.states.get(entity_id) assert state assert int(state.state) == 40 @@ -121,7 +121,7 @@ async def test_sensor_platform(hass, aioclient_mock): assert entry.unique_id == "uniqueid-ac1-z01-signal" # Test Second Zone Signal Sensor - entity_id = "sensor.testname_zone_closed_with_sensor_signal" + entity_id = "sensor.ac_one_zone_closed_with_sensor_signal" state = hass.states.get(entity_id) assert state assert int(state.state) == 10 @@ -131,7 +131,7 @@ async def test_sensor_platform(hass, aioclient_mock): assert entry.unique_id == "uniqueid-ac1-z02-signal" # Test First Zone Temp Sensor (disabled by default) - entity_id = "sensor.testname_zone_open_with_sensor_temperature" + entity_id = "sensor.ac_one_zone_open_with_sensor_temperature" assert not hass.states.get(entity_id) diff --git a/tests/components/advantage_air/test_switch.py b/tests/components/advantage_air/test_switch.py index 41af9e8ff80..be78edf8ffe 100644 --- a/tests/components/advantage_air/test_switch.py +++ b/tests/components/advantage_air/test_switch.py @@ -41,7 +41,7 @@ async def test_cover_async_setup_entry(hass, aioclient_mock): assert len(aioclient_mock.mock_calls) == 1 # Test Switch Entity - entity_id = "switch.testname_ac_one_fresh_air" + entity_id = "switch.ac_one_fresh_air" state = hass.states.get(entity_id) assert state assert state.state == STATE_OFF