Command line automation without command line switches

I think this is overdue. Currently if you want to trigger a command line action you have to make a command line switch, then hide the command line switch in your customization and then reference the switch in your automation. It would be much easier if we had a command line class. Something that could be triggered as follows:

- alias: 'A command line automation trigger: state (for example) entity_id: device_tracker.galtwisephone (for example) state: home action: - service: cmd.run_cmd data: "<YOUR COMMAND LINE SCRIPT HERE>"

This doesn’t seem unreasonable, thoughts?

Wouldn’t this be like allowing SQL injection in a round about manner?

i probably would have wished for something like this before i discovered appdaemon.
but since appdaemon there is, all automations are a lot easier when you know a bit of python.

1 Like

Not really at all

I know python! I’ll look into this appdaemon

1 Like

You could make your shell script call with a variable and use it no?

shell_command:
  run_sudo: sudo "{{cmd}}"
automation:
  - alias: 'A command line automation'
    trigger: state (for example)
      entity_id: device_tracker.galtwisephone (for example)
      state: home
  action:
    - service: shell_command.run_sudo
      data:
        cmd: 'cat MEOW'

I did not get this to work.

- id: '1562762467593'
  alias: PS Test
  trigger:
  - entity_id: switch.zwave_1
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
    - service: shell_command.run_sudo
      data:
        cmd: 'pwsh -file /usr/share/hassio/homeassistant/powershell_script/output_date.ps1'