Lazy loading of service descriptions (#11479)
* Lazy loading of service descriptions * Fix tests * Load YAML in executor * Return a copy of available services to allow mutations * Remove lint * Add zha/services.yaml * Only cache descriptions for known services * Remove lint * Remove description loading during service registration * Remove description parameter from async_register * Test async_get_all_descriptions * Remove lint * Fix typos from multi-edit * Remove unused arguments * Remove unused import os * Remove unused import os, part 2 * Remove unneeded coroutine decorator * Only use executor for loading files * Cleanups suggested in review * Increase test coverage * Fix races in existing tests
This commit is contained in:
parent
3cbd77f6ac
commit
8267a21bfe
85 changed files with 253 additions and 729 deletions
|
@ -4,7 +4,6 @@ Support for system log.
|
|||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/system_log/
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import asyncio
|
||||
import logging
|
||||
|
@ -15,7 +14,6 @@ from collections import deque
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant import __path__ as HOMEASSISTANT_PATH
|
||||
from homeassistant.config import load_yaml_config_file
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components.http import HomeAssistantView
|
||||
|
||||
|
@ -84,13 +82,8 @@ def async_setup(hass, config):
|
|||
# Only one service so far
|
||||
handler.records.clear()
|
||||
|
||||
descriptions = yield from hass.async_add_job(
|
||||
load_yaml_config_file, os.path.join(
|
||||
os.path.dirname(__file__), 'services.yaml'))
|
||||
|
||||
hass.services.async_register(
|
||||
DOMAIN, SERVICE_CLEAR, async_service_handler,
|
||||
descriptions[DOMAIN].get(SERVICE_CLEAR),
|
||||
schema=SERVICE_CLEAR_SCHEMA)
|
||||
|
||||
return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue