Add support for preserving specific devices
This commit is contained in:
parent
fd9b8a968c
commit
509e15f8ef
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue