Shell command with argument via REST api

I have a ‘smart’ water heater which I’ve created my own python script to turn on/off and get its state. (currently no component, I might add it if everything works fine)
The python script does accepts ‘time’ as an argument (i.e. -m turn_on -t 15)
Currently I’ve created 3 different switched, each with its own ‘time’ hard coded in the ‘turn_on’ command arguments.
I want to be able to do 2 more things

  1. To be able to call it from REST api with dynamic time (should I create shell_command for that? how can it get the argument?)
  2. To be able to add only 1 switch with ‘time’ as argument, similar to brightness in lights.

Any help will be much appreciated.
Thank you

I think you can pass values to shell command, but can’t find how to.

I do it this way:

  - alias: Hyperion effect
    initial_state: True
      platform: state
      entity_id: input_select.hyperion_effect
      service: shell_command.set_hyperion_effect

  set_hyperion_effect: 'scripts/ "{{ states.input_select.hyperion_effect.state }}"'

You can use an input_number for the time and call your script.

Edt: Found this about passing values to shell_command.

perhaps some code of your hyperion scipt .sh would be helpful…

I don’t use this anymore, because i’m using WLED now, but here it is.



if [ "$1" = "Off" ]; then
    echo '{ "command": "clear"}' | nc $hyperion $hport
    exit 0
    EFF="{\"effect\": {\"name\": \""$1"\"}, \"command\": \"effect\", \"priority\": 100 }"
    echo $EFF | nc $hyperion $hport
    exit 0