Search in sources :

Example 11 with ParameterOption

use of org.eclipse.smarthome.config.core.ParameterOption in project smarthome by eclipse.

the class ConfigDescriptionParameterConverter method readParameterOptions.

private List<ParameterOption> readParameterOptions(Object rawNodeValueList) {
    if (rawNodeValueList instanceof List<?>) {
        List<?> list = (List<?>) rawNodeValueList;
        List<ParameterOption> result = new ArrayList<>();
        for (Object object : list) {
            if (object instanceof NodeValue) {
                NodeValue nodeValue = (NodeValue) object;
                String value = nodeValue.getAttributes().get("value");
                String label = nodeValue.getValue().toString();
                result.add(new ParameterOption(value, label));
            }
        }
        return result;
    }
    return null;
}
Also used : NodeValue(org.eclipse.smarthome.config.xml.util.NodeValue) ParameterOption(org.eclipse.smarthome.config.core.ParameterOption) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 12 with ParameterOption

use of org.eclipse.smarthome.config.core.ParameterOption in project smarthome by eclipse.

the class VoiceManagerImpl method getParameterOptions.

@Override
public Collection<ParameterOption> getParameterOptions(URI uri, String param, Locale locale) {
    if (uri.toString().equals(CONFIG_URI)) {
        if (CONFIG_DEFAULT_HLI.equals(param)) {
            List<ParameterOption> options = new ArrayList<>();
            for (HumanLanguageInterpreter hli : humanLanguageInterpreters.values()) {
                ParameterOption option = new ParameterOption(hli.getId(), hli.getLabel(locale));
                options.add(option);
            }
            return options;
        } else if (CONFIG_DEFAULT_KS.equals(param)) {
            List<ParameterOption> options = new ArrayList<>();
            for (KSService ks : ksServices.values()) {
                ParameterOption option = new ParameterOption(ks.getId(), ks.getLabel(locale));
                options.add(option);
            }
            return options;
        } else if (CONFIG_DEFAULT_STT.equals(param)) {
            List<ParameterOption> options = new ArrayList<>();
            for (STTService stt : sttServices.values()) {
                ParameterOption option = new ParameterOption(stt.getId(), stt.getLabel(locale));
                options.add(option);
            }
            return options;
        } else if (CONFIG_DEFAULT_TTS.equals(param)) {
            List<ParameterOption> options = new ArrayList<>();
            for (TTSService tts : ttsServices.values()) {
                ParameterOption option = new ParameterOption(tts.getId(), tts.getLabel(locale));
                options.add(option);
            }
            return options;
        } else if (CONFIG_DEFAULT_VOICE.equals(param)) {
            List<ParameterOption> options = new ArrayList<>();
            for (Voice voice : getAllVoices()) {
                ParameterOption option = new ParameterOption(voice.getUID(), voice.getLabel() + " - " + voice.getLocale().getDisplayName());
                options.add(option);
            }
            return options;
        }
    }
    return null;
}
Also used : STTService(org.eclipse.smarthome.core.voice.STTService) ParameterOption(org.eclipse.smarthome.config.core.ParameterOption) KSService(org.eclipse.smarthome.core.voice.KSService) ArrayList(java.util.ArrayList) HumanLanguageInterpreter(org.eclipse.smarthome.core.voice.text.HumanLanguageInterpreter) TTSService(org.eclipse.smarthome.core.voice.TTSService) ArrayList(java.util.ArrayList) List(java.util.List) Voice(org.eclipse.smarthome.core.voice.Voice)

Example 13 with ParameterOption

use of org.eclipse.smarthome.config.core.ParameterOption in project smarthome by eclipse.

the class VoiceManagerTest method getParameterOptionsForTheDefaultKs.

