Restructure translations for entity components (#89702)

This commit is contained in:
Franck Nijhof 2023-03-16 12:16:08 +01:00 committed by GitHub
parent f55aaf7664
commit f32b7859b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 435 additions and 321 deletions

View File

@ -26,19 +26,21 @@
"armed_vacation": "{entity_name} armed vacation"
}
},
"state": {
"entity_component": {
"_": {
"armed": "Armed",
"disarmed": "Disarmed",
"armed_home": "Armed home",
"armed_away": "Armed away",
"armed_night": "Armed night",
"armed_vacation": "Armed vacation",
"armed_custom_bypass": "Armed custom bypass",
"pending": "Pending",
"arming": "Arming",
"disarming": "Disarming",
"triggered": "Triggered"
"state": {
"armed": "Armed",
"disarmed": "Disarmed",
"armed_home": "Armed home",
"armed_away": "Armed away",
"armed_night": "Armed night",
"armed_vacation": "Armed vacation",
"armed_custom_bypass": "Armed custom bypass",
"pending": "Pending",
"arming": "Arming",
"disarming": "Disarming",
"triggered": "Triggered"
}
}
}
}

View File

@ -1,10 +1,12 @@
{
"title": "Alert",
"state": {
"entity_component": {
"_": {
"idle": "[%key:common::state::idle%]",
"off": "Acknowledged",
"on": "[%key:common::state::active%]"
"state": {
"idle": "[%key:common::state::idle%]",
"off": "Acknowledged",
"on": "[%key:common::state::active%]"
}
}
}
}

View File

@ -1,9 +1,11 @@
{
"title": "Automation",
"state": {
"entity_component": {
"_": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
}
},
"issues": {

View File

@ -106,114 +106,168 @@
"turned_off": "{entity_name} turned off"
}
},
"state": {
"entity_component": {
"_": {
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
},
"battery": {
"off": "Normal",
"on": "Low"
"state": {
"off": "Normal",
"on": "Low"
}
},
"battery_charging": {
"off": "Not charging",
"on": "Charging"
"state": {
"off": "Not charging",
"on": "Charging"
}
},
"carbon_monoxide": {
"off": "[%key:component::binary_sensor::state::gas::off%]",
"on": "[%key:component::binary_sensor::state::gas::on%]"
"state": {
"off": "[%key:component::binary_sensor::entity_component::gas::state::off%]",
"on": "[key:component::binary_sensor::entity_component::gas::state::on%]"
}
},
"cold": {
"off": "[%key:component::binary_sensor::state::battery::off%]",
"on": "Cold"
"state": {
"off": "[%key:component::binary_sensor::entity_component::battery::state::off%]",
"on": "Cold"
}
},
"connectivity": {
"off": "[%key:common::state::disconnected%]",
"on": "[%key:common::state::connected%]"
"state": {
"off": "[%key:common::state::disconnected%]",
"on": "[%key:common::state::connected%]"
}
},
"door": {
"off": "[%key:common::state::closed%]",
"on": "[%key:common::state::open%]"
"state": {
"off": "[%key:common::state::closed%]",
"on": "[%key:common::state::open%]"
}
},
"garage_door": {
"off": "[%key:common::state::closed%]",
"on": "[%key:common::state::open%]"
"state": {
"off": "[%key:common::state::closed%]",
"on": "[%key:common::state::open%]"
}
},
"gas": {
"off": "Clear",
"on": "Detected"
"state": {
"off": "Clear",
"on": "Detected"
}
},
"heat": {
"off": "[%key:component::binary_sensor::state::battery::off%]",
"on": "Hot"
"state": {
"off": "[%key:component::binary_sensor::entity_component::battery::state::off%]",
"on": "Hot"
}
},
"light": {
"off": "No light",
"on": "Light detected"
"state": {
"off": "No light",
"on": "Light detected"
}
},
"lock": {
"off": "[%key:common::state::locked%]",
"on": "[%key:common::state::unlocked%]"
"state": {
"off": "[%key:common::state::locked%]",
"on": "[%key:common::state::unlocked%]"
}
},
"moisture": {
"off": "Dry",
"on": "Wet"
"state": {
"off": "Dry",
"on": "Wet"
}
},
"motion": {
"off": "[%key:component::binary_sensor::state::gas::off%]",
"on": "[%key:component::binary_sensor::state::gas::on%]"
"state": {
"off": "[key:component::binary_sensor::entity_component::gas::state::off%]",
"on": "[key:component::binary_sensor::entity_component::gas::state::on%]"
}
},
"moving": {
"off": "Not moving",
"on": "Moving"
"state": {
"off": "Not moving",
"on": "Moving"
}
},
"occupancy": {
"off": "[%key:component::binary_sensor::state::gas::off%]",
"on": "[%key:component::binary_sensor::state::gas::on%]"
"state": {
"off": "[key:component::binary_sensor::entity_component::gas::state::off%]",
"on": "[key:component::binary_sensor::entity_component::gas::state::on%]"
}
},
"opening": {
"off": "[%key:common::state::closed%]",
"on": "[%key:common::state::open%]"
"state": {
"off": "[%key:common::state::closed%]",
"on": "[%key:common::state::open%]"
}
},
"plug": {
"off": "Unplugged",
"on": "Plugged in"
"state": {
"off": "Unplugged",
"on": "Plugged in"
}
},
"presence": {
"off": "[%key:component::device_tracker::state::_::not_home%]",
"on": "[%key:component::device_tracker::state::_::home%]"
"state": {
"off": "[%key:component::device_tracker::entity_component::_::state::not_home%]",
"on": "[%key:component::device_tracker::entity_component::_::state::home%]"
}
},
"problem": {
"off": "OK",
"on": "Problem"
"state": {
"off": "OK",
"on": "Problem"
}
},
"running": {
"off": "Not running",
"on": "Running"
"state": {
"off": "Not running",
"on": "Running"
}
},
"safety": {
"off": "Safe",
"on": "Unsafe"
"state": {
"off": "Safe",
"on": "Unsafe"
}
},
"smoke": {
"off": "[%key:component::binary_sensor::state::gas::off%]",
"on": "[%key:component::binary_sensor::state::gas::on%]"
"state": {
"off": "[key:component::binary_sensor::entity_component::gas::state::off%]",
"on": "[key:component::binary_sensor::entity_component::gas::state::on%]"
}
},
"sound": {
"off": "[%key:component::binary_sensor::state::gas::off%]",
"on": "[%key:component::binary_sensor::state::gas::on%]"
"state": {
"off": "[key:component::binary_sensor::entity_component::gas::state::off%]",
"on": "[key:component::binary_sensor::entity_component::gas::state::on%]"
}
},
"update": {
"off": "Up-to-date",
"on": "Update available"
"state": {
"off": "Up-to-date",
"on": "Update available"
}
},
"vibration": {
"off": "[%key:component::binary_sensor::state::gas::off%]",
"on": "[%key:component::binary_sensor::state::gas::on%]"
"state": {
"off": "[key:component::binary_sensor::entity_component::gas::state::off%]",
"on": "[key:component::binary_sensor::entity_component::gas::state::on%]"
}
},
"window": {
"off": "[%key:common::state::closed%]",
"on": "[%key:common::state::open%]"
},
"_": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
"state": {
"off": "[%key:common::state::closed%]",
"on": "[%key:common::state::open%]"
}
}
},
"device_class": {

View File

@ -1,9 +1,11 @@
{
"title": "Calendar",
"state": {
"entity_component": {
"_": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
}
}
}

View File

@ -1,10 +1,12 @@
{
"title": "Camera",
"state": {
"entity_component": {
"_": {
"recording": "Recording",
"streaming": "Streaming",
"idle": "[%key:common::state::idle%]"
"state": {
"recording": "Recording",
"streaming": "Streaming",
"idle": "[%key:common::state::idle%]"
}
}
}
}

View File

@ -15,92 +15,92 @@
"set_preset_mode": "Change preset on {entity_name}"
}
},
"state": {
"entity_component": {
"_": {
"off": "[%key:common::state::off%]",
"heat": "Heat",
"cool": "Cool",
"heat_cool": "Heat/Cool",
"auto": "Auto",
"dry": "Dry",
"fan_only": "Fan only"
}
},
"state_attributes": {
"_": {
"aux_heat": { "name": "Aux heat" },
"current_humidity": { "name": "Current humidity" },
"current_temperature": { "name": "Current temperature" },
"fan_mode": {
"name": "Fan mode",
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]",
"auto": "Auto",
"low": "Low",
"medium": "Medium",
"high": "High",
"top": "Top",
"middle": "Middle",
"focus": "Focus",
"diffuse": "Diffuse"
}
"state": {
"off": "[%key:common::state::off%]",
"heat": "Heat",
"cool": "Cool",
"heat_cool": "Heat/Cool",
"auto": "Auto",
"dry": "Dry",
"fan_only": "Fan only"
},
"fan_modes": {
"name": "Fan modes"
},
"humidity": { "name": "Target humidity" },
"hvac_action": {
"name": "Current action",
"state": {
"off": "Off",
"heating": "Heating",
"cooling": "Cooling",
"drying": "Drying",
"idle": "Idle",
"fan": "Fan"
}
},
"hvac_modes": {
"name": "HVAC modes"
},
"max_humidity": { "name": "Max target humidity" },
"max_temp": { "name": "Max target temperature" },
"min_humidity": { "name": "Min target humidity" },
"min_temp": { "name": "Min target temperature" },
"preset_mode": {
"name": "Preset",
"state": {
"none": "None",
"eco": "Eco",
"away": "Away",
"boost": "Boost",
"comfort": "Comfort",
"home": "Home",
"sleep": "Sleep",
"activity": "Activity"
}
},
"preset_modes": {
"name": "Presets"
},
"swing_mode": {
"name": "Swing mode",
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]",
"both": "Both",
"vertical": "Vertical",
"horizontal": "Horizontal"
}
},
"swing_modes": {
"name": "Swing modes"
},
"target_temp_high": { "name": "Upper target temperature" },
"target_temp_low": { "name": "Lower target temperature" },
"target_temp_step": { "name": "Target temperature step" },
"temperature": { "name": "Target temperature" }
"state_attributes": {
"aux_heat": { "name": "Aux heat" },
"current_humidity": { "name": "Current humidity" },
"current_temperature": { "name": "Current temperature" },
"fan_mode": {
"name": "Fan mode",
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]",
"auto": "Auto",
"low": "Low",
"medium": "Medium",
"high": "High",
"top": "Top",
"middle": "Middle",
"focus": "Focus",
"diffuse": "Diffuse"
}
},
"fan_modes": {
"name": "Fan modes"
},
"humidity": { "name": "Target humidity" },
"hvac_action": {
"name": "Current action",
"state": {
"off": "Off",
"heating": "Heating",
"cooling": "Cooling",
"drying": "Drying",
"idle": "Idle",
"fan": "Fan"
}
},
"hvac_modes": {
"name": "HVAC modes"
},
"max_humidity": { "name": "Max target humidity" },
"max_temp": { "name": "Max target temperature" },
"min_humidity": { "name": "Min target humidity" },
"min_temp": { "name": "Min target temperature" },
"preset_mode": {
"name": "Preset",
"state": {
"none": "None",
"eco": "Eco",
"away": "Away",
"boost": "Boost",
"comfort": "Comfort",
"home": "Home",
"sleep": "Sleep",
"activity": "Activity"
}
},
"preset_modes": {
"name": "Presets"
},
"swing_mode": {
"name": "Swing mode",
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]",
"both": "Both",
"vertical": "Vertical",
"horizontal": "Horizontal"
}
},
"swing_modes": {
"name": "Swing modes"
},
"target_temp_high": { "name": "Upper target temperature" },
"target_temp_low": { "name": "Lower target temperature" },
"target_temp_step": { "name": "Target temperature step" },
"temperature": { "name": "Target temperature" }
}
}
}
}

