Add scripts editor backend (#8993)

* Add scripts editor backend

* Fix docstrings
This commit is contained in:
Paulus Schoutsen 2017-08-15 22:09:10 -07:00 committed by GitHub
parent 95c57412ff
commit 2dab239021
4 changed files with 45 additions and 10 deletions

View file

@ -39,13 +39,13 @@ ENTITY_ID_FORMAT = DOMAIN + '.{}'
GROUP_NAME_ALL_SCRIPTS = 'all scripts'
_SCRIPT_ENTRY_SCHEMA = vol.Schema({
SCRIPT_ENTRY_SCHEMA = vol.Schema({
CONF_ALIAS: cv.string,
vol.Required(CONF_SEQUENCE): cv.SCRIPT_SCHEMA,
})
CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({cv.slug: _SCRIPT_ENTRY_SCHEMA})
DOMAIN: vol.Schema({cv.slug: SCRIPT_ENTRY_SCHEMA})
}, extra=vol.ALLOW_EXTRA)
SCRIPT_SERVICE_SCHEMA = vol.Schema(dict)
@ -62,12 +62,6 @@ def is_on(hass, entity_id):
return hass.states.is_state(entity_id, STATE_ON)
@bind_hass
def reload(hass):
"""Reload script component."""
hass.services.call(DOMAIN, SERVICE_RELOAD)
@bind_hass
def turn_on(hass, entity_id, variables=None):
"""Turn script on."""
@ -88,6 +82,21 @@ def toggle(hass, entity_id):
hass.services.call(DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: entity_id})
@bind_hass
def reload(hass):
"""Reload script component."""
hass.services.call(DOMAIN, SERVICE_RELOAD)
@bind_hass
def async_reload(hass):
"""Reload the scripts from config.
Returns a coroutine object.
"""
return hass.services.async_call(DOMAIN, SERVICE_RELOAD)
@asyncio.coroutine
def async_setup(hass, config):
"""Load the scripts from the configuration."""