Add entity translations to Wiz (#96826)

This commit is contained in:
Joost Lekkerkerker 2023-07-22 16:28:48 +02:00 committed by GitHub
parent 47426e50d3
commit 11fd43b1fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 6 deletions

View File

@ -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."""

View File

@ -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",

View File

@ -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,

View File

@ -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"
}
}
}
}

View File

@ -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"