I eventually figured this out, I can now control (turn on, turn off, reboot, etc) my KVM VM’s with Alexa.
Here’s how I did it (this is also using the excellent Nabu Casa).
- SSH in to HASSIO
- $ docker ps -a
(this is to find the correct docker ID, the line for me was homeassistant/qemux86-64-
homeassistant:0.103.5, whihc gave me the ID of 58da6a62a2de) - $ docker exec -it 7de1331b3d67 /bin/bash
(this will give you shell access to the docker instance) - $ mkdir /config/ssh
- $ ssh-keygen -t rsa -f /config/ssh/id_rsa
- $ ssh-copy-id -i /config/ssh/id_rsa [email protected]
(replace the user and IP of the KVM host, this will copy the key to the KVM host) - I then created some .sh script files in /config/scripts22/vm_turn_on.sh, etc
- Contents os turn_vm_on.sh:
#!/bin/bash
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /config/ssh/id_rsa [email protected] -tt 'bash -l -c "virsh start gaminigVM"'
- In shell_commands.yaml:
vm_turn_on: '/config/scripts22/vm_turn_on.sh' - Then in scripts.yaml:
vm_turn_on:
sequence:
service: shell_command.vm_turn_on
- Then on Alexa, say “discover new devices”, and it should discover ‘vm_turn_on’.
Hope this helps 