I’m a little puzzled why the following doesn’t work - does anyone have any suggestions please?
I have a shell_command that I’d like to pass variables such as outdoor temperature to a bash script. e.g.
shell_commands.yaml
papirusupdate: /home/homeassistant/papirus.sh {{ states.sensor.netatmo_outdoor1_temperature.state }} {{ states.sensor.lights_on.state }} {{ states.sensor.doors_open.state }}
This generates an error each time it runs:
2018-01-17 15:50:00 INFO (MainThread) [homeassistant.helpers.script] Script Update Papirus: Running script
2018-01-17 15:50:00 INFO (MainThread) [homeassistant.helpers.script] Script Update Papirus: Executing step call service
2018-01-17 15:50:00 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1031, in _event_to_service_call
yield from service_handler.func(service_call)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/shell_command.py", line 86, in async_service_handler
process = yield from create_process
File "/usr/lib/python3.5/asyncio/subprocess.py", line 212, in create_subprocess_exec
stderr=stderr, **kwds)
File "/usr/lib/python3.5/asyncio/base_events.py", line 1189, in subprocess_exec
bufsize, **kwargs)
File "/usr/lib/python3.5/asyncio/unix_events.py", line 191, in _make_subprocess_transport
**kwargs)
File "/usr/lib/python3.5/asyncio/base_subprocess.py", line 39, in __init__
stderr=stderr, bufsize=bufsize, **kwargs)
File "/usr/lib/python3.5/asyncio/unix_events.py", line 695, in _start
universal_newlines=False, bufsize=bufsize, **kwargs)
File "/usr/lib/python3.5/subprocess.py", line 676, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1282, in _execute_child
raise child_exception_type(errno_num, err_msg)
OSError: [Errno 8] Exec format error
If I remove the template and just leave manual numbers in there it works:
papirusupdate: /home/homeassistant/papirus.sh 1 2 3
I don’t think it’s an issue with templating and shell_commands because I also have the following which uses the same templates and works:
pushover_glance: 'curl --data "token=tokenremoved&title={{ states.sensor.pushover_title_glance.state }}&text=OutD:{{ states.sensor.netatmo_outdoor1_temperature.state }} Humi:{{ states.sensor.netatmo_outdoor1_humidity.state }}&subtext=Lights:{{ states.sensor.lights_on.state }} Door/Win:{{ states.sensor.doors_open.state }}" https://api.pushover.net/1/glances.json'
Is there a known issue with calling bash scripts and templates?