Skip to content

Commit

Permalink
Revert "evcc DynamicChannelGroupTypes"
Browse files Browse the repository at this point in the history
This reverts commit 6c93006.

Signed-off-by: Michael Weger <[email protected]>
  • Loading branch information
MikeTheTux committed May 24, 2024
1 parent 9606729 commit 7254fbf
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@NonNullByDefault
public class EvccBindingConstants {

public static final String BINDING_ID = "evcc";
private static final String BINDING_ID = "evcc";

public static final String CHANNEL_GROUP_ID_GENERAL = "general";
public static final String CHANNEL_GROUP_ID_LOADPOINT = "loadpoint";
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
import org.openhab.core.thing.ThingUID;
import org.openhab.core.thing.binding.BaseThingHandler;
import org.openhab.core.thing.binding.builder.ChannelBuilder;
import org.openhab.core.thing.type.ChannelGroupType;
import org.openhab.core.thing.type.ChannelGroupTypeBuilder;
import org.openhab.core.thing.type.ChannelGroupTypeUID;
import org.openhab.core.thing.type.ChannelTypeUID;
import org.openhab.core.types.Command;
import org.openhab.core.types.RefreshType;
Expand All @@ -74,8 +71,6 @@ public class EvccHandler extends BaseThingHandler {

private @Nullable Result result;

private final EvccDynamicTypeProvider typeProvider;

private boolean batteryConfigured = false;
private boolean gridConfigured = false;
private boolean pvConfigured = false;
Expand All @@ -84,9 +79,8 @@ public class EvccHandler extends BaseThingHandler {

Map<String, Triple<Boolean, Float, ZonedDateTime>> vehiclePlans = new HashMap<>();

public EvccHandler(Thing thing, EvccDynamicTypeProvider typeProvider) {
public EvccHandler(Thing thing) {
super(thing);
this.typeProvider = typeProvider;
}

@Override
Expand Down Expand Up @@ -438,14 +432,12 @@ private void refresh() {
}

@Override
public void handleRemoval() {
public void dispose() {
ScheduledFuture<?> statePollingJob = this.statePollingJob;
if (statePollingJob != null) {
statePollingJob.cancel(true);
this.statePollingJob = null;
}
// typeProvider.removeChannelTypesForThing(getThing().getUID());
super.handleRemoval();
}

// Utility functions
Expand Down Expand Up @@ -608,8 +600,6 @@ private void createChannelsVehicle(String vehicleName, @Nullable String loadpoin
channelGroup = loadpointName + CHANNEL_GROUP_ID_CURRENT;
}

createChannelGroup(channelGroup);

createChannel(CHANNEL_HEATING_MIN_TEMPERATURE, channelGroup, CHANNEL_TYPE_UID_HEATING_MIN_TEMPERATURE,
"Number:Temperature");
createChannel(CHANNEL_HEATING_LIMIT_TEMPERATURE, channelGroup, CHANNEL_TYPE_UID_HEATING_LIMIT_TEMPERATURE,
Expand Down Expand Up @@ -1001,15 +991,6 @@ private void updateVehiclePlanChannel(ThingUID uid, String vehicleName, String c
}
}

private void createChannelGroup(String channelGroupTypeId) {
ChannelGroupTypeUID channelGroupTypeUID = new ChannelGroupTypeUID(BINDING_ID, channelGroupTypeId);
ChannelGroupTypeBuilder builder = ChannelGroupTypeBuilder.instance(channelGroupTypeUID, channelGroupTypeId);
ChannelGroupType channelGroupType = builder.build();
typeProvider.putChannelGroupType(channelGroupType);
logger.info("channelGroupTypeId: {}; channelGroupTypeUID: {}; channelGroupType: {}", channelGroupTypeId,
channelGroupTypeUID, channelGroupType);
}

private void createChannel(String channel, String channelGroupId, ChannelTypeUID channelTypeUID, String itemType) {
ChannelUID channelUid = new ChannelUID(thing.getUID(), channelGroupId, channel);
if (thing.getChannel(channelUid) == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.ThingHandlerFactory;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
* The {@link EvccHandlerFactory} is responsible for creating things and thing
Expand All @@ -39,13 +37,6 @@ public class EvccHandlerFactory extends BaseThingHandlerFactory {

private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_DEVICE);

private final EvccDynamicTypeProvider dynamicTypeProvider;

@Activate
public EvccHandlerFactory(@Reference EvccDynamicTypeProvider dynamicTypeProvider) {
this.dynamicTypeProvider = dynamicTypeProvider;
}

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
Expand All @@ -56,7 +47,7 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();

if (THING_TYPE_DEVICE.equals(thingTypeUID)) {
return new EvccHandler(thing, dynamicTypeProvider);
return new EvccHandler(thing);
}

return null;
Expand Down

0 comments on commit 7254fbf

Please sign in to comment.