Push-Location /srv/ha/current/homeassistant/.storage $Count = [ordered]@{ Devices=[PSCustomObject]([ordered]@{ Before = -1 After = -1 Removed = -1 }) Entities=[PSCustomObject]([ordered]@{ Before = -1 After = -1 Removed = -1 }) } $devices = $(Get-Content ./core.device_registry | ConvertFrom-Json -Depth 10) $Count.Devices.Before = $devices.data.devices.count $devices.data.devices = $devices.data.devices | # Where-Object identifiers -notmatch 'zwave' Where-Object {$_.identifiers[0] -eq 'zha'} $entities = $(Get-Content ./core.entity_registry | ConvertFrom-Json -Depth 10) $Count.Entities.Before = $entities.data.entities.count $entities.data.entities = $entities.data.entities | Where-Object platform -match 'zha' # Where-Object platform -notmatch zwave | # Where-Object { -not ( # $_.platform -match 'switch' -and $_.entity_id -match 'light\.' -and -not $_.config_entry_id # ) } $Count.Devices.After = $devices.data.devices.count $Count.Entities.After = $entities.data.entities.count $Count.Devices.Removed = $Count.Devices.Before - $Count.Devices.After $Count.Entities.Removed = $Count.Entities.Before - $Count.Entities.After $Count | Format-Table $devices | ConvertTo-Json -Depth 10 > /tmp/new.core.device_registry $entities | ConvertTo-Json -Depth 10 > /tmp/new.core.entity_registry ha core stop sudo mv ./core.entity_registry ./core.entity_registry.old sudo mv ./core.device_registry ./core.device_registry.old sudo cp /tmp/new.core.entity_registry ./core.entity_registry sudo cp /tmp/new.core.device_registry ./core.device_registry Pop-Location ha core start