StefanoGiu
(Stefano Giugliano)
April 10, 2020, 3:25pm
1
Lovelace:
- type: button
entity: sensor.centralina_irrigazione
style:
left: 17%
top: 37%
#--iron-icon-height: 30px
#--iron-icon-width: 30px
icon: 'mdi:radio'
tap_action:
action: call-service
service: script.water_a_zone
service_data:
zona: 1
minuti: 5
Script:
water_a_zone:
alias: Innaffia una zona
sequence:
- service: shell_command.run_netro
data_template:
zona_val: >
{{zona}}
minuti_val: >
{{minuti}}
shell_command:
run_netro: python C:\GoogleHome\Python\NetroRun.py {{zona_val}} {{minuti_val}}
When I try to run, I got the following error:
2020-04-10 17:24:55 ERROR (MainThread) [homeassistant.components.shell_command] Error running command: `python C:\GoogleHome\Python\NetroRun.py {{zona_val}} {{minuti_val}}`, return code: 2
StefanoGiu
(Stefano Giugliano)
April 11, 2020, 6:31am
2
Adding logs into the shell_command/init.py I can see:
rendered_args=C:\GoogleHome\Python\NetroRun.py 1 5
args=C:\GoogleHome\Python\NetroRun.py {{zona_val}} {{minuti_val}}
But still I got error:
2020-04-10 17:24:55 ERROR (MainThread) [homeassistant.components.shell_command] Error running command: python C:\GoogleHome\Python\NetroRun.py {{zona_val}} {{minuti_val}}
, return code: 2
AhmadK
(akasma74)
April 11, 2020, 6:48am
3
take a look at this (imho similar) case.
you probably need to escape your backslashes (or replace them with forward slashes).
StefanoGiu
(Stefano Giugliano)
April 11, 2020, 6:50am
4
I don’t think this is the problem… If I put the values instead of the templates in the shell_command… it works like a charm!!!
Moreover rendered_args looks fine!!!
I think the problem is here shlex.split(rendered_args)
This function maybe it’s not compatible with Windows…
AhmadK
(akasma74)
April 11, 2020, 6:55am
5
It’s completely up to you. The OP from the linked topic has exactly the same symptoms - his hardcoded commands did work just fine
StefanoGiu
(Stefano Giugliano)
April 11, 2020, 7:30am
6
@AhmadK using the forward slashes worked!!! Thanks a lot!!
1 Like
AhmadK
(akasma74)
April 11, 2020, 7:32am
7
That’s great!
Please mark a post with a solution by ticking the checkbox next to it.
I will show your post as Solved and a link to the solution post right below your question so future readers could find it easily.