[amazonechocontrol] fix dynamic DynamicStateDescriptionProvider (#8896)

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
This commit is contained in:
J-N-K 2020-10-29 22:35:53 +01:00 committed by GitHub
parent a8cfb6c883
commit d1803dc723
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 15 deletions

View File

@ -108,15 +108,15 @@ public class AmazonEchoDynamicStateDescriptionProvider implements DynamicStateDe
if (CHANNEL_TYPE_BLUETHOOTH_MAC.equals(channel.getChannelTypeUID())) { if (CHANNEL_TYPE_BLUETHOOTH_MAC.equals(channel.getChannelTypeUID())) {
EchoHandler handler = (EchoHandler) findHandler(channel); EchoHandler handler = (EchoHandler) findHandler(channel);
if (handler == null) { if (handler == null) {
return originalStateDescription; return null;
} }
BluetoothState bluetoothState = handler.findBluetoothState(); BluetoothState bluetoothState = handler.findBluetoothState();
if (bluetoothState == null) { if (bluetoothState == null) {
return originalStateDescription; return null;
} }
PairedDevice[] pairedDeviceList = bluetoothState.pairedDeviceList; PairedDevice[] pairedDeviceList = bluetoothState.pairedDeviceList;
if (pairedDeviceList == null) { if (pairedDeviceList == null) {
return originalStateDescription; return null;
} }
ArrayList<StateOption> options = new ArrayList<>(); ArrayList<StateOption> options = new ArrayList<>();
@ -136,12 +136,12 @@ public class AmazonEchoDynamicStateDescriptionProvider implements DynamicStateDe
} else if (CHANNEL_TYPE_AMAZON_MUSIC_PLAY_LIST_ID.equals(channel.getChannelTypeUID())) { } else if (CHANNEL_TYPE_AMAZON_MUSIC_PLAY_LIST_ID.equals(channel.getChannelTypeUID())) {
EchoHandler handler = (EchoHandler) findHandler(channel); EchoHandler handler = (EchoHandler) findHandler(channel);
if (handler == null) { if (handler == null) {
return originalStateDescription; return null;
} }
JsonPlaylists playLists = handler.findPlaylists(); JsonPlaylists playLists = handler.findPlaylists();
if (playLists == null) { if (playLists == null) {
return originalStateDescription; return null;
} }
ArrayList<StateOption> options = new ArrayList<>(); ArrayList<StateOption> options = new ArrayList<>();
@ -166,12 +166,12 @@ public class AmazonEchoDynamicStateDescriptionProvider implements DynamicStateDe
} else if (CHANNEL_TYPE_PLAY_ALARM_SOUND.equals(channel.getChannelTypeUID())) { } else if (CHANNEL_TYPE_PLAY_ALARM_SOUND.equals(channel.getChannelTypeUID())) {
EchoHandler handler = (EchoHandler) findHandler(channel); EchoHandler handler = (EchoHandler) findHandler(channel);
if (handler == null) { if (handler == null) {
return originalStateDescription; return null;
} }
JsonNotificationSound[] notificationSounds = handler.findAlarmSounds(); JsonNotificationSound[] notificationSounds = handler.findAlarmSounds();
if (notificationSounds == null) { if (notificationSounds == null) {
return originalStateDescription; return null;
} }
ArrayList<StateOption> options = new ArrayList<>(); ArrayList<StateOption> options = new ArrayList<>();
@ -191,15 +191,15 @@ public class AmazonEchoDynamicStateDescriptionProvider implements DynamicStateDe
} else if (CHANNEL_TYPE_CHANNEL_PLAY_ON_DEVICE.equals(channel.getChannelTypeUID())) { } else if (CHANNEL_TYPE_CHANNEL_PLAY_ON_DEVICE.equals(channel.getChannelTypeUID())) {
FlashBriefingProfileHandler handler = (FlashBriefingProfileHandler) findHandler(channel); FlashBriefingProfileHandler handler = (FlashBriefingProfileHandler) findHandler(channel);
if (handler == null) { if (handler == null) {
return originalStateDescription; return null;
} }
AccountHandler accountHandler = handler.findAccountHandler(); AccountHandler accountHandler = handler.findAccountHandler();
if (accountHandler == null) { if (accountHandler == null) {
return originalStateDescription; return null;
} }
List<Device> devices = accountHandler.getLastKnownDevices(); List<Device> devices = accountHandler.getLastKnownDevices();
if (devices.isEmpty()) { if (devices.isEmpty()) {
return originalStateDescription; return null;
} }
ArrayList<StateOption> options = new ArrayList<>(); ArrayList<StateOption> options = new ArrayList<>();
@ -216,11 +216,11 @@ public class AmazonEchoDynamicStateDescriptionProvider implements DynamicStateDe
} else if (CHANNEL_TYPE_MUSIC_PROVIDER_ID.equals(channel.getChannelTypeUID())) { } else if (CHANNEL_TYPE_MUSIC_PROVIDER_ID.equals(channel.getChannelTypeUID())) {
EchoHandler handler = (EchoHandler) findHandler(channel); EchoHandler handler = (EchoHandler) findHandler(channel);
if (handler == null) { if (handler == null) {
return originalStateDescription; return null;
} }
List<JsonMusicProvider> musicProviders = handler.findMusicProviders(); List<JsonMusicProvider> musicProviders = handler.findMusicProviders();
if (musicProviders == null) { if (musicProviders == null) {
return originalStateDescription; return null;
} }
ArrayList<StateOption> options = new ArrayList<>(); ArrayList<StateOption> options = new ArrayList<>();
@ -241,15 +241,15 @@ public class AmazonEchoDynamicStateDescriptionProvider implements DynamicStateDe
} else if (CHANNEL_TYPE_START_COMMAND.equals(channel.getChannelTypeUID())) { } else if (CHANNEL_TYPE_START_COMMAND.equals(channel.getChannelTypeUID())) {
EchoHandler handler = (EchoHandler) findHandler(channel); EchoHandler handler = (EchoHandler) findHandler(channel);
if (handler == null) { if (handler == null) {
return originalStateDescription; return null;
} }
AccountHandler account = handler.findAccount(); AccountHandler account = handler.findAccount();
if (account == null) { if (account == null) {
return originalStateDescription; return null;
} }
List<FlashBriefingProfileHandler> flashbriefings = account.getFlashBriefingProfileHandlers(); List<FlashBriefingProfileHandler> flashbriefings = account.getFlashBriefingProfileHandlers();
if (flashbriefings.isEmpty()) { if (flashbriefings.isEmpty()) {
return originalStateDescription; return null;
} }
ArrayList<StateOption> options = new ArrayList<>(); ArrayList<StateOption> options = new ArrayList<>();