Migrate & fix logger services to support translations (#96393)

* Migrate logger services to support translations

* Fix tests and schema validation

* Apply suggestions from code review

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>

---------

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
This commit is contained in:
Franck Nijhof 2023-07-12 16:37:18 +02:00 committed by GitHub
parent 18cc56ae96
commit 594d240a96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 20 deletions

View File

@ -1,26 +1,14 @@
set_default_level:
name: Set default level
description: Set the default log level for integrations.
fields:
level:
name: Level
description: Default severity level for all integrations.
selector:
select:
options:
- label: "Debug"
value: "debug"
- label: "Info"
value: "info"
- label: "Warning"
value: "warning"
- label: "Error"
value: "error"
- label: "Fatal"
value: "fatal"
- label: "Critical"
value: "critical"
- "debug"
- "info"
- "warning"
- "error"
- "fatal"
- "critical"
translation_key: level
set_level:
name: Set level
description: Set log level for integrations.

View File

@ -0,0 +1,30 @@
{
"services": {
"set_default_level": {
"name": "Set default level",
"description": "Sets the default log level for integrations.",
"fields": {
"level": {
"name": "Level",
"description": "Default severity level for all integrations."
}
}
},
"set_level": {
"name": "Set level",
"description": "Sets the log level for one or more integrations."
}
},
"selector": {
"level": {
"options": {
"debug": "Debug",
"info": "Info",
"warning": "Warning",
"error": "Error",
"fatal": "Fatal",
"critical": "Critical"
}
}
}
}

View File

@ -173,7 +173,7 @@ _SERVICE_SCHEMA = vol.Schema(
extra=vol.ALLOW_EXTRA,
)
_SERVICES_SCHEMA = vol.Schema({cv.slug: _SERVICE_SCHEMA})
_SERVICES_SCHEMA = vol.Schema({cv.slug: vol.Any(None, _SERVICE_SCHEMA)})
class ServiceParams(TypedDict):

View File

@ -677,6 +677,9 @@ async def test_async_get_all_descriptions_failing_integration(
with patch(
"homeassistant.helpers.service.async_get_integrations",
return_value={"logger": ImportError},
), patch(
"homeassistant.helpers.service.translation.async_get_translations",
return_value={},
):
descriptions = await service.async_get_all_descriptions(hass)