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.
[deconz] add support for effects on color lights (openhab#9238)
* add support for effects * add tags * remove unnecessary constants * fix state update Signed-off-by: Jan N. Klug <[email protected]>
- Loading branch information
Showing
10 changed files
with
243 additions
and
25 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
77 changes: 77 additions & 0 deletions
77
....deconz/src/main/java/org/openhab/binding/deconz/internal/CommandDescriptionProvider.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,77 @@ | ||
/** | ||
* Copyright (c) 2010-2020 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.deconz.internal; | ||
|
||
import java.util.Locale; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.openhab.core.thing.Channel; | ||
import org.openhab.core.thing.ChannelUID; | ||
import org.openhab.core.thing.ThingUID; | ||
import org.openhab.core.thing.type.DynamicCommandDescriptionProvider; | ||
import org.openhab.core.types.CommandDescription; | ||
import org.osgi.service.component.annotations.Component; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Dynamic channel command description provider. | ||
* Overrides the command description for the controls, which receive its configuration in the runtime. | ||
* | ||
* @author Jan N. Klug - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
@Component(service = { DynamicCommandDescriptionProvider.class, CommandDescriptionProvider.class }) | ||
public class CommandDescriptionProvider implements DynamicCommandDescriptionProvider { | ||
|
||
private final Map<ChannelUID, CommandDescription> descriptions = new ConcurrentHashMap<>(); | ||
private final Logger logger = LoggerFactory.getLogger(CommandDescriptionProvider.class); | ||
|
||
/** | ||
* Set a command description for a channel. This description will be used when preparing the channel command by | ||
* the framework for presentation. A previous description, if existed, will be replaced. | ||
* | ||
* @param channelUID | ||
* channel UID | ||
* @param description | ||
* state description for the channel | ||
*/ | ||
public void setDescription(ChannelUID channelUID, CommandDescription description) { | ||
logger.trace("adding command description for channel {}", channelUID); | ||
descriptions.put(channelUID, description); | ||
} | ||
|
||
/** | ||
* remove all descriptions for a given thing | ||
* | ||
* @param thingUID the thing's UID | ||
*/ | ||
public void removeDescriptionsForThing(ThingUID thingUID) { | ||
logger.trace("removing state description for thing {}", thingUID); | ||
descriptions.entrySet().removeIf(entry -> entry.getKey().getThingUID().equals(thingUID)); | ||
} | ||
|
||
@Override | ||
public @Nullable CommandDescription getCommandDescription(Channel channel, | ||
@Nullable CommandDescription originalStateDescription, @Nullable Locale locale) { | ||
if (descriptions.containsKey(channel.getUID())) { | ||
logger.trace("returning new stateDescription for {}", channel.getUID()); | ||
return descriptions.get(channel.getUID()); | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.