Skip to content

Commit 08c5bff

Browse files
authored
Update publish_script.md (#278)
1 parent 3f1f408 commit 08c5bff

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

docs/user/tutorials/publish_script.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,40 @@ Write an PowerShell script that deploys your apps to Home Assistant with the fol
2121

2222
After installing Samba share, please make sure that you can access your Home Assistant share from your machine:
2323
1. Press Windows + R to open the Run dialog
24-
2. In the Open Textbox write \\homeassistant.local\ (adapt if you use a different host name)
24+
2. In the Open Textbox write \\homeassistant.local\ (adapt if you use a different host name or use the ip adress)
2525
3. You will be prompted to enter User name and Password. Provide your User and Password from your Samba share configuration. Don't forget to tick "Remember my credentials".
2626

2727
The Home Assistant PowerShell Module uses the IP address of Home Assistant to start/stop the addons. It's a anyway a good idea to give a fix IP address to your Home Assistant system.
2828

2929
## The Script
3030

31-
- Create a Powershell file like publish.ps1.
31+
- Create a Powershell file like publish.ps1 in the same folder as your appsettings.json is located.
3232
- Create a subfolder "Home-Assistant" and copy the two files from the PowerShell Module into it.
3333

3434
```powershell
35-
$slug = 'c6a2317c_netdaemon5' # the slug can be found in the url of the browser when navigating to the NetDaemon addon
35+
$settings = (Get-Content appsettings.json | ConvertFrom-Json)
36+
37+
#CHANGE ME
38+
$slug = 'c6a2317c_netdaemon5' # the slug can be found in the url of the browser when navigating to the NetDaemon addon
39+
40+
$version = $slug.Split('_')[-1] # adapt if you are not using the default foldername for the addon
3641
$json = '{"addon": "' + $slug + '"}'
37-
$ip = "192.168.0.44" # adapt to your IP address
38-
$port = 8123 # change if your use another port
42+
$ip = $settings.HomeAssistant.Host
43+
$port = $settings.HomeAssistant.Port
3944
40-
$token = "Long-Lived Access Token" # generate one here http://homeassistant.local:8123/profile
45+
$token = $settings.HomeAssistant.Token
4146
4247
# Point to the HA PowerSHell Module
4348
Unblock-File .\Home-Assistant\Home-Assistant.psd1
4449
Unblock-File .\Home-Assistant\Home-Assistant.psm1
4550
Import-Module .\Home-Assistant
46-
51+
4752
New-HomeAssistantSession -ip $ip -port $port -token $token
4853
49-
Invoke-HomeAssistantService -service HASSIO.ADDON_STOP -json $json
54+
Invoke-HomeAssistantService -service hassio.addon_stop -json $json
5055
51-
Remove-Item -Recurse -Force \\homeassistant.local\config\netdaemon3\*
52-
dotnet publish -c Release HomeAssistant.csproj -o \\homeassistant.local\config\netdaemon3
56+
Remove-Item -Recurse -Force \\$ip\config\$version\*
57+
dotnet publish -c Release HomeAssistant.csproj -o \\$ip\config\$version
5358
54-
Invoke-HomeAssistantService -service HASSIO.ADDON_START -json $json
59+
Invoke-HomeAssistantService -service hassio.addon_start -json $json
5560
```

0 commit comments

Comments
 (0)