StarWing
(StarWing)
June 21, 2024, 4:17pm
1
I’m completely new to HA, migrating from Domoticz and most of the things I sorted out with the help of the forums an chatGPT
One of the things remaining: I would like to see the status of a esxi vm (online/offline) and start/stop it with a pushbutton.
I followed this guide AUTOMATION - Gracefully Shutdown VM's & ESXi Host via SSH
and I’m able to run a script againts the VM guest from the HA ssh shell, and this works. Now I want to put this all in 1 card. Somehing like:
This is in my configuration.yaml:
## ESX Buttons
shell_command:
turn_on_pluto: ssh -i /config/ssh_keys/id_rsa_homeassistant -o StrictHostKeyChecking=no [email protected] "/vmfs/volumes/DataDisk8TB/scripts/startpluto.sh"
turn_off_pluto: ssh -i /config/ssh_keys/id_rsa_homeassistant -o StrictHostKeyChecking=no [email protected] "/vmfs/volumes/DataDisk8TB/scripts/stoppluto.sh"
turn_on_wks: ssh -i /config/ssh_keys/id_rsa_homeassistant -o StrictHostKeyChecking=no [email protected] "/vmfs/volumes/DataDisk8TB/scripts/startwks.sh"
turn_off_wks: ssh -i /config/ssh_keys/id_rsa_homeassistant -o StrictHostKeyChecking=no [email protected] "/vmfs/volumes/DataDisk8TB/scripts/stopwks.sh"
but then with 3 vm’s.
What is the best approach to do this ?
if you don’t want to have 3 cards, one for each, then you could create a dropdown helper. use that to choose which vm you’re wanting to start/stop. then have the start/stop refer to the dropdown (it’ll be an input_select entity) to know which vm to do.
StarWing
(StarWing)
June 21, 2024, 6:51pm
3
I’m still not getting the overview of the HA config.
I managed to create an online/offline binary switch w/ ICMP instead of ping (which is obsolete)
This goes connected/disconnected as with the state of the VM.
configuration.yaml
## ESX Buttons
shell_command:
turn_on_pluto: ssh -i /config/ssh_keys/id_rsa_homeassistant -o StrictHostKeyChecking=no [email protected] "/vmfs/volumes/DataDisk8TB/scripts/startpluto.sh"
turn_off_pluto: ssh -i /config/ssh_keys/id_rsa_homeassistant -o StrictHostKeyChecking=no [email protected] "/vmfs/volumes/DataDisk8TB/scripts/stoppluto.sh"
switch:
- platform: template
switches:
pluto:
unique_id: pluto
friendly_name: Pluto
value_template: "{{ is_state('binary_sensor.pluto', 'connected') }}"
turn_on:
- service: shell_command.turn_on_pluto
entity_id: switch.pluto
turn_off:
- service: shell_command.turn_off_pluto
entity_id: switch.pluto
Button card:
show_name: true
show_icon: true
type: button
entity: switch.pluto
name: Pluto
show_state: true
The binary sensor works as expected and the switch goes with the state of the VM.
When I add a switch in the dashboard and toggle it, nothing happens.
Running the command from the SSH plugin works as expected.
What am I dooing wrong ?
CO_4X4
(Colorado Four Wheeler)
June 21, 2024, 9:29pm
4
Instead of using ‘connected’ have you tried using ‘on’? While the state in your UI will say connected or disconnected, the state is on or off.
StarWing
(StarWing)
June 22, 2024, 2:32am
5
Yes, this solves the on/off, but still searching why the ssh command is not running.
StarWing
(StarWing)
June 22, 2024, 6:46am
6
Found it
I solved it by using both SSH and the advanced plugin.
With the regular SSH plugin I couldn’t disable protection mode.
With the advanced SSH, I was not able to connect anymore to my esxi host.
1/
Create an ICMP binary sensor for the hosts you want. (here binary.sensor.pluto)
This will check the state of the switch.
2/
shell_command:
turn_on_pluto: '/usr/bin/ssh -i /config/ssh_keys/id_rsa_homeassistant -o StrictHostKeyChecking=no [email protected] "/vmfs/volumes/DataDisk8TB/scripts/startpluto.sh"'
turn_off_pluto: '/usr/bin/ssh -i /config/ssh_keys/id_rsa_homeassistant -o StrictHostKeyChecking=no [email protected] "/vmfs/volumes/DataDisk8TB/scripts/stoppluto.sh"'
switch:
- platform: template
switches:
pluto:
unique_id: pluto
friendly_name: Pluto
value_template: "{{ is_state('binary_sensor.pluto', 'on') }}"
turn_on:
- service: shell_command.turn_on_pluto
entity_id: switch.pluto
turn_off:
- service: shell_command.turn_off_pluto
entity_id: switch.pluto
3/
Use this as reference for creating keys with esxi:
4/
Install Advanced SSH & Web Terminal and disable protection mode, and run
`docker exec -it homeassistant /bin/bash`
5/
disable/remove Advanced SSH
Now my shell commands are running