-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[deconz] enable thing updates for deconz (#83)
* enable thing updates for deconz Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
- Loading branch information
Showing
16 changed files
with
143 additions
and
7 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
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
2 changes: 2 additions & 0 deletions
2
bundles/org.smarthomej.binding.deconz/src/main/resources/update/batterysensor.update
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,2 @@ | ||
# the battery_level channel changed from a custom type to the system-type | ||
1;UPDATE_CHANNEL;battery_level,Number,system:battery-level |
2 changes: 2 additions & 0 deletions
2
bundles/org.smarthomej.binding.deconz/src/main/resources/update/colorcontrol.update
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,2 @@ | ||
# the color channel changed from a custom type to the system-type | ||
1;UPDATE_CHANNEL;color,Color,system:color |
2 changes: 2 additions & 0 deletions
2
bundles/org.smarthomej.binding.deconz/src/main/resources/update/colorlight.update
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,2 @@ | ||
# the color channel changed from a custom type to the system-type | ||
1;UPDATE_CHANNEL;color,Color,system:color |
2 changes: 2 additions & 0 deletions
2
bundles/org.smarthomej.binding.deconz/src/main/resources/update/colortemperaturelight.update
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,2 @@ | ||
# the brightness channel changed from a custom type to the system-type | ||
1;UPDATE_CHANNEL;brightness,Dimmer,system:brightness |
2 changes: 2 additions & 0 deletions
2
bundles/org.smarthomej.binding.deconz/src/main/resources/update/dimmablelight.update
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,2 @@ | ||
# the brightness channel changed from a custom type to the system-type | ||
1;UPDATE_CHANNEL;brightness,Dimmer,system:brightness |
2 changes: 2 additions & 0 deletions
2
bundles/org.smarthomej.binding.deconz/src/main/resources/update/extendedcolorlight.update
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,2 @@ | ||
# the color channel changed from a custom type to the system-type | ||
1;UPDATE_CHANNEL;color,Color,system:color |
2 changes: 2 additions & 0 deletions
2
bundles/org.smarthomej.binding.deconz/src/main/resources/update/lightgroup.update
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,2 @@ | ||
# the color channel changed from a custom type to the system-type | ||
1;UPDATE_CHANNEL;color,Color,system:color |
2 changes: 2 additions & 0 deletions
2
bundles/org.smarthomej.binding.deconz/src/main/resources/update/onofflight.update
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,2 @@ | ||
# the switch channel changed from a custom type to the system-type | ||
1;UPDATE_CHANNEL;switch,Switch,system:power |
3 changes: 3 additions & 0 deletions
3
bundles/org.smarthomej.binding.deconz/src/main/resources/update/presencesensor.update
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,3 @@ | ||
# the presence channel and enabled channel changed from a custom type to the system-type | ||
1;UPDATE_CHANNEL;presence,Switch,system:motion | ||
1;UPDATE_CHANNEL;enabled,Switch,system:power |
69 changes: 69 additions & 0 deletions
69
...smarthomej.binding.deconz/src/test/java/org/smarthomej/binding/deconz/UpdateFileTest.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,69 @@ | ||
/** | ||
* Copyright (c) 2021 Contributors to the SmartHome/J 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.smarthomej.binding.deconz; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.util.Arrays; | ||
import java.util.regex.Pattern; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.junit.jupiter.api.Test; | ||
import org.smarthomej.binding.deconz.internal.DeconzHandlerFactory; | ||
|
||
/** | ||
* This class provides tests for automatic thing updates. | ||
* It should be moved to SAT sometime instead of implementing it in every binding | ||
* | ||
* @author Jan N. Klug - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class UpdateFileTest { | ||
private static final Pattern VALID_LINES = Pattern | ||
.compile("^(\\d+;(ADD_CHANNEL|UPDATE_CHANNEL|REMOVE_CHANNEL);.*|#.*)$"); | ||
|
||
@Test | ||
public void doCheck() { | ||
checkUpdateFiles(DeconzHandlerFactory.class); | ||
} | ||
|
||
private void checkUpdateFiles(Class clazz) { | ||
// list all files | ||
String path = clazz.getProtectionDomain().getCodeSource().getLocation().getFile() + "update"; | ||
File[] allUpdateFiles = new File(path).listFiles(pathname -> { | ||
if (pathname == null) { | ||
return false; | ||
} | ||
return pathname.getName().endsWith(".update"); | ||
}); | ||
if (allUpdateFiles == null) { | ||
// no updates | ||
return; | ||
} | ||
|
||
// check each file | ||
Arrays.stream(allUpdateFiles).forEach(file -> { | ||
try { | ||
// check each line if it matches the pattern | ||
Files.lines(file.toPath()).forEach(line -> assertEquals(true, VALID_LINES.matcher(line).matches(), | ||
"Checking " + file.getName() + " failed: " + line)); | ||
} catch (IOException e) { | ||
fail("Failed to read" + file.getName()); | ||
} | ||
}); | ||
} | ||
} |