PowerShell_Scripts/HomeAssistant/Invoke-HomeAssistantCli.ps1

21 lines
525 B
PowerShell

[CmdletBinding(SupportsShouldProcess)]param(
[switch]$NoJsonParsing,
[switch]$Help,
[Parameter(Position = 0, ValueFromRemainingArguments = $true)]
[string[]]$Params
)
$local:baseParams='--raw-json'
if( -not $Params ) { $NoJsonParsing = $true }
if( $NoJsonParsing ) { $baseParams=[string]::Empty }
if( $Help ) {
$NoJsonParsing = $true
$baseParams = '--help'
}
$local:results = & docker exec hassio_cli ha $params $baseParams
if( -not $NoJsonParsing ) {
$results | ConvertFrom-Json
} else {
$results
}