From fd9b8a968c18ac32adc1010718f1825ebeaf3c80 Mon Sep 17 00:00:00 2001 From: Gal Szkolnik Date: Fri, 16 Jul 2021 09:04:24 -0400 Subject: [PATCH 1/3] Fix dps and Get-HAPath DPS -MatchAny should work better now Get-HAPath refined --- HomeAssistant/Get-HAPath.ps1 | 11 +++++++---- docker/Get-DockerProcess.ps1 | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/HomeAssistant/Get-HAPath.ps1 b/HomeAssistant/Get-HAPath.ps1 index a1f9c93..aa0b590 100644 --- a/HomeAssistant/Get-HAPath.ps1 +++ b/HomeAssistant/Get-HAPath.ps1 @@ -1,6 +1,9 @@ -if( $HAConfigPath ) { return $HAConfigPath } @( $( - @($HAConfigPath,'/srv/ha/current/homeassistant','/usr/share/hassio/homeassistant') | Where-Object { Test-Path -Type Container $_ } | Select-Object -First 1 - ), '/srv/ha/current/homeassistant' -) | Where-Object { $_ } | Select-Object -First 1 -OutVariable HAConfigPath + @($HAConfigPath,'/srv/ha/current/homeassistant','/usr/share/hassio/homeassistant') | + Where-Object { $_ } | + Where-Object { Test-Path -Type Container $_ } | + Select-Object -First 1 + ), $HAConfigPath, '/srv/ha/current/homeassistant' +) | Where-Object { $_ } | + Select-Object -First 1 -OutVariable HAConfigPath diff --git a/docker/Get-DockerProcess.ps1 b/docker/Get-DockerProcess.ps1 index ff280cf..8653a47 100644 --- a/docker/Get-DockerProcess.ps1 +++ b/docker/Get-DockerProcess.ps1 @@ -32,7 +32,7 @@ if( $MatchName ) { } if( $MatchAny ) { - $result = $result | Where-Object { $_ | Out-String | Where-Object { $_ -match $($MatchAny -join '|') } } + $result = $result | Where-Object { $_ | Format-Table -Wrap -HideTableHeaders | Out-String | Where-Object { $_ -match $($MatchAny -join '|') } } } if( $OrderBy ) { From 509e15f8ef0ac4caa0177808b6bd63f28e5c45af Mon Sep 17 00:00:00 2001 From: Gal Szkolnik Date: Fri, 16 Jul 2021 09:23:58 -0400 Subject: [PATCH 2/3] Add support for preserving specific devices --- HomeAssistant/Refresh-HADeviceRegistry.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/HomeAssistant/Refresh-HADeviceRegistry.ps1 b/HomeAssistant/Refresh-HADeviceRegistry.ps1 index 90340ee..181eea9 100644 --- a/HomeAssistant/Refresh-HADeviceRegistry.ps1 +++ b/HomeAssistant/Refresh-HADeviceRegistry.ps1 @@ -18,12 +18,20 @@ $Count = [ordered]@{ }) } +# make sure the variable exist +if( -not (Test-Path variable:HAPreserveEntities) ) { + $HAPreserveEntities = [ordered]@{ + Platforms = @( 'zha' ) + Names = @() + } +} + $entities = $(Get-Content ./core.entity_registry | ConvertFrom-Json -Depth 10) $Count.Entities.BeforeData = $entities.data.entities $Count.Entities.Before = $entities.data.entities.count $entities.data.entities = $entities.data.entities | Where-Object { - ( $_.platform -match 'zha' ) -or ($_.Original_name -in $HAPreserveEntities) + ( $_.platform -match $HAPreserveEntities.Platforms ) -or ($_.Original_name -in $HAPreserveEntities.Names) } $Count.Entities.AfterData = $entities.data.entities From 624ca2cc8cf061126fb257b78eb3d201725d99c5 Mon Sep 17 00:00:00 2001 From: Gal Szkolnik Date: Fri, 16 Jul 2021 08:30:11 -0500 Subject: [PATCH 3/3] =added option to stay around after pwsh --- shell-loading-snippets/bash | 4 +++- shell-loading-snippets/sh | 4 +++- shell-loading-snippets/zsh | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/shell-loading-snippets/bash b/shell-loading-snippets/bash index 08e60aa..675e6e7 100755 --- a/shell-loading-snippets/bash +++ b/shell-loading-snippets/bash @@ -15,7 +15,9 @@ if [[ "$SZ_SKIP_DEFAULT_SHELL" != "1" ]]; then echo 'Starting PowerShell SZcripts...' echo "pwsh" >> /tmp/default_shell pwsh - exit + if [[ ! -f /tmp/keep_shell_after_pwsh ]]; then + exit + fi fi fi echo "continue" >> /tmp/default_shell diff --git a/shell-loading-snippets/sh b/shell-loading-snippets/sh index 08e60aa..675e6e7 100755 --- a/shell-loading-snippets/sh +++ b/shell-loading-snippets/sh @@ -15,7 +15,9 @@ if [[ "$SZ_SKIP_DEFAULT_SHELL" != "1" ]]; then echo 'Starting PowerShell SZcripts...' echo "pwsh" >> /tmp/default_shell pwsh - exit + if [[ ! -f /tmp/keep_shell_after_pwsh ]]; then + exit + fi fi fi echo "continue" >> /tmp/default_shell diff --git a/shell-loading-snippets/zsh b/shell-loading-snippets/zsh index 73c3840..52a6661 100755 --- a/shell-loading-snippets/zsh +++ b/shell-loading-snippets/zsh @@ -15,7 +15,9 @@ if [[ "$SZ_SKIP_DEFAULT_SHELL" != "1" ]]; then echo 'Starting PowerShell SZcripts...' echo "pwsh" >> /tmp/default_shell pwsh - exit + if [[ ! -f /tmp/keep_shell_after_pwsh ]]; then + exit + fi fi fi echo "continue" >> /tmp/default_shell