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.
Add support for setting repeater LED color and brightness.
Fixes openhab#12307 Signed-off-by: Jacob Laursen <[email protected]>
- Loading branch information
Showing
9 changed files
with
180 additions
and
4 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
57 changes: 57 additions & 0 deletions
57
...binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/api/Color.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,57 @@ | ||
/** | ||
* Copyright (c) 2010-2022 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; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.openhab.core.library.types.HSBType; | ||
|
||
/** | ||
* Color and brightness information for HD PowerView repeater | ||
* | ||
* @author Jacob Laursen - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class Color { | ||
public int brightness; | ||
public int red; | ||
public int green; | ||
public int blue; | ||
|
||
public Color(int brightness, HSBType hsbType) { | ||
this.brightness = brightness; | ||
int rgb = hsbType.getRGB(); | ||
java.awt.Color color = new java.awt.Color(rgb); | ||
this.red = color.getRed(); | ||
this.green = color.getGreen(); | ||
this.blue = color.getBlue(); | ||
} | ||
|
||
public Color(int brightness, java.awt.Color color) { | ||
this.brightness = brightness; | ||
this.red = color.getRed(); | ||
this.green = color.getGreen(); | ||
this.blue = color.getBlue(); | ||
} | ||
|
||
public Color(int brightness, int red, int green, int blue) { | ||
this.brightness = brightness; | ||
this.red = red; | ||
this.green = green; | ||
this.blue = blue; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%d.%d.%d/%d%%", red, green, blue, brightness); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...ew/src/main/java/org/openhab/binding/hdpowerview/internal/api/requests/RepeaterColor.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,40 @@ | ||
/** | ||
* Copyright (c) 2010-2022 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.requests; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.openhab.binding.hdpowerview.internal.api.Color; | ||
|
||
/** | ||
* Color state of a single Repeater for being updated by an HD PowerView Hub | ||
* | ||
* @author Jacob Laursen - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class RepeaterColor { | ||
public Repeater repeater; | ||
|
||
public class Repeater { | ||
public int id; | ||
public Color color; | ||
|
||
public Repeater(int id, Color color) { | ||
this.id = id; | ||
this.color = color; | ||
} | ||
} | ||
|
||
public RepeaterColor(int id, Color color) { | ||
repeater = new Repeater(id, color); | ||
} | ||
} |
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