View File

@ -1,9 +1,11 @@
{
"title": "Configurator",
"state": {
"entity_component": {
"_": {
"configure": "Configure",
"configured": "Configured"
"state": {
"configure": "Configure",
"configured": "Configured"
}
}
}
}

View File

@ -27,13 +27,15 @@
"tilt_position": "{entity_name} tilt position changes"
}
},
"state": {
"entity_component": {
"_": {
"open": "[%key:common::state::open%]",
"opening": "Opening",
"closed": "[%key:common::state::closed%]",
"closing": "Closing",
"stopped": "Stopped"
"state": {
"open": "[%key:common::state::open%]",
"opening": "Opening",
"closed": "[%key:common::state::closed%]",
"closing": "Closing",
"stopped": "Stopped"
}
}
}
}

View File

@ -10,10 +10,12 @@
"leaves": "{entity_name} leaves a zone"
}
},
"state": {
"entity_component": {
"_": {
"home": "[%key:common::state::home%]",
"not_home": "[%key:common::state::not_home%]"
"state": {
"home": "[%key:common::state::home%]",
"not_home": "[%key:common::state::not_home%]"
}
}
}
}

View File

@ -16,10 +16,12 @@
"turn_off": "Turn off {entity_name}"
}
},
"state": {
"entity_component": {
"_": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
}
}
}

