Skip to content

Commit

Permalink
#4 Support inverted logic for CONTROLLINGTHEGATE and `CONTROLLINGTH…
Browse files Browse the repository at this point in the history
…EGARAGEDOOR`
  • Loading branch information
magx2 committed Apr 10, 2019
1 parent 64eb5a3 commit 080afae
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,14 @@ private Optional<State> hiType(Channel channel) {
* https://github.com/SUPLA/supla-cloud/wiki/Channel-Functions-states
*/
private Optional<State> optionalHiType(Channel channel) {
boolean invertedLogic = channel.getParam3() != null && channel.getParam3() > 1;
boolean param2Present = channel.getParam2() != null && channel.getParam2() > 0;
if (param2Present || !channel.getType().isOutput()) {
return of(channel).map(Channel::getState).map(ChannelState::getHi).map(hi -> hi ? ON : OFF);
return of(channel)
.map(Channel::getState)
.map(ChannelState::getHi)
.map(hi -> invertedLogic ? !hi : hi)
.map(hi -> hi ? ON : OFF);
} else {
return empty();
}
Expand Down

0 comments on commit 080afae

Please sign in to comment.