Allow service data to be passed to shell_command (#2362)

pull/2367/head
Dale Higgs 2016-06-23 10:47:56 -05:00 committed by Paulus Schoutsen
parent 3349bdc2bd
commit 600a3e3965
1 changed files with 3 additions and 5 deletions

View File

@ -6,6 +6,7 @@ https://home-assistant.io/components/shell_command/
""" """
import logging import logging
import subprocess import subprocess
import shlex
import voluptuous as vol import voluptuous as vol
@ -23,8 +24,6 @@ CONFIG_SCHEMA = vol.Schema({
}), }),
}, extra=vol.ALLOW_EXTRA) }, extra=vol.ALLOW_EXTRA)
SHELL_COMMAND_SCHEMA = vol.Schema({})
def setup(hass, config): def setup(hass, config):
"""Setup the shell_command component.""" """Setup the shell_command component."""
@ -44,8 +43,7 @@ def setup(hass, config):
_LOGGER.exception('Error running command: %s', cmd) _LOGGER.exception('Error running command: %s', cmd)
for name in conf.keys(): for name in conf.keys():
hass.services.register(DOMAIN, name, service_handler, hass.services.register(DOMAIN, name, service_handler)
schema=SHELL_COMMAND_SCHEMA)
return True return True
@ -64,6 +62,6 @@ def _parse_command(hass, cmd, variables):
shell = True shell = True
else: else:
# template used. Must break into list and use shell=False for security # template used. Must break into list and use shell=False for security
cmd = [prog] + rendered_args.split() cmd = [prog] + shlex.split(rendered_args)
shell = False shell = False
return cmd, shell return cmd, shell