Allow service data to be passed to shell_command (#2362)
parent
3349bdc2bd
commit
600a3e3965
|
@ -6,6 +6,7 @@ https://home-assistant.io/components/shell_command/
|
|||
"""
|
||||
import logging
|
||||
import subprocess
|
||||
import shlex
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
|
@ -23,8 +24,6 @@ CONFIG_SCHEMA = vol.Schema({
|
|||
}),
|
||||
}, extra=vol.ALLOW_EXTRA)
|
||||
|
||||
SHELL_COMMAND_SCHEMA = vol.Schema({})
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
"""Setup the shell_command component."""
|
||||
|
@ -44,8 +43,7 @@ def setup(hass, config):
|
|||
_LOGGER.exception('Error running command: %s', cmd)
|
||||
|
||||
for name in conf.keys():
|
||||
hass.services.register(DOMAIN, name, service_handler,
|
||||
schema=SHELL_COMMAND_SCHEMA)
|
||||
hass.services.register(DOMAIN, name, service_handler)
|
||||
return True
|
||||
|
||||
|
||||
|
@ -64,6 +62,6 @@ def _parse_command(hass, cmd, variables):
|
|||
shell = True
|
||||
else:
|
||||
# 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
|
||||
return cmd, shell
|
||||
|
|
Loading…
Reference in New Issue