/**
 * Copyright (c) 2010-2020 Contributors to the openHAB project
 *
 * See the NOTICE file(s) distributed with this work for additional
 * information.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0
 *
 * SPDX-License-Identifier: EPL-2.0
 */

 /* ***********************************************************
 * This file was automatically generated on 2022-01-03.      *
 *                                                           *
 * openHAB Bindings Version 2.0.0                            *
 *                                                           *
 * If you have a bugfix for this file and want to commit it, *
 * please fix the bug in the generator. You can find a link  *
 * to the generators git repository on tinkerforge.com       *
 *************************************************************/

package org.openhab.binding.tinkerforge.internal.device;

import java.net.URI;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.eclipse.smarthome.config.core.Configuration;
import org.eclipse.smarthome.config.core.ConfigDescription;
import org.eclipse.smarthome.config.core.ConfigDescriptionBuilder;
import org.eclipse.smarthome.config.core.ConfigDescriptionParameter.Type;
import org.eclipse.smarthome.config.core.ConfigDescriptionParameterBuilder;
import org.eclipse.smarthome.config.core.ConfigDescriptionParameterGroup;
import org.eclipse.smarthome.config.core.ParameterOption;
import org.eclipse.smarthome.core.types.State;
import org.eclipse.smarthome.core.types.StateOption;
import org.eclipse.smarthome.core.types.Command;
import org.eclipse.smarthome.core.types.CommandDescriptionBuilder;
import org.eclipse.smarthome.core.types.CommandOption;
import org.eclipse.smarthome.core.thing.ChannelUID;
import org.eclipse.smarthome.core.thing.ThingStatus;
import org.eclipse.smarthome.core.thing.ThingTypeUID;
import org.eclipse.smarthome.core.thing.binding.BaseThingHandler;
import org.eclipse.smarthome.core.thing.type.ChannelDefinitionBuilder;
import org.eclipse.smarthome.core.thing.type.ChannelType;
import org.eclipse.smarthome.core.thing.type.ChannelTypeBuilder;
import org.eclipse.smarthome.core.thing.type.ChannelTypeUID;
import org.eclipse.smarthome.core.types.RefreshType;
import org.eclipse.smarthome.core.thing.type.ThingType;
import org.eclipse.smarthome.core.thing.type.ThingTypeBuilder;
import org.eclipse.smarthome.core.types.StateDescriptionFragmentBuilder;
import org.openhab.binding.tinkerforge.internal.TinkerforgeBindingConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.eclipse.smarthome.core.library.types.DecimalType;
import org.eclipse.smarthome.core.library.types.QuantityType;
import org.eclipse.smarthome.core.library.unit.MetricPrefix;
import org.eclipse.smarthome.core.library.unit.SIUnits;
import org.eclipse.smarthome.core.library.unit.SmartHomeUnits;
import org.eclipse.smarthome.core.library.types.OpenClosedType;
import org.eclipse.smarthome.core.library.types.StringType;

import com.tinkerforge.BrickletMultiTouch;
import com.tinkerforge.IPConnection;
import com.tinkerforge.TinkerforgeException;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;

/**
 * Wraps the Java Bindings of the Multi Touch Bricklet.
 * @author Erik Fleckstein - Initial contribution
 */
@NonNullByDefault
public class BrickletMultiTouchWrapper extends BrickletMultiTouch implements StandardFlashable, DeviceWrapper {
    public static final DeviceInfo DEVICE_INFO = new DeviceInfo(BrickletMultiTouch.DEVICE_DISPLAY_NAME, "brickletmultitouch", BrickletMultiTouch.DEVICE_IDENTIFIER, BrickletMultiTouchWrapper.class, BrickletMultiTouchActions.class, "2.0.0", false);

    public BrickletMultiTouchWrapper(String uid, IPConnection ipcon) {
        super(uid, ipcon);
    }

    private List<ScheduledFuture<?>> manualChannelUpdates = new ArrayList<>();
    private List<ListenerReg<?>> listenerRegs = new ArrayList<>();

    public void cancelManualUpdates() {
        manualChannelUpdates.forEach(f -> f.cancel(true));
    }

    public <T> T reg(T listener, Consumer<T> toRemove) {
        listenerRegs.add(new ListenerReg<T>(listener, toRemove));
        return listener;
    }

    
    private final Logger logger = LoggerFactory.getLogger(BrickletMultiTouchWrapper.class);

