Skip to content

Commit

Permalink
openhab#8 move supla binding to addons
Browse files Browse the repository at this point in the history
  • Loading branch information
magx2 committed May 4, 2019
1 parent d0c9d2d commit 3f6fc43
Show file tree
Hide file tree
Showing 55 changed files with 24 additions and 7 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@
<label>Dimmer</label>
</channel-type>

<channel-type id="toggle-gate-channel">
<item-type>String</item-type>
<label>Open/Close Gate</label>
<command>
<options>
<option value="NONE">None</option>
<option value="SELECT">Alert</option>
<option value="LSELECT">Long Alert</option>
</options>
</command>
</channel-type>

<channel-type id="unknown-channel">
<item-type>String</item-type>
<label>Unknown channel</label>
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public static class Channels {
public static final String HUMIDITY_CHANNEL_ID = "humidity-channel";
public static final String TEMPERATURE_AND_HUMIDITY_CHANNEL_ID = "temperature-and-humidity-channel";
public static final String DIMMER_CHANNEL_ID = "dimmer-channel";
public static final String TOGGLE_GAT_CHANNEL_ID = "toggle-gate-channel";
public static final String UNKNOWN_CHANNEL_ID = "unknown-channel";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ public ChannelInfo parse(ChannelUID channelUID) {
} else {
trimmedId = fullId;
}
return new ChannelInfo(parse(trimmedId), additionalChannelType.orElse(null));
return new ChannelInfo(parse(trimmedId, fullId), additionalChannelType.orElse(null));
}

private int parse(String id) {
private int parse(String id, String fullId) {
try {
return Integer.parseInt(id);
} catch (NumberFormatException ex) {
throw new IllegalArgumentException("Given id `" + id + "` is not int!", ex);
throw new IllegalArgumentException("Given id `" + id + "` is not int! Full ID = `" + fullId + "`", ex);
}
}
}
// ZjA0MWIwZWZmYWE5MTEzZGM3NDU3NjZjZDQ1ZTA3MTNjNGViNDUzOGYyNGQ3NjU2YTc5NGZkMTkzZjIzOTBhYQ.aHR0cHM6Ly9zdnIxOS5zdXBsYS5vcmc=
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.openhab.binding.supla.handler.CloudBridgeHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pl.grzeslowski.jsupla.api.ApiClientFactory;
import pl.grzeslowski.jsupla.api.generated.ApiClient;
import pl.grzeslowski.jsupla.api.generated.ApiException;
import pl.grzeslowski.jsupla.api.generated.api.IoDevicesApi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.util.List;

import static com.google.common.base.Strings.isNullOrEmpty;
import static java.lang.String.valueOf;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static java.util.Objects.requireNonNull;
Expand All @@ -28,6 +27,7 @@
import static org.openhab.binding.supla.SuplaBindingConstants.Channels.SWITCH_CHANNEL_RO_ID;
import static org.openhab.binding.supla.SuplaBindingConstants.Channels.TEMPERATURE_AND_HUMIDITY_CHANNEL_ID;
import static org.openhab.binding.supla.SuplaBindingConstants.Channels.TEMPERATURE_CHANNEL_ID;
import static org.openhab.binding.supla.SuplaBindingConstants.Channels.TOGGLE_GAT_CHANNEL_ID;

@SuppressWarnings("PackageAccessibility")
public class CreateChannelFunctionSwitch implements ChannelFunctionDispatcher.FunctionSwitch<List<Channel>> {
Expand All @@ -50,12 +50,12 @@ public List<Channel> onControllingTheGatewayLock(pl.grzeslowski.jsupla.api.gener

@Override
public List<Channel> onControllingTheGate(pl.grzeslowski.jsupla.api.generated.model.Channel channel) {
return createSwitchChannel(channel);
return createToggleGateChannel(channel);
}

@Override
public List<Channel> onControllingTheGarageDoor(pl.grzeslowski.jsupla.api.generated.model.Channel channel) {
return createSwitchChannel(channel);
return createToggleGateChannel(channel);
}

@Override
Expand Down Expand Up @@ -230,6 +230,10 @@ private List<Channel> createSwitchChannel(pl.grzeslowski.jsupla.api.generated.mo
}
}

private List<Channel> createToggleGateChannel(pl.grzeslowski.jsupla.api.generated.model.Channel channel) {
return singletonList(createChannel(channel, TOGGLE_GAT_CHANNEL_ID, "String"));
}

private List<Channel> createLedChannels(final pl.grzeslowski.jsupla.api.generated.model.Channel channel) {
return singletonList(createChannel(channel, RGB_CHANNEL_ID, "Color"));
}
Expand Down

0 comments on commit 3f6fc43

Please sign in to comment.