Skip to content

Commit

Permalink
first try to remove existing channels on the fly
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Heberling <markus@heberling.net>
  • Loading branch information
tisoft committed Oct 29, 2022
1 parent 42d44bd commit 39ad0b8
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@

import static org.openhab.binding.saicismart.internal.SAICiSMARTBindingConstants.CHANNEL_FORCE_REFRESH;
import static org.openhab.binding.saicismart.internal.SAICiSMARTBindingConstants.CHANNEL_LAST_ACTIVITY;
import static org.openhab.binding.saicismart.internal.SAICiSMARTBindingConstants.CHANNEL_WINDOW_SUN_ROOF;

import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
Expand All @@ -28,6 +30,7 @@
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.binding.BaseThingHandler;
import org.openhab.core.thing.binding.builder.ThingBuilder;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
import org.slf4j.Logger;
Expand Down Expand Up @@ -77,6 +80,13 @@ public void handleCommand(ChannelUID channelUID, Command command) {
public void initialize() {
config = getConfigAs(SAICiSMARTVehicleConfiguration.class);

ThingBuilder thingBuilder = editThing();
thingBuilder.withChannels(thing.getChannels().stream().filter(c -> {
// TODO: check properties
return !c.getUID().getId().equals(CHANNEL_WINDOW_SUN_ROOF);
}).collect(Collectors.toList()));
updateThing(thingBuilder.build());

updateStatus(ThingStatus.UNKNOWN);

// just started, make sure we start querying
Expand Down

0 comments on commit 39ad0b8

Please sign in to comment.