/**
 * 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.OnOffType;

import com.tinkerforge.BrickletParticulateMatter;
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 Particulate Matter Bricklet.
 * @author Erik Fleckstein - Initial contribution
 */
@NonNullByDefault
public class BrickletParticulateMatterWrapper extends BrickletParticulateMatter implements CoMCUFlashable, DeviceWrapper {
    public static final DeviceInfo DEVICE_INFO = new DeviceInfo(BrickletParticulateMatter.DEVICE_DISPLAY_NAME, "brickletparticulatematter", BrickletParticulateMatter.DEVICE_IDENTIFIER, BrickletParticulateMatterWrapper.class, BrickletParticulateMatterActions.class, "2.0.0", true);

    public BrickletParticulateMatterWrapper(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(BrickletParticulateMatterWrapper.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);
        BrickletParticulateMatterConfig cfg = (BrickletParticulateMatterConfig) config.as(BrickletParticulateMatterConfig.class);
        this.addPMConcentrationListener(this.reg((pm10, pm25, pm100) -> {if(true) {updateStateFn.accept("BrickletParticulateMatterPM10Concentration", transformBrickletParticulateMatterPM10ConcentrationCallback0(pm10, pm25, pm100, cfg));}}, this::removePMConcentrationListener));
		this.addPMConcentrationListener(this.reg((pm10, pm25, pm100) -> {if(true) {updateStateFn.accept("BrickletParticulateMatterPM25Concentration", transformBrickletParticulateMatterPM25ConcentrationCallback0(pm10, pm25, pm100, cfg));}}, this::removePMConcentrationListener));
		this.addPMConcentrationListener(this.reg((pm10, pm25, pm100) -> {if(true) {updateStateFn.accept("BrickletParticulateMatterPM100Concentration", transformBrickletParticulateMatterPM100ConcentrationCallback0(pm10, pm25, pm100, cfg));}}, this::removePMConcentrationListener));
		this.addPMCountListener(this.reg((greater03um, greater05um, greater10um, greater25um, greater50um, greater100um) -> {if(true) {updateStateFn.accept("BrickletParticulateMatterPartCount3", transformBrickletParticulateMatterPartCount3Callback0(greater03um, greater05um, greater10um, greater25um, greater50um, greater100um, cfg));}}, this::removePMCountListener));
		this.addPMCountListener(this.reg((greater03um, greater05um, greater10um, greater25um, greater50um, greater100um) -> {if(true) {updateStateFn.accept("BrickletParticulateMatterPartCount5", transformBrickletParticulateMatterPartCount5Callback0(greater03um, greater05um, greater10um, greater25um, greater50um, greater100um, cfg));}}, this::removePMCountListener));
		this.addPMCountListener(this.reg((greater03um, greater05um, greater10um, greater25um, greater50um, greater100um) -> {if(true) {updateStateFn.accept("BrickletParticulateMatterPartCount10", transformBrickletParticulateMatterPartCount10Callback0(greater03um, greater05um, greater10um, greater25um, greater50um, greater100um, cfg));}}, this::removePMCountListener));
		this.addPMCountListener(this.reg((greater03um, greater05um, greater10um, greater25um, greater50um, greater100um) -> {if(true) {updateStateFn.accept("BrickletParticulateMatterPartCount25", transformBrickletParticulateMatterPartCount25Callback0(greater03um, greater05um, greater10um, greater25um, greater50um, greater100um, cfg));}}, this::removePMCountListener));
		this.addPMCountListener(this.reg((greater03um, greater05um, greater10um, greater25um, greater50um, greater100um) -> {if(true) {updateStateFn.accept("BrickletParticulateMatterPartCount50", transformBrickletParticulateMatterPartCount50Callback0(greater03um, greater05um, greater10um, greater25um, greater50um, greater100um, cfg));}}, this::removePMCountListener));
		this.addPMCountListener(this.reg((greater03um, greater05um, greater10um, greater25um, greater50um, greater100um) -> {if(true) {updateStateFn.accept("BrickletParticulateMatterPartCount100", transformBrickletParticulateMatterPartCount100Callback0(greater03um, greater05um, greater10um, greater25um, greater50um, greater100um, cfg));}}, this::removePMCountListener));
        this.setPMCountCallbackConfiguration(cfg.pmCountUpdateInterval, true);
		        this.setPMConcentrationCallbackConfiguration(cfg.pmConcentrationUpdateInterval, true);
		this.setStatusLEDConfig(cfg.statusLEDConfig);
    }

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

        
        this.setPMCountCallbackConfiguration(0, true);
		        this.setPMConcentrationCallbackConfiguration(0, true);
    }

    @Override
    public List<String> getEnabledChannels(org.eclipse.smarthome.config.core.Configuration config) throws TinkerforgeException{
        List<String> result = new ArrayList<String>();
        result.add("BrickletParticulateMatterPM10Concentration");
		result.add("BrickletParticulateMatterPM25Concentration");
		result.add("BrickletParticulateMatterPM100Concentration");
		result.add("BrickletParticulateMatterPartCount3");
		result.add("BrickletParticulateMatterPartCount5");
		result.add("BrickletParticulateMatterPartCount10");
		result.add("BrickletParticulateMatterPartCount25");
		result.add("BrickletParticulateMatterPartCount50");
		result.add("BrickletParticulateMatterPartCount100");
		result.add("BrickletParticulateMatterSensorEnabled");
        return result;
    }

    public static @Nullable ChannelType getChannelType(ChannelTypeUID channelTypeUID) {
        switch(channelTypeUID.getId()) {
            case "BrickletParticulateMatterPM10Concentration":
                return ChannelTypeBuilder.state(new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterPM10Concentration"), "PM 1.0 Concentration", "Number:Density").withConfigDescriptionURI(URI.create("channel-type:tinkerforge:BrickletParticulateMatterPM10Concentration")).withDescription("The particulate matter 1.0 concentration. If the sensor is disabled then the last known good values from the sensor are returned.")
.withStateDescription(StateDescriptionFragmentBuilder.create().withPattern("%d %unit%").withReadOnly(true).build().toStateDescription()).build();
            case "BrickletParticulateMatterPM25Concentration":
                return ChannelTypeBuilder.state(new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterPM25Concentration"), "PM 2.5 Concentration", "Number:Density").withConfigDescriptionURI(URI.create("channel-type:tinkerforge:BrickletParticulateMatterPM25Concentration")).withDescription("The particulate matter 2.5 concentration. If the sensor is disabled then the last known good values from the sensor are returned.")
.withStateDescription(StateDescriptionFragmentBuilder.create().withPattern("%d %unit%").withReadOnly(true).build().toStateDescription()).build();
            case "BrickletParticulateMatterPM100Concentration":
                return ChannelTypeBuilder.state(new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterPM100Concentration"), "PM 10.0 Concentration", "Number:Density").withConfigDescriptionURI(URI.create("channel-type:tinkerforge:BrickletParticulateMatterPM100Concentration")).withDescription("The particulate matter 10.0 concentration. If the sensor is disabled then the last known good values from the sensor are returned.")
.withStateDescription(StateDescriptionFragmentBuilder.create().withPattern("%d %unit%").withReadOnly(true).build().toStateDescription()).build();
            case "BrickletParticulateMatterPartCount3":
                return ChannelTypeBuilder.state(new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterPartCount3"), "Particulates Greater 0.3µm", "Number:Dimensionless").withConfigDescriptionURI(URI.create("channel-type:tinkerforge:BrickletParticulateMatterPartCount3")).withDescription("The number of particulates greater than 0.3µm in 100 ml of air. If the sensor is disabled then the last known good values from the sensor are returned.")
.withStateDescription(StateDescriptionFragmentBuilder.create().withPattern("%d").withReadOnly(true).build().toStateDescription()).build();
            case "BrickletParticulateMatterPartCount5":
                return ChannelTypeBuilder.state(new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterPartCount5"), "Particulates Greater 0.5µm", "Number:Dimensionless").withConfigDescriptionURI(URI.create("channel-type:tinkerforge:BrickletParticulateMatterPartCount5")).withDescription("The number of particulates greater than 0.5µm in 100 ml of air. If the sensor is disabled then the last known good values from the sensor are returned.")
.withStateDescription(StateDescriptionFragmentBuilder.create().withPattern("%d").withReadOnly(true).build().toStateDescription()).build();
            case "BrickletParticulateMatterPartCount10":
                return ChannelTypeBuilder.state(new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterPartCount10"), "Particulates Greater 1.0µm", "Number:Dimensionless").withConfigDescriptionURI(URI.create("channel-type:tinkerforge:BrickletParticulateMatterPartCount10")).withDescription("The number of particulates greater than 1.0µm in 100 ml of air. If the sensor is disabled then the last known good values from the sensor are returned.")
.withStateDescription(StateDescriptionFragmentBuilder.create().withPattern("%d").withReadOnly(true).build().toStateDescription()).build();
            case "BrickletParticulateMatterPartCount25":
                return ChannelTypeBuilder.state(new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterPartCount25"), "Particulates Greater 2.5µm", "Number:Dimensionless").withConfigDescriptionURI(URI.create("channel-type:tinkerforge:BrickletParticulateMatterPartCount25")).withDescription("The number of particulates greater than 2.5µm in 100 ml of air. If the sensor is disabled then the last known good values from the sensor are returned.")
.withStateDescription(StateDescriptionFragmentBuilder.create().withPattern("%d").withReadOnly(true).build().toStateDescription()).build();
            case "BrickletParticulateMatterPartCount50":
                return ChannelTypeBuilder.state(new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterPartCount50"), "Particulates Greater 5.0µm", "Number:Dimensionless").withConfigDescriptionURI(URI.create("channel-type:tinkerforge:BrickletParticulateMatterPartCount50")).withDescription("The number of particulates greater than 5.0µm in 100 ml of air. If the sensor is disabled then the last known good values from the sensor are returned.")
.withStateDescription(StateDescriptionFragmentBuilder.create().withPattern("%d").withReadOnly(true).build().toStateDescription()).build();
            case "BrickletParticulateMatterPartCount100":
                return ChannelTypeBuilder.state(new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterPartCount100"), "Particulates Greater 10.0µm", "Number:Dimensionless").withConfigDescriptionURI(URI.create("channel-type:tinkerforge:BrickletParticulateMatterPartCount100")).withDescription("The number of particulates greater than 10.0µm in 100 ml of air. If the sensor is disabled then the last known good values from the sensor are returned.")
.withStateDescription(StateDescriptionFragmentBuilder.create().withPattern("%d").withReadOnly(true).build().toStateDescription()).build();
            case "BrickletParticulateMatterSensorEnabled":
                return ChannelTypeBuilder.state(new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterSensorEnabled"), "NOT USED", "Switch").withConfigDescriptionURI(URI.create("channel-type:tinkerforge:BrickletParticulateMatterSensorEnabled")).withDescription("NOT USED").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 Particulate Matter Bricklet").isListed(false).withSupportedBridgeTypeUIDs(Arrays.asList(TinkerforgeBindingConstants.THING_TYPE_BRICK_DAEMON.toString())).withConfigDescriptionURI(URI.create("thing-type:tinkerforge:" + thingTypeUID.getId())).withDescription("Measures Particulate Matter concentration (PM1.0, PM2.5 and PM10)").withChannelDefinitions(Arrays.asList(new ChannelDefinitionBuilder("BrickletParticulateMatterPM10Concentration", new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterPM10Concentration")).withLabel("PM 1.0 Concentration").build(), new ChannelDefinitionBuilder("BrickletParticulateMatterPM25Concentration", new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterPM25Concentration")).withLabel("PM 2.5 Concentration").build(), new ChannelDefinitionBuilder("BrickletParticulateMatterPM100Concentration", new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterPM100Concentration")).withLabel("PM 10.0 Concentration").build(), new ChannelDefinitionBuilder("BrickletParticulateMatterPartCount3", new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterPartCount3")).withLabel("Particulates Greater 0.3µm").build(), new ChannelDefinitionBuilder("BrickletParticulateMatterPartCount5", new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterPartCount5")).withLabel("Particulates Greater 0.5µm").build(), new ChannelDefinitionBuilder("BrickletParticulateMatterPartCount10", new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterPartCount10")).withLabel("Particulates Greater 1.0µm").build(), new ChannelDefinitionBuilder("BrickletParticulateMatterPartCount25", new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterPartCount25")).withLabel("Particulates Greater 2.5µm").build(), new ChannelDefinitionBuilder("BrickletParticulateMatterPartCount50", new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterPartCount50")).withLabel("Particulates Greater 5.0µm").build(), new ChannelDefinitionBuilder("BrickletParticulateMatterPartCount100", new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterPartCount100")).withLabel("Particulates Greater 10.0µm").build(), new ChannelDefinitionBuilder("BrickletParticulateMatterSensorEnabled", new ChannelTypeUID("tinkerforge", "BrickletParticulateMatterSensorEnabled")).withLabel("Sensor Enabled").withDescription("Enables/Disables the fan and the laser diode of the sensors.<br/><br/>The sensor takes about 30 seconds after it is enabled to settle and produce stable values.<br/><br/>The laser diode has a lifetime of about 8000 hours. If you want to measure in an interval with a long idle time (e.g. hourly) you should turn the laser diode off between the measurements.").build())).withProperties(props).build();
    }

    public static @Nullable ConfigDescription getConfigDescription(URI uri) {
        switch(uri.toASCIIString()) {
            case "thing-type:tinkerforge:brickletparticulatematter":
                return ConfigDescriptionBuilder.create(uri).withParameters(Arrays.asList(ConfigDescriptionParameterBuilder.create("pmConcentrationUpdateInterval", Type.INTEGER).withDefault("1000").withDescription("Specifies the update interval for all PM concentration data in milliseconds. A value of 0 disables automatic updates.").withGroupName("update_intervals").withLabel("PM Concentration Update Interval").withUnit("ms").withMinimum(BigDecimal.valueOf(0)).withMaximum(BigDecimal.valueOf(4294967295L)).build(), ConfigDescriptionParameterBuilder.create("pmCountUpdateInterval", Type.INTEGER).withDefault("1000").withDescription("Specifies the update interval for all PM count data in milliseconds. A value of 0 disables automatic updates.").withGroupName("update_intervals").withLabel("PM Count Update Interval").withUnit("ms").withMinimum(BigDecimal.valueOf(0)).withMaximum(BigDecimal.valueOf(4294967295L)).build(), ConfigDescriptionParameterBuilder.create("statusLEDConfig", Type.INTEGER).withDefault("3").withDescription("The status LED configuration. By default the LED shows communication traffic between Brick and Bricklet, it flickers once for every 10 received data packets.<br/><br/>You can also turn the LED permanently on/off or show a heartbeat.<br/><br/>If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.").withLabel("Status LED Configuration").withAdvanced(true).withLimitToOptions(true).withOptions(Arrays.asList(new ParameterOption("0", "Off"), new ParameterOption("1", "On"), new ParameterOption("2", "Show Heartbeat"), new ParameterOption("3", "Show Status"))).build())).withParameterGroups(Arrays.asList(new ConfigDescriptionParameterGroup("update_intervals", "null", true, "Update Intervals", "Update Intervals"))).build();
            case "channel-type:tinkerforge:BrickletParticulateMatterPM10Concentration":
                return ConfigDescriptionBuilder.create(uri).withParameters(Arrays.asList()).withParameterGroups(Arrays.asList()).build();
            case "channel-type:tinkerforge:BrickletParticulateMatterPM25Concentration":
                return ConfigDescriptionBuilder.create(uri).withParameters(Arrays.asList()).withParameterGroups(Arrays.asList()).build();
            case "channel-type:tinkerforge:BrickletParticulateMatterPM100Concentration":
                return ConfigDescriptionBuilder.create(uri).withParameters(Arrays.asList()).withParameterGroups(Arrays.asList()).build();
            case "channel-type:tinkerforge:BrickletParticulateMatterPartCount3":
                return ConfigDescriptionBuilder.create(uri).withParameters(Arrays.asList()).withParameterGroups(Arrays.asList()).build();
            case "channel-type:tinkerforge:BrickletParticulateMatterPartCount5":
                return ConfigDescriptionBuilder.create(uri).withParameters(Arrays.asList()).withParameterGroups(Arrays.asList()).build();
            case "channel-type:tinkerforge:BrickletParticulateMatterPartCount10":
                return ConfigDescriptionBuilder.create(uri).withParameters(Arrays.asList()).withParameterGroups(Arrays.asList()).build();
            case "channel-type:tinkerforge:BrickletParticulateMatterPartCount25":
                return ConfigDescriptionBuilder.create(uri).withParameters(Arrays.asList()).withParameterGroups(Arrays.asList()).build();
            case "channel-type:tinkerforge:BrickletParticulateMatterPartCount50":
                return ConfigDescriptionBuilder.create(uri).withParameters(Arrays.asList()).withParameterGroups(Arrays.asList()).build();
            case "channel-type:tinkerforge:BrickletParticulateMatterPartCount100":
                return ConfigDescriptionBuilder.create(uri).withParameters(Arrays.asList()).withParameterGroups(Arrays.asList()).build();
            case "channel-type:tinkerforge:BrickletParticulateMatterSensorEnabled":
                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 {
        BrickletParticulateMatterConfig cfg = (BrickletParticulateMatterConfig) config.as(BrickletParticulateMatterConfig.class);
switch(channel) {
            case "BrickletParticulateMatterPM10Concentration":
                   {
            BrickletParticulateMatter.PMConcentration value = this.getPMConcentration();
            if(true)
                updateStateFn.accept(channel, transformBrickletParticulateMatterPM10ConcentrationGetter0(value, cfg));
        }
                   return;
            case "BrickletParticulateMatterPM25Concentration":
                   {
            BrickletParticulateMatter.PMConcentration value = this.getPMConcentration();
            if(true)
                updateStateFn.accept(channel, transformBrickletParticulateMatterPM25ConcentrationGetter0(value, cfg));
        }
                   return;
            case "BrickletParticulateMatterPM100Concentration":
                   {
            BrickletParticulateMatter.PMConcentration value = this.getPMConcentration();
            if(true)
                updateStateFn.accept(channel, transformBrickletParticulateMatterPM100ConcentrationGetter0(value, cfg));
        }
                   return;
            case "BrickletParticulateMatterPartCount3":
                   {
            BrickletParticulateMatter.PMCount value = this.getPMCount();
            if(true)
                updateStateFn.accept(channel, transformBrickletParticulateMatterPartCount3Getter0(value, cfg));
        }
                   return;
            case "BrickletParticulateMatterPartCount5":
                   {
            BrickletParticulateMatter.PMCount value = this.getPMCount();
            if(true)
                updateStateFn.accept(channel, transformBrickletParticulateMatterPartCount5Getter0(value, cfg));
        }
                   return;
            case "BrickletParticulateMatterPartCount10":
                   {
            BrickletParticulateMatter.PMCount value = this.getPMCount();
            if(true)
                updateStateFn.accept(channel, transformBrickletParticulateMatterPartCount10Getter0(value, cfg));
        }
                   return;
            case "BrickletParticulateMatterPartCount25":
                   {
            BrickletParticulateMatter.PMCount value = this.getPMCount();
            if(true)
                updateStateFn.accept(channel, transformBrickletParticulateMatterPartCount25Getter0(value, cfg));
        }
                   return;
            case "BrickletParticulateMatterPartCount50":
                   {
            BrickletParticulateMatter.PMCount value = this.getPMCount();
            if(true)
                updateStateFn.accept(channel, transformBrickletParticulateMatterPartCount50Getter0(value, cfg));
        }
                   return;
            case "BrickletParticulateMatterPartCount100":
                   {
            BrickletParticulateMatter.PMCount value = this.getPMCount();
            if(true)
                updateStateFn.accept(channel, transformBrickletParticulateMatterPartCount100Getter0(value, cfg));
        }
                   return;
            case "BrickletParticulateMatterSensorEnabled":
                   {
            boolean value = this.getEnable();
            if(true)
                updateStateFn.accept(channel, transformBrickletParticulateMatterSensorEnabledGetter0(value, cfg));
        }
                   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 "BrickletParticulateMatterSensorEnabled":
                if (command instanceof OnOffType) {
                    OnOffType cmd = (OnOffType) command;
this.setEnable(cmd == OnOffType.ON);
                }
        
                else {
                    logger.warn("Command type {} not supported for channel {}. Please use one of OnOffType.", command.getClass().getName(), channel);
                }
                
                break;
default:
                logger.warn("Command for unknown channel {}", channel);
        }
        return result;
    }

        private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterPM10ConcentrationCallback0(int pm10, int pm25, int pm100, BrickletParticulateMatterConfig cfg) {
        return new QuantityType<>(pm10, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterPM25ConcentrationCallback0(int pm10, int pm25, int pm100, BrickletParticulateMatterConfig cfg) {
        return new QuantityType<>(pm25, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterPM100ConcentrationCallback0(int pm10, int pm25, int pm100, BrickletParticulateMatterConfig cfg) {
        return new QuantityType<>(pm100, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterPartCount3Callback0(int greater03um, int greater05um, int greater10um, int greater25um, int greater50um, int greater100um, BrickletParticulateMatterConfig cfg) {
        return new DecimalType(greater03um);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterPartCount5Callback0(int greater03um, int greater05um, int greater10um, int greater25um, int greater50um, int greater100um, BrickletParticulateMatterConfig cfg) {
        return new DecimalType(greater05um);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterPartCount10Callback0(int greater03um, int greater05um, int greater10um, int greater25um, int greater50um, int greater100um, BrickletParticulateMatterConfig cfg) {
        return new DecimalType(greater10um);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterPartCount25Callback0(int greater03um, int greater05um, int greater10um, int greater25um, int greater50um, int greater100um, BrickletParticulateMatterConfig cfg) {
        return new DecimalType(greater25um);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterPartCount50Callback0(int greater03um, int greater05um, int greater10um, int greater25um, int greater50um, int greater100um, BrickletParticulateMatterConfig cfg) {
        return new DecimalType(greater50um);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterPartCount100Callback0(int greater03um, int greater05um, int greater10um, int greater25um, int greater50um, int greater100um, BrickletParticulateMatterConfig cfg) {
        return new DecimalType(greater100um);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterPM10ConcentrationGetter0(BrickletParticulateMatter.PMConcentration value, BrickletParticulateMatterConfig cfg) {
        return new QuantityType<>(value.pm10, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterPM25ConcentrationGetter0(BrickletParticulateMatter.PMConcentration value, BrickletParticulateMatterConfig cfg) {
        return new QuantityType<>(value.pm25, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterPM100ConcentrationGetter0(BrickletParticulateMatter.PMConcentration value, BrickletParticulateMatterConfig cfg) {
        return new QuantityType<>(value.pm100, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterPartCount3Getter0(BrickletParticulateMatter.PMCount value, BrickletParticulateMatterConfig cfg) {
        return new DecimalType(value.greater03um);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterPartCount5Getter0(BrickletParticulateMatter.PMCount value, BrickletParticulateMatterConfig cfg) {
        return new DecimalType(value.greater05um);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterPartCount10Getter0(BrickletParticulateMatter.PMCount value, BrickletParticulateMatterConfig cfg) {
        return new DecimalType(value.greater10um);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterPartCount25Getter0(BrickletParticulateMatter.PMCount value, BrickletParticulateMatterConfig cfg) {
        return new DecimalType(value.greater25um);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterPartCount50Getter0(BrickletParticulateMatter.PMCount value, BrickletParticulateMatterConfig cfg) {
        return new DecimalType(value.greater50um);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterPartCount100Getter0(BrickletParticulateMatter.PMCount value, BrickletParticulateMatterConfig cfg) {
        return new DecimalType(value.greater100um);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletParticulateMatterSensorEnabledGetter0(boolean value, BrickletParticulateMatterConfig cfg) {
        return value ? OnOffType.ON : OnOffType.OFF;
    }

}