    @Override
    public void initialize(org.eclipse.smarthome.config.core.Configuration config, Function<String, org.eclipse.smarthome.config.core.Configuration> getChannelConfigFn, BiConsumer<String, org.eclipse.smarthome.core.types.State> updateStateFn, BiConsumer<String, String> triggerChannelFn, ScheduledExecutorService scheduler, BaseThingHandler handler) throws TinkerforgeException {
        this.setResponseExpectedAll(true);
        BrickletMultiTouchConfig cfg = (BrickletMultiTouchConfig) config.as(BrickletMultiTouchConfig.class);
        if(cfg.electrode0Enabled) {
this.addTouchStateListener(this.reg((state) -> {if(true) {updateStateFn.accept("BrickletMultiTouchElectrode0", transformBrickletMultiTouchElectrode0Callback0(state, cfg));}}, this::removeTouchStateListener));}
		if(cfg.electrode1Enabled) {
this.addTouchStateListener(this.reg((state) -> {if(true) {updateStateFn.accept("BrickletMultiTouchElectrode1", transformBrickletMultiTouchElectrode1Callback0(state, cfg));}}, this::removeTouchStateListener));}
		if(cfg.electrode2Enabled) {
this.addTouchStateListener(this.reg((state) -> {if(true) {updateStateFn.accept("BrickletMultiTouchElectrode2", transformBrickletMultiTouchElectrode2Callback0(state, cfg));}}, this::removeTouchStateListener));}
		if(cfg.electrode3Enabled) {
this.addTouchStateListener(this.reg((state) -> {if(true) {updateStateFn.accept("BrickletMultiTouchElectrode3", transformBrickletMultiTouchElectrode3Callback0(state, cfg));}}, this::removeTouchStateListener));}
		if(cfg.electrode4Enabled) {
this.addTouchStateListener(this.reg((state) -> {if(true) {updateStateFn.accept("BrickletMultiTouchElectrode4", transformBrickletMultiTouchElectrode4Callback0(state, cfg));}}, this::removeTouchStateListener));}
		if(cfg.electrode5Enabled) {
this.addTouchStateListener(this.reg((state) -> {if(true) {updateStateFn.accept("BrickletMultiTouchElectrode5", transformBrickletMultiTouchElectrode5Callback0(state, cfg));}}, this::removeTouchStateListener));}
		if(cfg.electrode6Enabled) {
this.addTouchStateListener(this.reg((state) -> {if(true) {updateStateFn.accept("BrickletMultiTouchElectrode6", transformBrickletMultiTouchElectrode6Callback0(state, cfg));}}, this::removeTouchStateListener));}
		if(cfg.electrode7Enabled) {
this.addTouchStateListener(this.reg((state) -> {if(true) {updateStateFn.accept("BrickletMultiTouchElectrode7", transformBrickletMultiTouchElectrode7Callback0(state, cfg));}}, this::removeTouchStateListener));}
		if(cfg.electrode8Enabled) {
this.addTouchStateListener(this.reg((state) -> {if(true) {updateStateFn.accept("BrickletMultiTouchElectrode8", transformBrickletMultiTouchElectrode8Callback0(state, cfg));}}, this::removeTouchStateListener));}
		if(cfg.electrode9Enabled) {
this.addTouchStateListener(this.reg((state) -> {if(true) {updateStateFn.accept("BrickletMultiTouchElectrode9", transformBrickletMultiTouchElectrode9Callback0(state, cfg));}}, this::removeTouchStateListener));}
		if(cfg.electrode10Enabled) {
this.addTouchStateListener(this.reg((state) -> {if(true) {updateStateFn.accept("BrickletMultiTouchElectrode10", transformBrickletMultiTouchElectrode10Callback0(state, cfg));}}, this::removeTouchStateListener));}
		if(cfg.electrode11Enabled) {
this.addTouchStateListener(this.reg((state) -> {if(true) {updateStateFn.accept("BrickletMultiTouchElectrode11", transformBrickletMultiTouchElectrode11Callback0(state, cfg));}}, this::removeTouchStateListener));}
		if(cfg.proximityEnabled) {
this.addTouchStateListener(this.reg((state) -> {if(true) {updateStateFn.accept("BrickletMultiTouchProximity", transformBrickletMultiTouchProximityCallback0(state, cfg));}}, this::removeTouchStateListener));}
        this.setElectrodeSensitivity(cfg.sensitivity.shortValue());
		        this.recalibrate();
		        this.setElectrodeConfig((cfg.electrode0Enabled ? 1 << 0 : 0) | (cfg.electrode1Enabled ? 1 << 1 : 0) | (cfg.electrode2Enabled ? 1 << 2 : 0) | (cfg.electrode3Enabled ? 1 << 3 : 0) | (cfg.electrode4Enabled ? 1 << 4 : 0) | (cfg.electrode5Enabled ? 1 << 5 : 0) | (cfg.electrode6Enabled ? 1 << 6 : 0) | (cfg.electrode7Enabled ? 1 << 7 : 0) | (cfg.electrode8Enabled ? 1 << 8 : 0) | (cfg.electrode9Enabled ? 1 << 9 : 0) | (cfg.electrode10Enabled ? 1 << 10 : 0) | (cfg.electrode11Enabled ? 1 << 11 : 0) | (cfg.proximityEnabled ? 1 << 12 : 0));
    }

