forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[hdpowerview] Add support for scene groups (openhab#11534)
* Add support for scene collections. Fixes openhab#11533 Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Add unit test for parsing of scene collections response. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Add default i18n properties file. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix CAT: File does not end with a newline. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Update documentation with scene collections. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix CAT: File does not end with a newline. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix formatting. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Fix CAT: File does not end with a newline. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Split offline tests into separate distinct tests. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Increase test coverage for scene/scene collection parsing. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Internationalization of dynamic scene/scene collection channels. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Rename scene collections to scene groups. Renamed for all user-oriented texts/references to be consistent with now abandoned feature of the PowerView app. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Change custom text keys to not collide with framework. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Avoid multiple thing updates. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Add missing label/description texts for secondary channel. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> * Remove unneeded @nullable annotations. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
- Loading branch information
Showing
12 changed files
with
420 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...rc/main/java/org/openhab/binding/hdpowerview/internal/HDPowerViewTranslationProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Copyright (c) 2010-2021 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.hdpowerview.internal; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.openhab.core.i18n.LocaleProvider; | ||
import org.openhab.core.i18n.TranslationProvider; | ||
import org.osgi.framework.Bundle; | ||
|
||
/** | ||
* {@link HDPowerViewTranslationProvider} provides i18n message lookup | ||
* | ||
* @author Jacob Laursen - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class HDPowerViewTranslationProvider { | ||
|
||
private final Bundle bundle; | ||
private final TranslationProvider i18nProvider; | ||
private final LocaleProvider localeProvider; | ||
|
||
public HDPowerViewTranslationProvider(Bundle bundle, TranslationProvider i18nProvider, | ||
LocaleProvider localeProvider) { | ||
this.bundle = bundle; | ||
this.i18nProvider = i18nProvider; | ||
this.localeProvider = localeProvider; | ||
} | ||
|
||
public String getText(String key, @Nullable Object... arguments) { | ||
String text = i18nProvider.getText(bundle, key, key, localeProvider.getLocale(), arguments); | ||
if (text != null) { | ||
return text; | ||
} | ||
return key; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...rc/main/java/org/openhab/binding/hdpowerview/internal/api/responses/SceneCollections.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright (c) 2010-2021 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.hdpowerview.internal.api.responses; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import java.util.Base64; | ||
import java.util.List; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
|
||
/** | ||
* State of all Scenes in an HD PowerView hub | ||
* | ||
* @author Jacob Laursen - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class SceneCollections { | ||
|
||
public @Nullable List<SceneCollection> sceneCollectionData; | ||
public @Nullable List<Integer> sceneCollectionIds; | ||
|
||
/* | ||
* the following SuppressWarnings annotation is because the Eclipse compiler | ||
* does NOT expect a NonNullByDefault annotation on the inner class, since it is | ||
* implicitly inherited from the outer class, whereas the Maven compiler always | ||
* requires an explicit NonNullByDefault annotation on all classes | ||
*/ | ||
@SuppressWarnings("null") | ||
@NonNullByDefault | ||
public static class SceneCollection { | ||
public int id; | ||
public @Nullable String name; | ||
public int order; | ||
public int colorId; | ||
public int iconId; | ||
|
||
public String getName() { | ||
return new String(Base64.getDecoder().decode(name), StandardCharsets.UTF_8); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.