View File

@ -155,18 +155,20 @@
}
}
},
"state": {
"entity_component": {
"_": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]",
"home": "[%key:component::device_tracker::state::_::home%]",
"not_home": "[%key:component::device_tracker::state::_::not_home%]",
"open": "[%key:common::state::open%]",
"closed": "[%key:common::state::closed%]",
"locked": "[%key:common::state::locked%]",
"unlocked": "[%key:common::state::unlocked%]",
"ok": "[%key:component::binary_sensor::state::problem::off%]",
"problem": "[%key:component::binary_sensor::state::problem::on%]"
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]",
"home": "[%key:component::device_tracker::entity_component::_::state::home%]",
"not_home": "[%key:component::device_tracker::entity_component::_::state::not_home%]",
"open": "[%key:common::state::open%]",
"closed": "[%key:common::state::closed%]",
"locked": "[%key:common::state::locked%]",
"unlocked": "[%key:common::state::unlocked%]",
"ok": "[%key:component::binary_sensor::entity_component::problem::state::off%]",
"problem": "[%key:component::binary_sensor::entity_component::problem::state::on%]"
}
}
}
}

View File

@ -20,10 +20,12 @@
"turn_off": "Turn off {entity_name}"
}
},
"state": {
"entity_component": {
"_": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
}
}
}