    @Override
    public void dispose(org.eclipse.smarthome.config.core.Configuration config) throws TinkerforgeException {
        listenerRegs.forEach(ListenerReg::deregister);

        
        
    }

    @Override
    public List<String> getEnabledChannels(org.eclipse.smarthome.config.core.Configuration config) throws TinkerforgeException{
        BrickletMultiTouchConfig cfg = (BrickletMultiTouchConfig) config.as(BrickletMultiTouchConfig.class);
List<String> result = new ArrayList<String>();
        if (cfg.electrode0Enabled) {
                result.add("BrickletMultiTouchElectrode0");
            }
		if (cfg.electrode1Enabled) {
                result.add("BrickletMultiTouchElectrode1");
            }
		if (cfg.electrode2Enabled) {
                result.add("BrickletMultiTouchElectrode2");
            }
		if (cfg.electrode3Enabled) {
                result.add("BrickletMultiTouchElectrode3");
            }
		if (cfg.electrode4Enabled) {
                result.add("BrickletMultiTouchElectrode4");
            }
		if (cfg.electrode5Enabled) {
                result.add("BrickletMultiTouchElectrode5");
            }
		if (cfg.electrode6Enabled) {
                result.add("BrickletMultiTouchElectrode6");
            }
		if (cfg.electrode7Enabled) {
                result.add("BrickletMultiTouchElectrode7");
            }
		if (cfg.electrode8Enabled) {
                result.add("BrickletMultiTouchElectrode8");
            }
		if (cfg.electrode9Enabled) {
                result.add("BrickletMultiTouchElectrode9");
            }
		if (cfg.electrode10Enabled) {
                result.add("BrickletMultiTouchElectrode10");
            }
		if (cfg.electrode11Enabled) {
                result.add("BrickletMultiTouchElectrode11");
            }
		if (cfg.proximityEnabled) {
                result.add("BrickletMultiTouchProximity");
            }
		result.add("BrickletMultiTouchRecalibrate");
        return result;
    }

    public static @Nullable ChannelType getChannelType(ChannelTypeUID channelTypeUID) {
        switch(channelTypeUID.getId()) {
            case "BrickletMultiTouchElectrode":
                return ChannelTypeBuilder.state(new ChannelTypeUID("tinkerforge", "BrickletMultiTouchElectrode"), "NOT USED", "Contact").withConfigDescriptionURI(URI.create("channel-type:tinkerforge:BrickletMultiTouchElectrode")).withDescription("The current touch state. An electrode is already counted as touched if a finger is nearly touching the electrode. This means that you can put a piece of paper or foil or similar on top of a electrode to build a touch panel with a professional look.").build();
            case "BrickletMultiTouchRecalibrate":
                return ChannelTypeBuilder.state(new ChannelTypeUID("tinkerforge", "BrickletMultiTouchRecalibrate"), "Recalibrate Electrodes", "String").withConfigDescriptionURI(URI.create("channel-type:tinkerforge:BrickletMultiTouchRecalibrate")).withDescription("Recalibrates the electrodes. Trigger this channel whenever you changed or moved you electrodes.")
.withCommandDescription(CommandDescriptionBuilder.create().withCommandOption(new CommandOption("TRIGGER", "Trigger")).build()).build();
default:
                break;
        }

        return null;
    }

