@@ -0,0 +1,1246 @@
+%22%22%22%0Ahomeassistant.components.shell_command%0A~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%0A%0AComponent to expose shell commands as services.%0A%0Ashell_command:%0A  restart_pow: touch ~/.pow/restart.txt%0A%0A%22%22%22%0Aimport logging%0Aimport subprocess%0A%0Afrom homeassistant.util import slugify%0A%0ADOMAIN = 'shell_command'%0ADEPENDENCIES = %5B%5D%0A%0A_LOGGER = logging.getLogger(__name__)%0A%0A%0Adef setup(hass, config):%0A    %22%22%22 Sets up the shell_command component. %22%22%22%0A    conf = config.get(DOMAIN)%0A%0A    if not isinstance(conf, dict):%0A        _LOGGER.error('Expected configuration to be a dictionary')%0A        return False%0A%0A    for name in conf.keys():%0A        if name != slugify(name):%0A            _LOGGER.error('Invalid service name: %25s. Try %25s',%0A                          name, slugify(name))%0A            return False%0A%0A    def service_handler(call):%0A        %22%22%22 Execute a shell command service. %22%22%22%0A        try:%0A            subprocess.call(conf%5Bcall.service%5D.split(' '),%0A                            stdout=subprocess.DEVNULL,%0A                            stderr=subprocess.DEVNULL)%0A        except subprocess.SubprocessError:%0A            _LOGGER.exception('Error running command')%0A%0A    for name in conf.keys():%0A        hass.services.register(DOMAIN, name, service_handler)%0A%0A    return True%0A

Add shell_command component