View File

@ -1,9 +1,11 @@
{
"title": "Input boolean",
"state": {
"entity_component": {
"_": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
}
}
}

View File

@ -19,10 +19,12 @@
"turned_off": "{entity_name} turned off"
}
},
"state": {
"entity_component": {
"_": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
}
}
}

View File

@ -15,10 +15,12 @@
"unlocked": "{entity_name} unlocked"
}
},
"state": {
"entity_component": {
"_": {
"locked": "[%key:common::state::locked%]",
"unlocked": "[%key:common::state::unlocked%]"
"state": {
"locked": "[%key:common::state::locked%]",
"unlocked": "[%key:common::state::unlocked%]"
}
}
}
}

View File

@ -19,15 +19,17 @@
"changed_states": "{entity_name} changed states"
}
},
"state": {
"entity_component": {
"_": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]",
"playing": "Playing",
"paused": "[%key:common::state::paused%]",
"idle": "[%key:common::state::idle%]",
"standby": "[%key:common::state::standby%]",
"buffering": "Buffering"
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]",
"playing": "Playing",
"paused": "[%key:common::state::paused%]",
"idle": "[%key:common::state::idle%]",
"standby": "[%key:common::state::standby%]",
"buffering": "Buffering"
}
}
}
}

View File

@ -1,9 +1,11 @@
{
"title": "Person",
"state": {
"entity_component": {
"_": {
"home": "[%key:common::state::home%]",
"not_home": "[%key:common::state::not_home%]"
"state": {
"home": "[%key:common::state::home%]",
"not_home": "[%key:common::state::not_home%]"
}
}
}
}

View File

@ -1,9 +1,11 @@
{
"title": "Plant Monitor",
"state": {
"entity_component": {
"_": {
"ok": "[%key:component::binary_sensor::state::problem::off%]",
"problem": "[%key:component::binary_sensor::state::problem::on%]"
"state": {
"ok": "[%key:component::binary_sensor::entity_component::problem::state::off%]",
"problem": "[%key:component::binary_sensor::entity_component::problem::state::on%]"
}
}
}
}

View File

@ -16,10 +16,12 @@
"turned_off": "{entity_name} turned off"
}
},
"state": {
"entity_component": {
"_": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
}
}
}

View File

@ -1,9 +1,11 @@
{
"title": "Schedule",
"state": {
"entity_component": {
"_": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
}
}
}

View File

@ -1,9 +1,11 @@
{
"title": "Script",
"state": {
"entity_component": {
"_": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
}
}
}

