Merge branch 'master' of https://code.lksz.me/lksz/PowerShell_Scripts
This commit is contained in:
commit
1b3a16806a
|
@ -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
|
@($HAConfigPath,'/srv/ha/current/homeassistant','/usr/share/hassio/homeassistant') |
|
||||||
), '/srv/ha/current/homeassistant'
|
Where-Object { $_ } |
|
||||||
) | Where-Object { $_ } | Select-Object -First 1 -OutVariable HAConfigPath
|
Where-Object { Test-Path -Type Container $_ } |
|
||||||
|
Select-Object -First 1
|
||||||
|
), $HAConfigPath, '/srv/ha/current/homeassistant'
|
||||||
|
) | Where-Object { $_ } |
|
||||||
|
Select-Object -First 1 -OutVariable HAConfigPath
|
||||||
|
|
|
@ -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)
|
$entities = $(Get-Content ./core.entity_registry | ConvertFrom-Json -Depth 10)
|
||||||
$Count.Entities.BeforeData = $entities.data.entities
|
$Count.Entities.BeforeData = $entities.data.entities
|
||||||
$Count.Entities.Before = $entities.data.entities.count
|
$Count.Entities.Before = $entities.data.entities.count
|
||||||
$entities.data.entities = $entities.data.entities |
|
$entities.data.entities = $entities.data.entities |
|
||||||
Where-Object {
|
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
|
$Count.Entities.AfterData = $entities.data.entities
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ if( $MatchName ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $MatchAny ) {
|
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 ) {
|
if( $OrderBy ) {
|
||||||
|
|
|
@ -15,8 +15,10 @@ if [[ "$SZ_SKIP_DEFAULT_SHELL" != "1" ]]; then
|
||||||
echo 'Starting PowerShell SZcripts...'
|
echo 'Starting PowerShell SZcripts...'
|
||||||
echo "pwsh" >> /tmp/default_shell
|
echo "pwsh" >> /tmp/default_shell
|
||||||
pwsh
|
pwsh
|
||||||
|
if [[ ! -f /tmp/keep_shell_after_pwsh ]]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo "continue" >> /tmp/default_shell
|
echo "continue" >> /tmp/default_shell
|
||||||
export SZ_SKIP_DEFAULT_SHELL=1
|
export SZ_SKIP_DEFAULT_SHELL=1
|
||||||
|
|
|
@ -15,8 +15,10 @@ if [[ "$SZ_SKIP_DEFAULT_SHELL" != "1" ]]; then
|
||||||
echo 'Starting PowerShell SZcripts...'
|
echo 'Starting PowerShell SZcripts...'
|
||||||
echo "pwsh" >> /tmp/default_shell
|
echo "pwsh" >> /tmp/default_shell
|
||||||
pwsh
|
pwsh
|
||||||
|
if [[ ! -f /tmp/keep_shell_after_pwsh ]]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo "continue" >> /tmp/default_shell
|
echo "continue" >> /tmp/default_shell
|
||||||
export SZ_SKIP_DEFAULT_SHELL=1
|
export SZ_SKIP_DEFAULT_SHELL=1
|
||||||
|
|
|
@ -15,8 +15,10 @@ if [[ "$SZ_SKIP_DEFAULT_SHELL" != "1" ]]; then
|
||||||
echo 'Starting PowerShell SZcripts...'
|
echo 'Starting PowerShell SZcripts...'
|
||||||
echo "pwsh" >> /tmp/default_shell
|
echo "pwsh" >> /tmp/default_shell
|
||||||
pwsh
|
pwsh
|
||||||
|
if [[ ! -f /tmp/keep_shell_after_pwsh ]]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo "continue" >> /tmp/default_shell
|
echo "continue" >> /tmp/default_shell
|
||||||
export SZ_SKIP_DEFAULT_SHELL=1
|
export SZ_SKIP_DEFAULT_SHELL=1
|
||||||
|
|
Loading…
Reference in New Issue