    public static ThingType getThingType(ThingTypeUID thingTypeUID) {
             Map<String, String> thingTypeProperties = ThingTypeBuilder.instance(thingTypeUID, "unused").build().getProperties();
             Map<String, String> props = new HashMap<String, String>(thingTypeProperties);
             props.putIfAbsent(TinkerforgeBindingConstants.PROPERTY_MINIMUM_FIRMWARE_VERSION, DEVICE_INFO.minimumFWVersion);
        return ThingTypeBuilder.instance(thingTypeUID, "Tinkerforge Multi Touch Bricklet").isListed(false).withSupportedBridgeTypeUIDs(Arrays.asList(TinkerforgeBindingConstants.THING_TYPE_BRICK_DAEMON.toString())).withConfigDescriptionURI(URI.create("thing-type:tinkerforge:" + thingTypeUID.getId())).withDescription("Capacitive touch sensor for 12 electrodes").withChannelDefinitions(Arrays.asList(new ChannelDefinitionBuilder("BrickletMultiTouchElectrode0", new ChannelTypeUID("tinkerforge", "BrickletMultiTouchElectrode")).withLabel("Electrode 0").build(), new ChannelDefinitionBuilder("BrickletMultiTouchElectrode1", new ChannelTypeUID("tinkerforge", "BrickletMultiTouchElectrode")).withLabel("Electrode 1").build(), new ChannelDefinitionBuilder("BrickletMultiTouchElectrode2", new ChannelTypeUID("tinkerforge", "BrickletMultiTouchElectrode")).withLabel("Electrode 2").build(), new ChannelDefinitionBuilder("BrickletMultiTouchElectrode3", new ChannelTypeUID("tinkerforge", "BrickletMultiTouchElectrode")).withLabel("Electrode 3").build(), new ChannelDefinitionBuilder("BrickletMultiTouchElectrode4", new ChannelTypeUID("tinkerforge", "BrickletMultiTouchElectrode")).withLabel("Electrode 4").build(), new ChannelDefinitionBuilder("BrickletMultiTouchElectrode5", new ChannelTypeUID("tinkerforge", "BrickletMultiTouchElectrode")).withLabel("Electrode 5").build(), new ChannelDefinitionBuilder("BrickletMultiTouchElectrode6", new ChannelTypeUID("tinkerforge", "BrickletMultiTouchElectrode")).withLabel("Electrode 6").build(), new ChannelDefinitionBuilder("BrickletMultiTouchElectrode7", new ChannelTypeUID("tinkerforge", "BrickletMultiTouchElectrode")).withLabel("Electrode 7").build(), new ChannelDefinitionBuilder("BrickletMultiTouchElectrode8", new ChannelTypeUID("tinkerforge", "BrickletMultiTouchElectrode")).withLabel("Electrode 8").build(), new ChannelDefinitionBuilder("BrickletMultiTouchElectrode9", new ChannelTypeUID("tinkerforge", "BrickletMultiTouchElectrode")).withLabel("Electrode 9").build(), new ChannelDefinitionBuilder("BrickletMultiTouchElectrode10", new ChannelTypeUID("tinkerforge", "BrickletMultiTouchElectrode")).withLabel("Electrode 10").build(), new ChannelDefinitionBuilder("BrickletMultiTouchElectrode11", new ChannelTypeUID("tinkerforge", "BrickletMultiTouchElectrode")).withLabel("Electrode 11").build(), new ChannelDefinitionBuilder("BrickletMultiTouchProximity", new ChannelTypeUID("tinkerforge", "BrickletMultiTouchElectrode")).withLabel("Proximity").withDescription("If a hand or similar is in proximity to the electrodes, this channel is toggled. The proximity is activated with a distance of 1-2cm. This means that you can put a piece of paper or foil or similar on top of a electrode to build a touch panel with a professional look.").build(), new ChannelDefinitionBuilder("BrickletMultiTouchRecalibrate", new ChannelTypeUID("tinkerforge", "BrickletMultiTouchRecalibrate")).withLabel("Recalibrate Electrodes").build())).withProperties(props).build();
    }

