mirror of
https://github.com/home-assistant/core.git
synced 2025-04-22 16:27:56 +00:00
Add entity translations to OralB (#97402)
* Make bluetooth use the translation from the entity description * Add entity translations to OralB * Remove links to other platforms * Remove links to other platforms * Remove links to other platforms * Add test * Use is * Fix tests * Update homeassistant/components/oralb/strings.json
This commit is contained in:
parent
3a053afac6
commit
f72efa9618
@ -38,23 +38,31 @@ SENSOR_DESCRIPTIONS: dict[str, SensorEntityDescription] = {
|
||||
),
|
||||
OralBSensor.SECTOR: SensorEntityDescription(
|
||||
key=OralBSensor.SECTOR,
|
||||
translation_key="sector",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
OralBSensor.NUMBER_OF_SECTORS: SensorEntityDescription(
|
||||
key=OralBSensor.NUMBER_OF_SECTORS,
|
||||
translation_key="number_of_sectors",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
OralBSensor.SECTOR_TIMER: SensorEntityDescription(
|
||||
key=OralBSensor.SECTOR_TIMER,
|
||||
translation_key="sector_timer",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
OralBSensor.TOOTHBRUSH_STATE: SensorEntityDescription(
|
||||
key=OralBSensor.TOOTHBRUSH_STATE
|
||||
key=OralBSensor.TOOTHBRUSH_STATE,
|
||||
name=None,
|
||||
),
|
||||
OralBSensor.PRESSURE: SensorEntityDescription(
|
||||
key=OralBSensor.PRESSURE,
|
||||
translation_key="pressure",
|
||||
),
|
||||
OralBSensor.PRESSURE: SensorEntityDescription(key=OralBSensor.PRESSURE),
|
||||
OralBSensor.MODE: SensorEntityDescription(
|
||||
key=OralBSensor.MODE,
|
||||
translation_key="mode",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
OralBSensor.SIGNAL_STRENGTH: SensorEntityDescription(
|
||||
@ -94,10 +102,7 @@ def sensor_update_to_bluetooth_data_update(
|
||||
device_key_to_bluetooth_entity_key(device_key): sensor_values.native_value
|
||||
for device_key, sensor_values in sensor_update.entity_values.items()
|
||||
},
|
||||
entity_names={
|
||||
device_key_to_bluetooth_entity_key(device_key): sensor_values.name
|
||||
for device_key, sensor_values in sensor_update.entity_values.items()
|
||||
},
|
||||
entity_names={},
|
||||
)
|
||||
|
||||
|
||||
|
@ -18,5 +18,24 @@
|
||||
"already_in_progress": "[%key:common::config_flow::abort::already_in_progress%]",
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"sector": {
|
||||
"name": "Sector"
|
||||
},
|
||||
"number_of_sectors": {
|
||||
"name": "Number of sectors"
|
||||
},
|
||||
"sector_timer": {
|
||||
"name": "Sector timer"
|
||||
},
|
||||
"pressure": {
|
||||
"name": "Pressure"
|
||||
},
|
||||
"mode": {
|
||||
"name": "Brushing mode"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,15 +46,10 @@ async def test_sensors(
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all("sensor")) == 9
|
||||
|
||||
toothbrush_sensor = hass.states.get(
|
||||
"sensor.smart_series_7000_48be_toothbrush_state"
|
||||
)
|
||||
toothbrush_sensor = hass.states.get("sensor.smart_series_7000_48be")
|
||||
toothbrush_sensor_attrs = toothbrush_sensor.attributes
|
||||
assert toothbrush_sensor.state == "running"
|
||||
assert (
|
||||
toothbrush_sensor_attrs[ATTR_FRIENDLY_NAME]
|
||||
== "Smart Series 7000 48BE Toothbrush State"
|
||||
)
|
||||
assert toothbrush_sensor_attrs[ATTR_FRIENDLY_NAME] == "Smart Series 7000 48BE"
|
||||
assert ATTR_ASSUMED_STATE not in toothbrush_sensor_attrs
|
||||
|
||||
assert await hass.config_entries.async_unload(entry.entry_id)
|
||||
@ -77,10 +72,7 @@ async def test_sensors(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# All of these devices are sleepy so we should still be available
|
||||
toothbrush_sensor = hass.states.get(
|
||||
"sensor.smart_series_7000_48be_toothbrush_state"
|
||||
)
|
||||
toothbrush_sensor_attrs = toothbrush_sensor.attributes
|
||||
toothbrush_sensor = hass.states.get("sensor.smart_series_7000_48be")
|
||||
assert toothbrush_sensor.state == "running"
|
||||
|
||||
|
||||
@ -104,10 +96,12 @@ async def test_sensors_io_series_4(
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all("sensor")) == 9
|
||||
|
||||
toothbrush_sensor = hass.states.get("sensor.io_series_4_48be_mode")
|
||||
toothbrush_sensor = hass.states.get("sensor.io_series_4_48be_brushing_mode")
|
||||
toothbrush_sensor_attrs = toothbrush_sensor.attributes
|
||||
assert toothbrush_sensor.state == "gum care"
|
||||
assert toothbrush_sensor_attrs[ATTR_FRIENDLY_NAME] == "IO Series 4 48BE Mode"
|
||||
assert (
|
||||
toothbrush_sensor_attrs[ATTR_FRIENDLY_NAME] == "IO Series 4 48BE Brushing mode"
|
||||
)
|
||||
assert ATTR_ASSUMED_STATE not in toothbrush_sensor_attrs
|
||||
|
||||
# Fast-forward time without BLE advertisements
|
||||
@ -131,7 +125,7 @@ async def test_sensors_io_series_4(
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
toothbrush_sensor = hass.states.get("sensor.io_series_4_48be_mode")
|
||||
toothbrush_sensor = hass.states.get("sensor.io_series_4_48be_brushing_mode")
|
||||
# Sleepy devices should keep their state over time
|
||||
assert toothbrush_sensor.state == "gum care"
|
||||
toothbrush_sensor_attrs = toothbrush_sensor.attributes
|
||||
@ -157,6 +151,7 @@ async def test_sensors_battery(hass: HomeAssistant) -> None:
|
||||
|
||||
bat_sensor = hass.states.get("sensor.io_series_6_7_1dcf_battery")
|
||||
assert bat_sensor.state == "49"
|
||||
assert bat_sensor.name == "IO Series 6/7 1DCF Battery"
|
||||
|
||||
assert await hass.config_entries.async_unload(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
Loading…
x
Reference in New Issue
Block a user