View File

@ -94,10 +94,12 @@
"wind_speed": "{entity_name} wind speed changes"
}
},
"state": {
"entity_component": {
"_": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
}
}
}

View File

@ -10,10 +10,12 @@
"single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]"
}
},
"state": {
"entity_component": {
"_": {
"above_horizon": "Above horizon",
"below_horizon": "Below horizon"
"state": {
"above_horizon": "Above horizon",
"below_horizon": "Below horizon"
}
}
}
}

View File

@ -16,10 +16,12 @@
"turned_off": "{entity_name} turned off"
}
},
"state": {
"entity_component": {
"_": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
"state": {
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]"
}
}
}
}

View File

@ -1,9 +1,11 @@
{
"state": {
"entity_component": {
"_": {
"active": "[%key:common::state::active%]",
"idle": "[%key:common::state::idle%]",
"paused": "[%key:common::state::paused%]"
"state": {
"active": "[%key:common::state::active%]",
"idle": "[%key:common::state::idle%]",
"paused": "[%key:common::state::paused%]"
}
}
}
}

View File

@ -14,16 +14,18 @@
"dock": "Let {entity_name} return to the dock"
}
},
"state": {
"entity_component": {
"_": {
"cleaning": "Cleaning",
"docked": "Docked",
"error": "Error",
"idle": "[%key:common::state::idle%]",
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]",
"paused": "[%key:common::state::paused%]",
"returning": "Returning to dock"
"state": {
"cleaning": "Cleaning",
"docked": "Docked",
"error": "Error",
"idle": "[%key:common::state::idle%]",
"off": "[%key:common::state::off%]",
"on": "[%key:common::state::on%]",
"paused": "[%key:common::state::paused%]",
"returning": "Returning to dock"
}
}
}
}

View File

@ -5,15 +5,17 @@
"turn_off": "Turn off {entity_name}"
}
},
"state": {
"entity_component": {
"_": {
"off": "[%key:common::state::off%]",
"eco": "Eco",
"electric": "Electric",
"gas": "Gas",
"high_demand": "High Demand",
"heat_pump": "Heat Pump",
"performance": "Performance"
"state": {
"off": "[%key:common::state::off%]",
"eco": "Eco",
"electric": "Electric",
"gas": "Gas",
"high_demand": "High Demand",
"heat_pump": "Heat Pump",
"performance": "Performance"
}
}
}
}

View File