    public static @Nullable ConfigDescription getConfigDescription(URI uri) {
        switch(uri.toASCIIString()) {
            case "thing-type:tinkerforge:brickletmultitouch":
                return ConfigDescriptionBuilder.create(uri).withParameters(Arrays.asList(ConfigDescriptionParameterBuilder.create("sensitivity", Type.INTEGER).withDefault("181").withDescription("The sensitivity of the electrodes. An electrode with a high sensitivity will register a touch earlier then an electrode with a low sensitivity.<br/><br/>If you build a big electrode you might need to decrease the sensitivity, since the area that can be charged will get bigger. If you want to be able to activate an electrode from further away you need to increase the sensitivity.").withLabel("Sensitivity").withMinimum(BigDecimal.valueOf(5)).withMaximum(BigDecimal.valueOf(201)).build(), ConfigDescriptionParameterBuilder.create("proximityEnabled", Type.BOOLEAN).withDefault("true").withDescription("It is recommended that you disable the proximity feature if not needed. This will reduce the amount of traffic that is produced.").withLabel("Proximity Detection").build(), ConfigDescriptionParameterBuilder.create("electrode0Enabled", Type.BOOLEAN).withDefault("true").withDescription("A disabled electrode will always return false as its state. If you don't need all electrodes you can disable the electrodes that are not needed. Disabling electrodes will also reduce power consumption.").withLabel("Electrode 0 Enabled").build(), ConfigDescriptionParameterBuilder.create("electrode1Enabled", Type.BOOLEAN).withDefault("true").withDescription("A disabled electrode will always return false as its state. If you don't need all electrodes you can disable the electrodes that are not needed. Disabling electrodes will also reduce power consumption.").withLabel("Electrode 1 Enabled").build(), ConfigDescriptionParameterBuilder.create("electrode2Enabled", Type.BOOLEAN).withDefault("true").withDescription("A disabled electrode will always return false as its state. If you don't need all electrodes you can disable the electrodes that are not needed. Disabling electrodes will also reduce power consumption.").withLabel("Electrode 2 Enabled").build(), ConfigDescriptionParameterBuilder.create("electrode3Enabled", Type.BOOLEAN).withDefault("true").withDescription("A disabled electrode will always return false as its state. If you don't need all electrodes you can disable the electrodes that are not needed. Disabling electrodes will also reduce power consumption.").withLabel("Electrode 3 Enabled").build(), ConfigDescriptionParameterBuilder.create("electrode4Enabled", Type.BOOLEAN).withDefault("true").withDescription("A disabled electrode will always return false as its state. If you don't need all electrodes you can disable the electrodes that are not needed. Disabling electrodes will also reduce power consumption.").withLabel("Electrode 4 Enabled").build(), ConfigDescriptionParameterBuilder.create("electrode5Enabled", Type.BOOLEAN).withDefault("true").withDescription("A disabled electrode will always return false as its state. If you don't need all electrodes you can disable the electrodes that are not needed. Disabling electrodes will also reduce power consumption.").withLabel("Electrode 5 Enabled").build(), ConfigDescriptionParameterBuilder.create("electrode6Enabled", Type.BOOLEAN).withDefault("true").withDescription("A disabled electrode will always return false as its state. If you don't need all electrodes you can disable the electrodes that are not needed. Disabling electrodes will also reduce power consumption.").withLabel("Electrode 6 Enabled").build(), ConfigDescriptionParameterBuilder.create("electrode7Enabled", Type.BOOLEAN).withDefault("true").withDescription("A disabled electrode will always return false as its state. If you don't need all electrodes you can disable the electrodes that are not needed. Disabling electrodes will also reduce power consumption.").withLabel("Electrode 7 Enabled").build(), ConfigDescriptionParameterBuilder.create("electrode8Enabled", Type.BOOLEAN).withDefault("true").withDescription("A disabled electrode will always return false as its state. If you don't need all electrodes you can disable the electrodes that are not needed. Disabling electrodes will also reduce power consumption.").withLabel("Electrode 8 Enabled").build(), ConfigDescriptionParameterBuilder.create("electrode9Enabled", Type.BOOLEAN).withDefault("true").withDescription("A disabled electrode will always return false as its state. If you don't need all electrodes you can disable the electrodes that are not needed. Disabling electrodes will also reduce power consumption.").withLabel("Electrode 9 Enabled").build(), ConfigDescriptionParameterBuilder.create("electrode10Enabled", Type.BOOLEAN).withDefault("true").withDescription("A disabled electrode will always return false as its state. If you don't need all electrodes you can disable the electrodes that are not needed. Disabling electrodes will also reduce power consumption.").withLabel("Electrode 10 Enabled").build(), ConfigDescriptionParameterBuilder.create("electrode11Enabled", Type.BOOLEAN).withDefault("true").withDescription("A disabled electrode will always return false as its state. If you don't need all electrodes you can disable the electrodes that are not needed. Disabling electrodes will also reduce power consumption.").withLabel("Electrode 11 Enabled").build())).withParameterGroups(Arrays.asList(new ConfigDescriptionParameterGroup("update_intervals", "null", true, "Update Intervals", "Update Intervals"))).build();
            case "channel-type:tinkerforge:BrickletMultiTouchElectrode":
                return ConfigDescriptionBuilder.create(uri).withParameters(Arrays.asList()).withParameterGroups(Arrays.asList()).build();
            case "channel-type:tinkerforge:BrickletMultiTouchRecalibrate":
                return ConfigDescriptionBuilder.create(uri).withParameters(Arrays.asList()).withParameterGroups(Arrays.asList()).build();
            default:
                break;
        }
        return null;
    }

