Exposing a shell_command to a voice assistant?

I’ve got a shell_command working, and right now, I’ve just attached it directly to a dashboard button to run when clicked. This works fine.

I’d like to expose it to my Google Assistant, but to do that, it looks like the configuration.yaml needs an exposed_domain and an entity to work. I’m not entirely sure the best way to setup the shell_command to be available to this, which is primarily why I posted in Configuration and not Voice Assistants, because I’m just not sure how to configure it to the point where I can move to the Voice Assistant configuration.

Would I need to create a device, add an entity to it, tie this shell_command to that, and then use the device as the exposed_domain?

Command line sensor!

1 Like

Looking at the documentation, I’m not entirely sure how that’d help me here, though if you could tell me more it wouldn’t surprise me that I’m missing something.

I should add, right now, my command is setup in my configuration.yaml using

shell_command:
  ark_script: "ssh -i /config/.ssh/id_rsa -o UserKnownHostsFile=/config/.ssh/known_hosts [email protected] '/home/user/toggle_ark_server.sh' "

and the button is just using

show_name: true
show_icon: true
type: button
show_state: true
hold_action:
  action: none
tap_action:
  action: perform-action
  perform_action: shell_command.ark_script
  target: {}
name: Ark Server
icon: mdi:controller

To my knowledge, I need to get it to a state where my configuration.yaml can include something like the below, though maybe I’m wrong and making this harder than it needs to be.

google_assistant:
  project_id: shellfish-09d85
  service_account: !include SERVICE_ACCOUNT.json
  report_state: true
  exposed_domains:
    - shell_command
  entity_config:
    shell_command.ark_script:
      name: ARK_SCRIPT

Since you then have a (command line) sensor, your configuration logic can put whatever you want into it, and then you can have an automation triggered by the sensor value changing, to then call google assistant or whatever else you want

Or you can just call whatever else you want in your logic when you click on the button you already have

1 Like