Import smart-home into Gitea
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
# Quick-connect helper for the smart-home / Home Assistant project.
|
||||
# Pulls the long-lived token from Vaultwarden (org "Homelab - Claude"),
|
||||
# exports it as HA_TOKEN, and runs a connection test.
|
||||
#
|
||||
# Usage: pwsh -File scripts\connect.ps1 [command]
|
||||
# (defaults to "ping")
|
||||
|
||||
param([string]$Command = "ping")
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$projRoot = Split-Path -Parent $PSScriptRoot
|
||||
|
||||
# Retrieve token from Bitwarden/Vaultwarden CLI (item name: "Home Assistant - RogueOne")
|
||||
# Falls back to an already-set $env:HA_TOKEN if bw is unavailable.
|
||||
if (-not $env:HA_TOKEN) {
|
||||
try {
|
||||
$env:HA_TOKEN = (bw get password "Home Assistant - RogueOne").Trim()
|
||||
} catch {
|
||||
Write-Warning "Could not read token from Bitwarden. Set `$env:HA_TOKEN manually."
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $env:HA_TOKEN) { throw "HA_TOKEN not set." }
|
||||
|
||||
Push-Location $projRoot
|
||||
try {
|
||||
bun ha.js $Command
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
Reference in New Issue
Block a user