@Test
public void getParameterOptionsForTheDefaultKs() throws URISyntaxException {
    ksService = new KSServiceStub();
    registerService(ksService);
    boolean isKSStubInTheOptions = false;
    Collection<ParameterOption> options = voiceManager.getParameterOptions(new URI("system:voice"), "defaultKS", null);
    assertNotNull(options);
    for (ParameterOption option : options) {
        String optionValue = option.getValue();
        String optionLabel = option.getLabel();
        String ksStubId = ksService.getId();
        String ksLabel = ksService.getLabel(null);
        if (optionValue.equals(ksStubId) && optionLabel.equals(ksLabel)) {
            isKSStubInTheOptions = true;
        }
    }
    assertTrue(isKSStubInTheOptions);
}
Also used : ParameterOption(org.eclipse.smarthome.config.core.ParameterOption) URI(java.net.URI) KSServiceStub(org.eclipse.smarthome.core.voice.internal.KSServiceStub) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Example 14 with ParameterOption

use of org.eclipse.smarthome.config.core.ParameterOption in project smarthome by eclipse.

the class VoiceManagerTest method getParameterOptionsForTheDefaultTts.

@Test
public void getParameterOptionsForTheDefaultTts() throws URISyntaxException {
    ttsService = new TTSServiceStub();
    registerService(ttsService);
    boolean isTTSStubInTheOptions = false;
    Collection<ParameterOption> options = voiceManager.getParameterOptions(new URI("system:voice"), "defaultTTS", null);
    assertNotNull(options);
    for (ParameterOption option : options) {
        String optionValue = option.getValue();
        String optionLabel = option.getLabel();
        String ttsStubId = ttsService.getId();
        String ttsLabel = ttsService.getLabel(null);
        if (optionValue.equals(ttsStubId) && optionLabel.equals(ttsLabel)) {
            isTTSStubInTheOptions = true;
        }
    }
    assertTrue(isTTSStubInTheOptions);
}
Also used : TTSServiceStub(org.eclipse.smarthome.core.voice.internal.TTSServiceStub) ParameterOption(org.eclipse.smarthome.config.core.ParameterOption) URI(java.net.URI) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Example 15 with ParameterOption

use of org.eclipse.smarthome.config.core.ParameterOption in project smarthome by eclipse.

the class VoiceManagerTest method getParameterOptionsForTheDefaultSTT.

@Test
public void getParameterOptionsForTheDefaultSTT() throws URISyntaxException {
    sttService = new STTServiceStub();
    registerService(sttService);
    boolean isSTTStubInTheOptions = false;
    Collection<ParameterOption> options = voiceManager.getParameterOptions(new URI("system:voice"), "defaultSTT", null);
    assertNotNull(options);
    for (ParameterOption option : options) {
        String optionValue = option.getValue();
        String optionLabel = option.getLabel();
        String sttStubId = sttService.getId();
        String sttLabel = sttService.getLabel(null);
        if (optionValue.equals(sttStubId) && optionLabel.equals(sttLabel)) {
            isSTTStubInTheOptions = true;
        }
    }
    assertTrue(isSTTStubInTheOptions);
}
Also used : ParameterOption(org.eclipse.smarthome.config.core.ParameterOption) STTServiceStub(org.eclipse.smarthome.core.voice.internal.STTServiceStub) URI(java.net.URI) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Aggregations

ParameterOption (org.eclipse.smarthome.config.core.ParameterOption)16 ArrayList (java.util.ArrayList)9 URI (java.net.URI)8 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)5 Test (org.junit.Test)5 List (java.util.List)4 ConfigDescriptionParameter (org.eclipse.smarthome.config.core.ConfigDescriptionParameter)4 BigDecimal (java.math.BigDecimal)2 FilterCriteria (org.eclipse.smarthome.config.core.FilterCriteria)2 AudioSink (org.eclipse.smarthome.core.audio.AudioSink)2 TTSServiceStub (org.eclipse.smarthome.core.voice.internal.TTSServiceStub)2 File (java.io.File)1 URISyntaxException (java.net.URISyntaxException)1 ZoneId (java.time.ZoneId)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Comparator (java.util.Comparator)1 Locale (java.util.Locale)1 TimeZone (java.util.TimeZone)1 TimeUnit (java.util.concurrent.TimeUnit)1