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.
Merge pull request #4 from openhab/2.5.x
update fork
- Loading branch information
Showing
333 changed files
with
17,650 additions
and
4,133 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
25 changes: 25 additions & 0 deletions
25
...rmdecoder/src/main/java/org/openhab/binding/alarmdecoder/internal/config/VZoneConfig.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-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.alarmdecoder.internal.config; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
|
||
/** | ||
* The {@link VZoneConfig} class contains fields mapping thing configuration parameters for VZoneHandler. | ||
* | ||
* @author Bob Adair - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class VZoneConfig { | ||
public int address = -1; | ||
} |
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
115 changes: 115 additions & 0 deletions
115
...decoder/src/main/java/org/openhab/binding/alarmdecoder/internal/handler/VZoneHandler.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,115 @@ | ||
/** | ||
* 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.alarmdecoder.internal.handler; | ||
|
||
import static org.openhab.binding.alarmdecoder.internal.AlarmDecoderBindingConstants.*; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.smarthome.core.library.types.OnOffType; | ||
import org.eclipse.smarthome.core.library.types.StringType; | ||
import org.eclipse.smarthome.core.thing.ChannelUID; | ||
import org.eclipse.smarthome.core.thing.Thing; | ||
import org.eclipse.smarthome.core.thing.ThingStatus; | ||
import org.eclipse.smarthome.core.thing.ThingStatusDetail; | ||
import org.eclipse.smarthome.core.types.Command; | ||
import org.eclipse.smarthome.core.types.UnDefType; | ||
import org.openhab.binding.alarmdecoder.internal.config.VZoneConfig; | ||
import org.openhab.binding.alarmdecoder.internal.protocol.ADCommand; | ||
import org.openhab.binding.alarmdecoder.internal.protocol.ADMessage; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* The {@link VZoneHandler} is responsible for sending state commands to virtual zones. | ||
* | ||
* @author Bob Adair - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class VZoneHandler extends ADThingHandler { | ||
|
||
public static final String CMD_OPEN = "OPEN"; | ||
public static final String CMD_CLOSED = "CLOSED"; | ||
|
||
private final Logger logger = LoggerFactory.getLogger(VZoneHandler.class); | ||
|
||
private VZoneConfig config = new VZoneConfig(); | ||
|
||
public VZoneHandler(Thing thing) { | ||
super(thing); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
config = getConfigAs(VZoneConfig.class); | ||
|
||
if (config.address < 0 || config.address > 99) { | ||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Invalid address setting"); | ||
return; | ||
} | ||
logger.debug("Virtual zone handler initializing for address {}", config.address); | ||
initDeviceState(); | ||
} | ||
|
||
@Override | ||
public void initChannelState() { | ||
UnDefType state = UnDefType.UNDEF; | ||
updateState(CHANNEL_STATE, state); | ||
firstUpdateReceived.set(false); | ||
} | ||
|
||
@Override | ||
public void notifyPanelReady() { | ||
logger.trace("Virtual zone handler for {} received panel ready notification.", config.address); | ||
if (firstUpdateReceived.compareAndSet(false, true)) { | ||
updateState(CHANNEL_STATE, OnOffType.ON); | ||
} | ||
} | ||
|
||
@Override | ||
public void handleCommand(ChannelUID channelUID, Command command) { | ||
if (channelUID.getId().equals(CHANNEL_COMMAND)) { | ||
if (command instanceof StringType) { | ||
String cmd = ((StringType) command).toString(); | ||
if (CMD_OPEN.equalsIgnoreCase(cmd)) { | ||
sendCommand(ADCommand.setZone(config.address, ADCommand.ZONE_OPEN)); | ||
setChannelState(OnOffType.OFF); | ||
} else if (CMD_CLOSED.equalsIgnoreCase(cmd)) { | ||
sendCommand(ADCommand.setZone(config.address, ADCommand.ZONE_CLOSED)); | ||
setChannelState(OnOffType.ON); | ||
} else { | ||
logger.debug("Virtual zone handler {} received invalid command: {}", config.address, cmd); | ||
} | ||
} | ||
} else if (channelUID.getId().equals(CHANNEL_STATE)) { | ||
if (command instanceof OnOffType) { | ||
if (command == OnOffType.OFF) { | ||
sendCommand(ADCommand.setZone(config.address, ADCommand.ZONE_OPEN)); | ||
setChannelState(OnOffType.OFF); | ||
} else if (command == OnOffType.ON) { | ||
sendCommand(ADCommand.setZone(config.address, ADCommand.ZONE_CLOSED)); | ||
setChannelState(OnOffType.ON); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private void setChannelState(OnOffType state) { | ||
updateState(CHANNEL_STATE, state); | ||
firstUpdateReceived.set(true); | ||
} | ||
|
||
@Override | ||
public void handleUpdate(ADMessage msg) { | ||
// There can be no update requests | ||
} | ||
} |
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.