        @Override
    public void refreshValue(String channel, org.eclipse.smarthome.config.core.Configuration config, org.eclipse.smarthome.config.core.Configuration channelConfig, BiConsumer<String, org.eclipse.smarthome.core.types.State> updateStateFn, BiConsumer<String, String> triggerChannelFn) throws TinkerforgeException {
        BrickletMultiTouchConfig cfg = (BrickletMultiTouchConfig) config.as(BrickletMultiTouchConfig.class);
switch(channel) {
            case "BrickletMultiTouchElectrode0":
                   {
            int value = this.getTouchState();
            if(true)
                updateStateFn.accept(channel, transformBrickletMultiTouchElectrode0Getter0(value, cfg));
        }
                   return;
            case "BrickletMultiTouchElectrode1":
                   {
            int value = this.getTouchState();
            if(true)
                updateStateFn.accept(channel, transformBrickletMultiTouchElectrode1Getter0(value, cfg));
        }
                   return;
            case "BrickletMultiTouchElectrode2":
                   {
            int value = this.getTouchState();
            if(true)
                updateStateFn.accept(channel, transformBrickletMultiTouchElectrode2Getter0(value, cfg));
        }
                   return;
            case "BrickletMultiTouchElectrode3":
                   {
            int value = this.getTouchState();
            if(true)
                updateStateFn.accept(channel, transformBrickletMultiTouchElectrode3Getter0(value, cfg));
        }
                   return;
            case "BrickletMultiTouchElectrode4":
                   {
            int value = this.getTouchState();
            if(true)
                updateStateFn.accept(channel, transformBrickletMultiTouchElectrode4Getter0(value, cfg));
        }
                   return;
            case "BrickletMultiTouchElectrode5":
                   {
            int value = this.getTouchState();
            if(true)
                updateStateFn.accept(channel, transformBrickletMultiTouchElectrode5Getter0(value, cfg));
        }
                   return;
            case "BrickletMultiTouchElectrode6":
                   {
            int value = this.getTouchState();
            if(true)
                updateStateFn.accept(channel, transformBrickletMultiTouchElectrode6Getter0(value, cfg));
        }
                   return;
            case "BrickletMultiTouchElectrode7":
                   {
            int value = this.getTouchState();
            if(true)
                updateStateFn.accept(channel, transformBrickletMultiTouchElectrode7Getter0(value, cfg));
        }
                   return;
            case "BrickletMultiTouchElectrode8":
                   {
            int value = this.getTouchState();
            if(true)
                updateStateFn.accept(channel, transformBrickletMultiTouchElectrode8Getter0(value, cfg));
        }
                   return;
            case "BrickletMultiTouchElectrode9":
                   {
            int value = this.getTouchState();
            if(true)
                updateStateFn.accept(channel, transformBrickletMultiTouchElectrode9Getter0(value, cfg));
        }
                   return;
            case "BrickletMultiTouchElectrode10":
                   {
            int value = this.getTouchState();
            if(true)
                updateStateFn.accept(channel, transformBrickletMultiTouchElectrode10Getter0(value, cfg));
        }
                   return;
            case "BrickletMultiTouchElectrode11":
                   {
            int value = this.getTouchState();
            if(true)
                updateStateFn.accept(channel, transformBrickletMultiTouchElectrode11Getter0(value, cfg));
        }
                   return;
            case "BrickletMultiTouchProximity":
                   {
            int value = this.getTouchState();
            if(true)
                updateStateFn.accept(channel, transformBrickletMultiTouchProximityGetter0(value, cfg));
        }
                   return;
            case "BrickletMultiTouchRecalibrate":
               return;
default:
                logger.warn("Refresh for unknown channel {}", channel);
                break;
        }
    }
    

