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
|
@ -6,13 +6,11 @@ https://home-assistant.io/components/eight_sleep/
|
|||
"""
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
from datetime import timedelta
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.config import load_yaml_config_file
|
||||
from homeassistant.const import (
|
||||
CONF_USERNAME, CONF_PASSWORD, CONF_SENSORS, CONF_BINARY_SENSORS,
|
||||
ATTR_ENTITY_ID, EVENT_HOMEASSISTANT_STOP)
|
||||
|
@ -159,10 +157,6 @@ def async_setup(hass, config):
|
|||
CONF_BINARY_SENSORS: binary_sensors,
|
||||
}, config))
|
||||
|
||||
descriptions = yield from hass.async_add_job(
|
||||
load_yaml_config_file,
|
||||
os.path.join(os.path.dirname(__file__), 'services.yaml'))
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_service_handler(service):
|
||||
"""Handle eight sleep service calls."""
|
||||
|
@ -183,7 +177,6 @@ def async_setup(hass, config):
|
|||
# Register services
|
||||
hass.services.async_register(
|
||||
DOMAIN, SERVICE_HEAT_SET, async_service_handler,
|
||||
descriptions[DOMAIN].get(SERVICE_HEAT_SET),
|
||||
schema=SERVICE_EIGHT_SCHEMA)
|
||||
|
||||
@asyncio.coroutine
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue