Install software on HAOS

I am about to convert one of my boxes into a Home Assistant machine. I am currently using that box to run a PowerShell script periodically, hence I still need this facility. Will I be able to install PowerShell onto the HAOS box?

I dont think so. But i know for sure you can do it with docker.

You mean, (1) install HOS, and then PowerShell in a docker container in HOS?

Or do you mean (2) install some general purpose Linux distro, and then HOS in a Docker container?

Install Proxmox, HA OS in a VM, your Powershell in a lcx

1 Like

Thanks. I have been trying to avoid running HAOS in a container or VM based on performance concerns. Do you think HAOS will take a performance hit if run in a VM as opposed to native Linux? Are there any comparisons out there between the two installation methods? Gotta tell you, the box I will be using is far from beefy.

Don’t know your what metal box is or what kind of processor. But if this box can handle VM at all, even a Core i3 from 8 years ago, I don’t think you would feel any difference.

1 Like

Thanks all for your inputs. I decided to install HAOS in a Docker container, and it works just fine. What I am having trouble now with is that I just bought a Sonoff P dongle, and HA doesn’t detect it. Not sure what I am doing wrong.

No idea how you did that, but how did you pass-through the dongle ? Maybe show your docker-compose config, or your docker run command.

I followed the instructions here.

The big question is now, what computer does the dongle need to be attached to? Does it have to be attached to the computer that actually runs HAOS, or can it be attached to any computer on the home network?

If the former holds, then yes, it looks like I have to “pass-through the dongle,” which I don’t know how to do.

Ok, you did not install HA OS in a docker container, but HA Container in a docker container.

Best solution

Using ser2net, it can be attached to another computer, but not easy.

1 Like

Apologies. Yes, I installed HA in a Docker container. For HAOS I would have needed a VM, of course.

As for passing-through the dongle, that article doesn’t really help I’m afraid: while I did indeed find the path that needs to be mounted, I can’t find a docker-compose.yaml file on my system. My Docker is started by a systemd service that looks like this:

Description=Docker Application Container Engine
Documentation= docker.socket firewalld.service containerd.service containerd.service

# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID

# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.

# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.

# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.

# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.

# set delegate yes so that systemd does not reset the cgroups of docker containers

# kill only the docker process, not all processes in the cgroup


Any thoughts?

No idea, I have never seen a docker container run like that.

Just curious. What does the PowerShell script do? Any reason that it can’t be done from an automation?

I use it to reboot this guy.

Sounds expensive, but what kind of API does the PowerShell script perform to reboot it?

1 Like

See below.

# Usage: pwsh -File rebootM2000.ps1
param (
	[string]$HotspotIp = ""

$ErrorActionPreference = "SilentlyContinue"
$ProgressPreference = "SilentlyContinue"
$hotspotEndpoint = "http://" + $HotspotIp

try {
   # Enter your mifi admin password on the line below
   $password = 'password'

   # Login to Mifi and force reboot
   $err = $null
   try {
	  $webReq = Invoke-WebRequest -Uri ($hotspotEndpoint + "/login") -SessionVariable session -Method get -UseBasicParsing
   catch {
	  $err = $_

   if ($err.Count -eq 0) {
	  $token = ($webReq.InputFields | ? {$ -eq 'gSecureToken'}).value
	  $passwordBytes = [System.Text.Encoding]::ASCII.GetBytes($password + $token)
	  $sha1 = [System.Security.Cryptography.SHA1]::Create()
	  $hash = $sha1.ComputeHash($passwordBytes)

	  # Convert resulting bytes to hex
	  $hashedpasswd = [string]::Join("",[System.BitConverter]::ToString($hash).ToLower().Split('-'))

	  # Build secure token
	  $body = "shaPassword=" + $hashedpasswd + "&gSecureToken=" + $token
	  try {
		 $result = invoke-RestMethod -Uri ($hotspotEndpoint + "/submitLogin/") -Method post -body $body -ContentType "application/x-www-form-urlencoded; charset=UTF-8" -WebSession $session
	  catch {
		 $err = $_
	  if ($err.Count -ne 0)
		 throw $err

	  try {
		 $webReq = Invoke-WebRequest -Uri ($hotspotEndpoint + "/restarting") -WebSession $session -Method get -useBasicParsing
	  catch {
		 $err = $_
	  if ($err.Count -ne 0)
		 throw $err

	  if ($err.Count -eq 0)
		 if ($webReq.Content -match 'data : \{ gSecureToken : "(.+)" \}') {
			$body = "gSecureToken=" + $matches[1]
			$result = invoke-RestMethod -Uri ($hotspotEndpoint + "/restarting/reboot/") -Method post -body $body -ContentType "application/x-www-form-urlencoded; charset=UTF-8" -WebSession $session -ErrorVariable err -ErrorAction SilentlyContinue 
			write-output $result
		 else {
			write-error "Could not parse content from endpoint $hotspotEndpoint/restarting $($webReq.Content)"
		 write-error $err
} catch {
   write-error $result
   $ErrorActionPreference = "Continue"
   throw $_

Looks like there is an Alpine package for Powershell.
So in theory you could install this package inside your HA-Core docker container and run your powershell script directly in HA core. There would be more work to do to fully incorporate it into automations and the like for everyday use, but its a possibility.


I do not have Home Assistant Core, but Home Assistant Container. Anyway, say I re-do my whole installation, and install the full HAOS. Are you, by any chance, hinting that I could run this Alpine package inside HAOS? I would gladly ditch my HA Container installation if that could be achieved!

1 Like

Yes, with “apk add …” you can install packages, but if you update HA, the package is lost, so make sure you add that command in an automation on a restart HA for example… So it gets installed when it’s not there…

Or just convert that PowerShell script to a python script


Here is a link to a gist to have a python script, no need for PowerShell