Skip to content

Commit

Permalink
Fix ChannelTresholdController channels not configurable in UI + add log
Browse files Browse the repository at this point in the history
  • Loading branch information
sfeilmeier committed Apr 5, 2018
1 parent ae3399b commit ffed9cd
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class ChannelThresholdController extends Controller {
private final Logger log = LoggerFactory.getLogger(ChannelThresholdController.class);

private ThingStateChannels thingState = new ThingStateChannels(this);

/*
* Constructors
*/
Expand All @@ -83,7 +84,7 @@ public ChannelThresholdController(String thingId) {
*/
@SuppressWarnings("unchecked")
@ChannelInfo(title = "Channel", description = "Address of the channel that indicates the switching by the min and max threshold.", type = String.class)
public ConfigChannel<String> thresholdChannelName = new ConfigChannel<String>("thresholdChannelAddress", this)
public ConfigChannel<String> thresholdChannelAddress = new ConfigChannel<String>("thresholdChannelAddress", this)
.addChangeListener((channel, newValue, oldValue) -> {
Optional<String> channelAddress = (Optional<String>) newValue;
if (channelAddress.isPresent()) {
Expand All @@ -100,7 +101,7 @@ public ChannelThresholdController(String thingId) {

@SuppressWarnings("unchecked")
@ChannelInfo(title = "Output", description = "Address of the digital output channel that should be switched.", type = String.class)
public ConfigChannel<String> outputChannelName = new ConfigChannel<String>("outputChannelAddress", this)
public ConfigChannel<String> outputChannelAddress = new ConfigChannel<String>("outputChannelAddress", this)
.addChangeListener((channel, newValue, oldValue) -> {
Optional<String> channelAddress = (Optional<String>) newValue;
if (channelAddress.isPresent()) {
Expand Down Expand Up @@ -170,13 +171,15 @@ public void run() {
private void on(boolean invertOutput) throws WriteChannelException {
Optional<Boolean> currentValueOpt = this.outputChannel.valueOptional();
if (!currentValueOpt.isPresent() || currentValueOpt.get() != (true ^ invertOutput)) {
log.info("Set output [" + this.outputChannel.address() + "] ON.");
outputChannel.pushWrite(true ^ invertOutput);
}
}

private void off(boolean invertOutput) throws WriteChannelException {
Optional<Boolean> currentValueOpt = this.outputChannel.valueOptional();
if (!currentValueOpt.isPresent() || currentValueOpt.get() != (false ^ invertOutput)) {
log.info("Set output [" + this.outputChannel.address() + "] OFF.");
outputChannel.pushWrite(false ^ invertOutput);
}
}
Expand Down

0 comments on commit ffed9cd

Please sign in to comment.