Add bind_hass to components (#8502)

* Add bind_hass to components

* Add bind_hass to group
This commit is contained in:
Paulus Schoutsen 2017-07-16 10:14:46 -07:00 committed by GitHub
parent d3be056d15
commit d29bdddaa7
24 changed files with 138 additions and 0 deletions

View file

@ -6,6 +6,7 @@ import logging
import voluptuous as vol
from homeassistant.exceptions import HomeAssistantError
from homeassistant.loader import bind_hass
from homeassistant.util import sanitize_filename
DOMAIN = 'python_script'
@ -49,6 +50,7 @@ def setup(hass, config):
return True
@bind_hass
def execute_script(hass, name, data=None):
"""Execute a script."""
filename = '{}.py'.format(name)
@ -57,6 +59,7 @@ def execute_script(hass, name, data=None):
execute(hass, filename, source, data)
@bind_hass
def execute(hass, filename, source, data=None):
"""Execute Python source."""
from RestrictedPython import compile_restricted_exec