From 11fd43b1fc33c35b68858878f94bfb49a407f3e6 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Sat, 22 Jul 2023 16:28:48 +0200 Subject: [PATCH] Add entity translations to Wiz (#96826) --- homeassistant/components/wiz/binary_sensor.py | 1 - homeassistant/components/wiz/number.py | 4 ++-- homeassistant/components/wiz/sensor.py | 2 -- homeassistant/components/wiz/strings.json | 10 ++++++++++ tests/components/wiz/test_sensor.py | 2 +- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/wiz/binary_sensor.py b/homeassistant/components/wiz/binary_sensor.py index 538bd3a741d..6b3caf23a1c 100644 --- a/homeassistant/components/wiz/binary_sensor.py +++ b/homeassistant/components/wiz/binary_sensor.py @@ -66,7 +66,6 @@ class WizOccupancyEntity(WizEntity, BinarySensorEntity): """Representation of WiZ Occupancy sensor.""" _attr_device_class = BinarySensorDeviceClass.OCCUPANCY - _attr_name = "Occupancy" def __init__(self, wiz_data: WizData, name: str) -> None: """Initialize an WiZ device.""" diff --git a/homeassistant/components/wiz/number.py b/homeassistant/components/wiz/number.py index be1cf61ae09..f1212c75f25 100644 --- a/homeassistant/components/wiz/number.py +++ b/homeassistant/components/wiz/number.py @@ -49,11 +49,11 @@ async def _async_set_ratio(device: wizlight, ratio: int) -> None: NUMBERS: tuple[WizNumberEntityDescription, ...] = ( WizNumberEntityDescription( key="effect_speed", + translation_key="effect_speed", native_min_value=10, native_max_value=200, native_step=1, icon="mdi:speedometer", - name="Effect speed", value_fn=lambda device: cast(int | None, device.state.get_speed()), set_value_fn=_async_set_speed, required_feature="effect", @@ -61,11 +61,11 @@ NUMBERS: tuple[WizNumberEntityDescription, ...] = ( ), WizNumberEntityDescription( key="dual_head_ratio", + translation_key="dual_head_ratio", native_min_value=0, native_max_value=100, native_step=1, icon="mdi:floor-lamp-dual", - name="Dual head ratio", value_fn=lambda device: cast(int | None, device.state.get_ratio()), set_value_fn=_async_set_ratio, required_feature="dual_head", diff --git a/homeassistant/components/wiz/sensor.py b/homeassistant/components/wiz/sensor.py index e5346e00081..a66c37fabb5 100644 --- a/homeassistant/components/wiz/sensor.py +++ b/homeassistant/components/wiz/sensor.py @@ -23,7 +23,6 @@ from .models import WizData SENSORS: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="rssi", - name="Signal strength", entity_registry_enabled_default=False, state_class=SensorStateClass.MEASUREMENT, device_class=SensorDeviceClass.SIGNAL_STRENGTH, @@ -36,7 +35,6 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( POWER_SENSORS: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="power", - name="Current power", state_class=SensorStateClass.MEASUREMENT, device_class=SensorDeviceClass.POWER, native_unit_of_measurement=UnitOfPower.WATT, diff --git a/homeassistant/components/wiz/strings.json b/homeassistant/components/wiz/strings.json index 656219f13bb..b75e199fe33 100644 --- a/homeassistant/components/wiz/strings.json +++ b/homeassistant/components/wiz/strings.json @@ -29,5 +29,15 @@ "no_devices_found": "[%key:common::config_flow::abort::no_devices_found%]", "already_configured": "[%key:common::config_flow::abort::already_configured_device%]" } + }, + "entity": { + "number": { + "effect_speed": { + "name": "Effect speed" + }, + "dual_head_ratio": { + "name": "Dual head ratio" + } + } } } diff --git a/tests/components/wiz/test_sensor.py b/tests/components/wiz/test_sensor.py index a1eb6ded51d..522eb5c7cba 100644 --- a/tests/components/wiz/test_sensor.py +++ b/tests/components/wiz/test_sensor.py @@ -49,7 +49,7 @@ async def test_power_monitoring(hass: HomeAssistant) -> None: _, entry = await async_setup_integration( hass, wizlight=socket, bulb_type=FAKE_SOCKET_WITH_POWER_MONITORING ) - entity_id = "sensor.mock_title_current_power" + entity_id = "sensor.mock_title_power" entity_registry = er.async_get(hass) reg_entry = entity_registry.async_get(entity_id) assert reg_entry.unique_id == f"{FAKE_MAC}_power"