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.
[lcn] Add configuration option invertOpenClosed to binary sensor chan…
…nel (openhab#8102) Closes openhab#8069 Signed-off-by: Thomas Weiler <[email protected]> Signed-off-by: MPH80 <[email protected]>
- Loading branch information
Showing
9 changed files
with
218 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -820,5 +820,4 @@ private static int convertMsecToLCNTimer(double ms) { | |
} | ||
return lcntimer; | ||
} | ||
|
||
} |
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
48 changes: 48 additions & 0 deletions
48
...ding.lcn/src/main/java/org/openhab/binding/lcn/internal/converter/InversionConverter.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,48 @@ | ||
/** | ||
* 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.lcn.internal.converter; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.smarthome.core.library.types.OnOffType; | ||
import org.eclipse.smarthome.core.library.types.OpenClosedType; | ||
import org.eclipse.smarthome.core.library.types.UpDownType; | ||
import org.eclipse.smarthome.core.types.State; | ||
|
||
/** | ||
* Converter for all states representing antonyms. | ||
* | ||
* @author Thomas Weiler - Initial Contribution | ||
*/ | ||
@NonNullByDefault | ||
public class InversionConverter extends Converter { | ||
/** | ||
* Converts a state into its antonym where applicable. | ||
* | ||
* @param state to be inverted | ||
* @return inverted state | ||
*/ | ||
@Override | ||
public State onStateUpdateFromHandler(State state) { | ||
State convertedState = state; | ||
|
||
if (state instanceof OpenClosedType) { | ||
convertedState = state.equals(OpenClosedType.OPEN) ? OpenClosedType.CLOSED : OpenClosedType.OPEN; | ||
} else if (state instanceof OnOffType) { | ||
convertedState = state.equals(OnOffType.ON) ? OnOffType.OFF : OnOffType.ON; | ||
} else if (state instanceof UpDownType) { | ||
convertedState = state.equals(UpDownType.UP) ? UpDownType.DOWN : UpDownType.UP; | ||
} | ||
|
||
return convertedState; | ||
} | ||
} |
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.