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.
[intesis] - added IntesisBox support (openhab#8694)
* Intesis Binding - added IntesisBox support
- Loading branch information
Showing
16 changed files
with
900 additions
and
43 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
37 changes: 37 additions & 0 deletions
37
...esis/src/main/java/org/openhab/binding/intesis/internal/api/IntesisBoxChangeListener.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,37 @@ | ||
/** | ||
* 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.intesis.internal.api; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.openhab.core.thing.ThingStatus; | ||
|
||
/** | ||
* The {@link IntesisBoxChangeListener} is in interface for a IntesisBox changed consumer | ||
* | ||
* @author Hans-Jörg Merk - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public interface IntesisBoxChangeListener { | ||
/** | ||
* This method will be called in case a message was received. | ||
* | ||
*/ | ||
void messageReceived(String messageLine); | ||
|
||
/** | ||
* This method will be called in case the connection status has changed. | ||
* | ||
*/ | ||
void connectionStatusChanged(ThingStatus status, @Nullable String message); | ||
} |
78 changes: 78 additions & 0 deletions
78
...ing.intesis/src/main/java/org/openhab/binding/intesis/internal/api/IntesisBoxMessage.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,78 @@ | ||
/** | ||
* 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.intesis.internal.api; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
|
||
/** | ||
* @author Cody Cutrer - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class IntesisBoxMessage { | ||
public static final String ID = "ID"; | ||
public static final String INFO = "INFO"; | ||
public static final String SET = "SET"; | ||
public static final String CHN = "CHN"; | ||
public static final String GET = "GET"; | ||
public static final String LOGIN = "LOGIN"; | ||
public static final String LOGOUT = "LOGOUT"; | ||
public static final String CFG = "CFG"; | ||
public static final String LIMITS = "LIMITS"; | ||
public static final String DISCOVER = "DISCOVER"; | ||
|
||
private static final Pattern REGEX = Pattern.compile("^([^,]+)(?:,(\\d+))?:([^,]+),([A-Z0-9.,\\[\\]]+)$"); | ||
|
||
@SuppressWarnings("unused") | ||
private final String acNum; | ||
private final String command; | ||
private final String function; | ||
private final String value; | ||
|
||
private IntesisBoxMessage(String command, String acNum, String function, String value) { | ||
this.command = command; | ||
this.acNum = acNum; | ||
this.function = function; | ||
this.value = value; | ||
} | ||
|
||
public String getCommand() { | ||
return command; | ||
} | ||
|
||
public String getFunction() { | ||
return function; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public List<String> getLimitsValue() { | ||
return Arrays.asList(value.substring(1, value.length() - 1).split(",")); | ||
} | ||
|
||
public static @Nullable IntesisBoxMessage parse(String message) { | ||
Matcher m = REGEX.matcher(message); | ||
if (!m.find()) { | ||
return null; | ||
} | ||
|
||
return new IntesisBoxMessage(m.group(1), m.group(2), m.group(3), m.group(4)); | ||
} | ||
} |
Oops, something went wrong.