        @Override
    public List<SetterRefresh> handleCommand(org.eclipse.smarthome.config.core.Configuration config, org.eclipse.smarthome.config.core.Configuration channelConfig, String channel, Command command) throws TinkerforgeException {
        List<SetterRefresh> result = Collections.emptyList();
        
        switch(channel) {
            case "BrickletMultiTouchRecalibrate":
                if (command instanceof StringType) {
                    this.recalibrate();
                }
        
                else {
                    logger.warn("Command type {} not supported for channel {}. Please use one of StringType.", command.getClass().getName(), channel);
                }
                
                break;
default:
                logger.warn("Command for unknown channel {}", channel);
        }
        return result;
    }

        private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode0Callback0(int state, BrickletMultiTouchConfig cfg) {
        return (state & (1 << 0)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode1Callback0(int state, BrickletMultiTouchConfig cfg) {
        return (state & (1 << 1)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode2Callback0(int state, BrickletMultiTouchConfig cfg) {
        return (state & (1 << 2)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode3Callback0(int state, BrickletMultiTouchConfig cfg) {
        return (state & (1 << 3)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode4Callback0(int state, BrickletMultiTouchConfig cfg) {
        return (state & (1 << 4)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode5Callback0(int state, BrickletMultiTouchConfig cfg) {
        return (state & (1 << 5)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode6Callback0(int state, BrickletMultiTouchConfig cfg) {
        return (state & (1 << 6)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode7Callback0(int state, BrickletMultiTouchConfig cfg) {
        return (state & (1 << 7)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode8Callback0(int state, BrickletMultiTouchConfig cfg) {
        return (state & (1 << 8)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode9Callback0(int state, BrickletMultiTouchConfig cfg) {
        return (state & (1 << 9)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode10Callback0(int state, BrickletMultiTouchConfig cfg) {
        return (state & (1 << 10)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode11Callback0(int state, BrickletMultiTouchConfig cfg) {
        return (state & (1 << 11)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchProximityCallback0(int state, BrickletMultiTouchConfig cfg) {
        return (state & (1 << 12)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode0Getter0(int value, BrickletMultiTouchConfig cfg) {
        return (value & (1 << 0)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode1Getter0(int value, BrickletMultiTouchConfig cfg) {
        return (value & (1 << 1)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode2Getter0(int value, BrickletMultiTouchConfig cfg) {
        return (value & (1 << 2)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode3Getter0(int value, BrickletMultiTouchConfig cfg) {
        return (value & (1 << 3)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode4Getter0(int value, BrickletMultiTouchConfig cfg) {
        return (value & (1 << 4)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode5Getter0(int value, BrickletMultiTouchConfig cfg) {
        return (value & (1 << 5)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode6Getter0(int value, BrickletMultiTouchConfig cfg) {
        return (value & (1 << 6)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode7Getter0(int value, BrickletMultiTouchConfig cfg) {
        return (value & (1 << 7)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode8Getter0(int value, BrickletMultiTouchConfig cfg) {
        return (value & (1 << 8)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode9Getter0(int value, BrickletMultiTouchConfig cfg) {
        return (value & (1 << 9)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode10Getter0(int value, BrickletMultiTouchConfig cfg) {
        return (value & (1 << 10)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchElectrode11Getter0(int value, BrickletMultiTouchConfig cfg) {
        return (value & (1 << 11)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletMultiTouchProximityGetter0(int value, BrickletMultiTouchConfig cfg) {
        return (value & (1 << 12)) > 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
    }

}