@ -1,21 +1,23 @@
{
"state": {
"entity_component": {
"_": {
"clear-night": "Clear, night",
"cloudy": "Cloudy",
"exceptional": "Exceptional",
"fog": "Fog",
"hail": "Hail",
"lightning": "Lightning",
"lightning-rainy": "Lightning, rainy",
"partlycloudy": "Partly cloudy",
"pouring": "Pouring",
"rainy": "Rainy",
"snowy": "Snowy",
"snowy-rainy": "Snowy, rainy",
"sunny": "Sunny",
"windy": "Windy",
"windy-variant": "Windy"
"state": {
"clear-night": "Clear, night",
"cloudy": "Cloudy",
"exceptional": "Exceptional",
"fog": "Fog",
"hail": "Hail",
"lightning": "Lightning",
"lightning-rainy": "Lightning, rainy",
"partlycloudy": "Partly cloudy",
"pouring": "Pouring",
"rainy": "Rainy",
"snowy": "Snowy",
"snowy-rainy": "Snowy, rainy",
"sunny": "Sunny",
"windy": "Windy",
"windy-variant": "Windy"
}
}
}
}

View File

@ -255,13 +255,16 @@ class _TranslationCache:
categories.update(resource)
for category in categories:
resource_func = (
_merge_resources if category == "state" else _build_resources
)
new_resources: Mapping[str, dict[str, Any] | str]
new_resources = resource_func( # type: ignore[assignment]
translation_strings, components, category
)
if category in ("state", "entity_component"):
new_resources = _merge_resources(
translation_strings, components, category
)
else:
new_resources = _build_resources(
translation_strings, components, category
)
for component, resource in new_resources.items():
category_cache: dict[str, Any] = cached.setdefault(
@ -299,7 +302,7 @@ async def async_get_translations(
components = set(integrations)
elif config_flow:
components = (await async_get_config_flows(hass)) - hass.config.components
elif category == "state":
elif category in ("state", "entity_component"):
components = set(hass.config.components)
else:
# Only 'state' supports merging, so remove platforms from selection

View File

@ -231,25 +231,6 @@ def gen_strings_schema(config: Config, integration: Integration) -> vol.Schema:
vol.Optional("trigger_type"): {str: cv.string_with_no_html},
vol.Optional("trigger_subtype"): {str: cv.string_with_no_html},
},
vol.Optional("state"): cv.schema_with_slug_keys(
cv.schema_with_slug_keys(
cv.string_with_no_html, slug_validator=translation_key_validator
),
slug_validator=vol.Any("_", cv.slug),
),
vol.Optional("state_attributes"): cv.schema_with_slug_keys(
cv.schema_with_slug_keys(
{
vol.Optional("name"): str,
vol.Optional("state"): cv.schema_with_slug_keys(
cv.string_with_no_html,
slug_validator=translation_key_validator,
),
},
slug_validator=translation_key_validator,
),
slug_validator=vol.Any("_", cv.slug),
),
vol.Optional("system_health"): {
vol.Optional("info"): cv.schema_with_slug_keys(
cv.string_with_no_html, slug_validator=translation_key_validator
@ -283,26 +264,48 @@ def gen_strings_schema(config: Config, integration: Integration) -> vol.Schema:
),
)
},
vol.Optional("entity"): {
str: {
str: {
vol.Optional("entity_component"): cv.schema_with_slug_keys(
{
vol.Optional("state"): cv.schema_with_slug_keys(
cv.string_with_no_html,
slug_validator=translation_key_validator,
),
vol.Optional("state_attributes"): cv.schema_with_slug_keys(
{
vol.Optional("name"): str,
vol.Optional("state"): cv.schema_with_slug_keys(
cv.string_with_no_html,
slug_validator=translation_key_validator,
),
},
slug_validator=translation_key_validator,
),
},
slug_validator=vol.Any("_", cv.slug),
),
vol.Optional("entity"): cv.schema_with_slug_keys(
cv.schema_with_slug_keys(
{
vol.Optional("name"): cv.string_with_no_html,
vol.Optional("state_attributes"): {
str: {
vol.Optional("state"): cv.schema_with_slug_keys(
cv.string_with_no_html,
slug_validator=translation_key_validator,
),
vol.Optional("state_attributes"): cv.schema_with_slug_keys(
{
vol.Optional("name"): cv.string_with_no_html,
vol.Optional("state"): cv.schema_with_slug_keys(
cv.string_with_no_html,
slug_validator=translation_key_validator,
),
}
},
vol.Optional("state"): cv.schema_with_slug_keys(
cv.string_with_no_html,
},
slug_validator=translation_key_validator,
),
}
}
},
},
slug_validator=translation_key_validator,
),
slug_validator=cv.slug,
),
}
)

View File

@ -373,32 +373,32 @@ async def test_caching(hass: HomeAssistant) -> None:
"homeassistant.helpers.translation._merge_resources",
side_effect=translation._merge_resources,
) as mock_merge:
load1 = await translation.async_get_translations(hass, "en", "state")
load1 = await translation.async_get_translations(hass, "en", "entity_component")
assert len(mock_merge.mock_calls) == 1
load2 = await translation.async_get_translations(hass, "en", "state")
load2 = await translation.async_get_translations(hass, "en", "entity_component")
assert len(mock_merge.mock_calls) == 1
assert load1 == load2
for key in load1:
assert key.startswith("component.sensor.state.") or key.startswith(
"component.light.state."
)
assert key.startswith(
"component.sensor.entity_component._.state."
) or key.startswith("component.light.entity_component._.state.")
load_sensor_only = await translation.async_get_translations(
hass, "en", "state", integrations={"sensor"}
hass, "en", "entity_component", integrations={"sensor"}
)
assert load_sensor_only
for key in load_sensor_only:
assert key.startswith("component.sensor.state.")
assert key.startswith("component.sensor.entity_component._.state.")
load_light_only = await translation.async_get_translations(
hass, "en", "state", integrations={"light"}
hass, "en", "entity_component", integrations={"light"}
)
assert load_light_only
for key in load_light_only:
assert key.startswith("component.light.state.")
assert key.startswith("component.light.entity_component._.state.")
hass.config.components.add("media_player")