From 2f22613cf953ed86eb0e2d054f42c3bbfd39d78b Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Tue, 4 Apr 2023 12:56:39 +0200 Subject: [PATCH] Address late review for NextDNS entity name translations (#90771) --- .../components/nextdns/binary_sensor.py | 4 ++-- homeassistant/components/nextdns/strings.json | 8 +++---- .../components/nextdns/test_binary_sensor.py | 24 ++++++------------- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/homeassistant/components/nextdns/binary_sensor.py b/homeassistant/components/nextdns/binary_sensor.py index 6f85442b16b..e2e37ccab2d 100644 --- a/homeassistant/components/nextdns/binary_sensor.py +++ b/homeassistant/components/nextdns/binary_sensor.py @@ -43,14 +43,14 @@ SENSORS = ( NextDnsBinarySensorEntityDescription[ConnectionStatus]( key="this_device_nextdns_connection_status", entity_category=EntityCategory.DIAGNOSTIC, - translation_key="this_device_nextdns_connection_status", + translation_key="device_connection_status", device_class=BinarySensorDeviceClass.CONNECTIVITY, state=lambda data, _: data.connected, ), NextDnsBinarySensorEntityDescription[ConnectionStatus]( key="this_device_profile_connection_status", entity_category=EntityCategory.DIAGNOSTIC, - translation_key="this_device_profile_connection_status", + translation_key="device_profile_connection_status", device_class=BinarySensorDeviceClass.CONNECTIVITY, state=lambda data, profile_id: profile_id == data.profile_id, ), diff --git a/homeassistant/components/nextdns/strings.json b/homeassistant/components/nextdns/strings.json index cc4fb6fa8fc..517e229d0e4 100644 --- a/homeassistant/components/nextdns/strings.json +++ b/homeassistant/components/nextdns/strings.json @@ -28,11 +28,11 @@ }, "entity": { "binary_sensor": { - "this_device_nextdns_connection_status": { - "name": "This device NextDNS connection status" + "device_connection_status": { + "name": "Device connection status" }, - "this_device_profile_connection_status": { - "name": "This device profile connection status" + "device_profile_connection_status": { + "name": "Device profile connection status" } }, "button": { diff --git a/tests/components/nextdns/test_binary_sensor.py b/tests/components/nextdns/test_binary_sensor.py index eb1478a5809..08d1f08f5d1 100644 --- a/tests/components/nextdns/test_binary_sensor.py +++ b/tests/components/nextdns/test_binary_sensor.py @@ -20,26 +20,22 @@ async def test_binary_Sensor(hass: HomeAssistant) -> None: await init_integration(hass) - state = hass.states.get( - "binary_sensor.fake_profile_this_device_nextdns_connection_status" - ) + state = hass.states.get("binary_sensor.fake_profile_device_connection_status") assert state assert state.state == STATE_ON - entry = registry.async_get( - "binary_sensor.fake_profile_this_device_nextdns_connection_status" - ) + entry = registry.async_get("binary_sensor.fake_profile_device_connection_status") assert entry assert entry.unique_id == "xyz12_this_device_nextdns_connection_status" state = hass.states.get( - "binary_sensor.fake_profile_this_device_profile_connection_status" + "binary_sensor.fake_profile_device_profile_connection_status" ) assert state assert state.state == STATE_OFF entry = registry.async_get( - "binary_sensor.fake_profile_this_device_profile_connection_status" + "binary_sensor.fake_profile_device_profile_connection_status" ) assert entry assert entry.unique_id == "xyz12_this_device_profile_connection_status" @@ -49,9 +45,7 @@ async def test_availability(hass: HomeAssistant) -> None: """Ensure that we mark the entities unavailable correctly when service causes an error.""" await init_integration(hass) - state = hass.states.get( - "binary_sensor.fake_profile_this_device_nextdns_connection_status" - ) + state = hass.states.get("binary_sensor.fake_profile_device_connection_status") assert state assert state.state != STATE_UNAVAILABLE assert state.state == STATE_ON @@ -64,9 +58,7 @@ async def test_availability(hass: HomeAssistant) -> None: async_fire_time_changed(hass, future) await hass.async_block_till_done() - state = hass.states.get( - "binary_sensor.fake_profile_this_device_nextdns_connection_status" - ) + state = hass.states.get("binary_sensor.fake_profile_device_connection_status") assert state assert state.state == STATE_UNAVAILABLE @@ -78,9 +70,7 @@ async def test_availability(hass: HomeAssistant) -> None: async_fire_time_changed(hass, future) await hass.async_block_till_done() - state = hass.states.get( - "binary_sensor.fake_profile_this_device_nextdns_connection_status" - ) + state = hass.states.get("binary_sensor.fake_profile_device_connection_status") assert state assert state.state != STATE_UNAVAILABLE assert state.state == STATE_ON