Thank you so much for this - I’ve been trying to do this for months! All working for me following your instructions.
As per @robha I am using a Proxmox VM. I have a few other VMs running Ubuntu, so I mounted the HA disk inside one of them rather than using a live CD. For anyone else trying this, you will need to manually edit the configuration for the linux VM that you are going to use, and insert the HA disk (e.g. local-lvm:vm-100-disk-1) as a secondary drive. Make sure that you stop the HA VM first, and remove this disk from the second VM before restarting HA!
I have a preference for using a command line binary sensor rather than a switch for monitoring (a bit cleaner):
- platform: command_line
name: NAS Mount
command: "[ -f /media/nasup ] && echo 'Up' || echo 'Down'"
payload_on: "Up"
payload_off: "Down"
This simply checks whether a file on the NAS is accessible and sets the sensor to on and off. Can be used in the automation in the same way as the switch.