forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[hue] Implement CLIP 2 / API v2 (openhab#13570)
* [hue] Implement CLIP 2 / API v2 --------- Signed-off-by: Andrew Fiddian-Green <[email protected]> Signed-off-by: Matt Myers <[email protected]>
- Loading branch information
Showing
98 changed files
with
23,869 additions
and
421 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
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
86 changes: 86 additions & 0 deletions
86
...ab.binding.hue/src/main/java/org/openhab/binding/hue/internal/action/DynamicsActions.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,86 @@ | ||
/** | ||
* Copyright (c) 2010-2023 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.hue.internal.action; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.openhab.binding.hue.internal.handler.Clip2ThingHandler; | ||
import org.openhab.core.automation.annotation.ActionInput; | ||
import org.openhab.core.automation.annotation.RuleAction; | ||
import org.openhab.core.library.types.QuantityType; | ||
import org.openhab.core.library.unit.MetricPrefix; | ||
import org.openhab.core.library.unit.Units; | ||
import org.openhab.core.thing.binding.ThingActions; | ||
import org.openhab.core.thing.binding.ThingActionsScope; | ||
import org.openhab.core.thing.binding.ThingHandler; | ||
import org.openhab.core.types.Command; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Implementation of the {@link ThingActions} interface used for sending 'dynamics' commands to Hue API v2 devices, | ||
* rooms or zones. | ||
* | ||
* @author Andrew Fiddian-Green - Initial contribution | ||
*/ | ||
@ThingActionsScope(name = "hue") | ||
@NonNullByDefault | ||
public class DynamicsActions implements ThingActions { | ||
|
||
private final Logger logger = LoggerFactory.getLogger(DynamicsActions.class); | ||
|
||
private @Nullable Clip2ThingHandler handler; | ||
|
||
public static void dynamicCommand(ThingActions actions, @Nullable String channelId, @Nullable Command command, | ||
@Nullable Long durationMs) { | ||
((DynamicsActions) actions).dynamicCommand(channelId, command, durationMs); | ||
} | ||
|
||
@RuleAction(label = "@text/dynamics.action.label", description = "@text/dynamics.action.description") | ||
public void dynamicCommand( | ||
@ActionInput(name = "channelId", label = "@text/dynamics.channel.label", description = "@text/dynamics.channel.description") @Nullable String channelId, | ||
@ActionInput(name = "command", label = "@text/dynamics.command.label", description = "@text/dynamics.command.description") @Nullable Command command, | ||
@ActionInput(name = "durationMs", label = "@text/dynamics.duration.label", description = "@text/dynamics.duration.description") @Nullable Long durationMs) { | ||
// | ||
Clip2ThingHandler handler = this.handler; | ||
if (handler == null) { | ||
logger.warn("ThingHandler is null."); | ||
return; | ||
} | ||
if (channelId == null) { | ||
logger.debug("Channel ID is null."); | ||
return; | ||
} | ||
if (command == null) { | ||
logger.debug("Command is null."); | ||
return; | ||
} | ||
if (durationMs == null || durationMs.longValue() <= 0) { | ||
logger.debug("Duration is null, zero or negative."); | ||
return; | ||
} | ||
handler.handleDynamicsCommand(channelId, command, | ||
new QuantityType<>(durationMs.longValue(), MetricPrefix.MILLI(Units.SECOND))); | ||
logger.debug("Dynamic command '{}' sent to channelId '{}' with duration {}ms.", command, channelId, durationMs); | ||
} | ||
|
||
@Override | ||
public @Nullable ThingHandler getThingHandler() { | ||
return handler; | ||
} | ||
|
||
@Override | ||
public void setThingHandler(@Nullable ThingHandler handler) { | ||
this.handler = (Clip2ThingHandler) handler; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
....binding.hue/src/main/java/org/openhab/binding/hue/internal/config/Clip2BridgeConfig.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,30 @@ | ||
/** | ||
* Copyright (c) 2010-2023 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.hue.internal.config; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
|
||
/** | ||
* Configuration for the Clip2BridgeHandler. | ||
* | ||
* @author Andrew Fiddian-Green - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class Clip2BridgeConfig { | ||
public static final String APPLICATION_KEY = "applicationKey"; | ||
|
||
public String ipAddress = ""; | ||
public String applicationKey = ""; | ||
public int checkMinutes = 60; | ||
public boolean useSelfSignedCertificate = true; | ||
} |
25 changes: 25 additions & 0 deletions
25
...b.binding.hue/src/main/java/org/openhab/binding/hue/internal/config/Clip2ThingConfig.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,25 @@ | ||
/** | ||
* Copyright (c) 2010-2023 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.hue.internal.config; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
|
||
/** | ||
* Configuration for CLIP V2 things. | ||
* | ||
* @author Andrew Fiddian-Green - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class Clip2ThingConfig { | ||
public String resourceId = ""; | ||
} |
Oops, something went wrong.