Add support for preserving specific devices

This commit is contained in:
Gal Szkolnik 2021-07-16 09:23:58 -04:00
parent fd9b8a968c
commit 509e15f8ef
1 changed files with 9 additions and 1 deletions

View File

@ -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