@@ -39,6 +39,7 @@ import {
3939 computeDeviceName ,
4040 subscribeDeviceRegistry ,
4141} from "../../../../../data/device_registry" ;
42+ import { isComponentLoaded } from "../../../../../common/config/is_component_loaded" ;
4243
4344@customElement ( "zwave-migration" )
4445export class ZwaveMigration extends LitElement {
@@ -94,8 +95,8 @@ export class ZwaveMigration extends LitElement {
9495 "ui.panel.config.zwave.migration.ozw.introduction"
9596 ) }
9697 </ div>
97- ${ ! this . hass . config . components . includes ( "hassio" ) &&
98- ! this . hass . config . components . includes ( "mqtt" )
98+ ${ ! isComponentLoaded ( this . hass , "hassio" ) &&
99+ ! isComponentLoaded ( this . hass , "mqtt" )
99100 ? html `
100101 <ha- card class= "content" header = "MQTT Required">
101102 <div class= "card-content" >
@@ -182,7 +183,7 @@ export class ZwaveMigration extends LitElement {
182183 <p>
183184 Now it 's time to set up the OZW integration.
184185 </p>
185- ${ this . hass . config . components . includes ( "hassio" )
186+ ${ isComponentLoaded ( this . hass , "hassio" )
186187 ? html `
187188 <p>
188189 The OZWDaemon runs in a Home Assistant addon
@@ -378,15 +379,15 @@ export class ZwaveMigration extends LitElement {
378379
379380 private async _setupOzw ( ) {
380381 const ozwConfigFlow = await startOzwConfigFlow ( this . hass ) ;
381- if ( this . hass . config . components . includes ( "ozw" ) ) {
382+ if ( isComponentLoaded ( this . hass , "ozw" ) ) {
382383 this . _getMigrationData ( ) ;
383384 this . _step = 3 ;
384385 return ;
385386 }
386387 showConfigFlowDialog ( this , {
387388 continueFlowId : ozwConfigFlow . flow_id ,
388389 dialogClosedCallback : ( ) => {
389- if ( this . hass . config . components . includes ( "ozw" ) ) {
390+ if ( isComponentLoaded ( this . hass , "ozw" ) ) {
390391 this . _getMigrationData ( ) ;
391392 this . _step = 3 ;
392393 }
@@ -397,7 +398,18 @@ export class ZwaveMigration extends LitElement {
397398 }
398399
399400 private async _getMigrationData ( ) {
400- this . _migrationData = await migrateZwave ( this . hass , true ) ;
401+ try {
402+ this . _migrationData = await migrateZwave ( this . hass , true ) ;
403+ } catch ( err ) {
404+ showAlertDialog ( this , {
405+ title : "Failed to get migration data!" ,
406+ text :
407+ err . code === "unknown_command"
408+ ? "Restart Home Assistant and try again."
409+ : err . message ,
410+ } ) ;
411+ return ;
412+ }
401413 this . _migratedZwaveEntities = Object . keys (
402414 this . _migrationData . migration_entity_map
403415 ) ;
0 commit comments