/**
 * 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.thing.CommonTriggerEvents;
import org.eclipse.smarthome.core.library.types.StringType;
import org.eclipse.smarthome.core.library.types.DateTimeType;
import java.util.stream.Collectors;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;

import com.tinkerforge.BrickletNFC;
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 NFC Bricklet.
 * @author Erik Fleckstein - Initial contribution
 */
@NonNullByDefault
public class BrickletNFCWrapper extends BrickletNFC implements CoMCUFlashable, DeviceWrapper {
    public static final DeviceInfo DEVICE_INFO = new DeviceInfo(BrickletNFC.DEVICE_DISPLAY_NAME, "brickletnfc", BrickletNFC.DEVICE_IDENTIFIER, BrickletNFCWrapper.class, BrickletNFCActions.class, "2.0.6", true);

    public BrickletNFCWrapper(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(BrickletNFCWrapper.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);
        BrickletNFCConfig cfg = (BrickletNFCConfig) config.as(BrickletNFCConfig.class);
        if(cfg.mode != 4) {
this.addReaderStateChangedListener(this.reg((state, idle) -> {if(true) {updateStateFn.accept("BrickletNFCState", transformBrickletNFCStateCallback0(state, idle, cfg));}}, this::removeReaderStateChangedListener));}
		if(cfg.mode != 4) {
this.addCardemuStateChangedListener(this.reg((state, idle) -> {if(true) {updateStateFn.accept("BrickletNFCState", transformBrickletNFCStateCallback1(state, idle, cfg));}}, this::removeCardemuStateChangedListener));}
		if(cfg.mode != 4) {
this.addP2PStateChangedListener(this.reg((state, idle) -> {if(true) {updateStateFn.accept("BrickletNFCState", transformBrickletNFCStateCallback2(state, idle, cfg));}}, this::removeP2PStateChangedListener));}
        this.setMode(cfg.mode);
		    this.setDetectionLEDConfig(cfg.detectionLEDConfig);
		    this.setMaximumTimeout(cfg.maximumTimeout);
		this.setStatusLEDConfig(cfg.statusLEDConfig);
		if (cfg.mode == 4) {
		BrickletNFCTagIDConfig channelCfg = getChannelConfigFn.apply("BrickletNFCLastTagID").as(BrickletNFCTagIDConfig.class);
		
		if(channelCfg.updateInterval > 0) {
    this.manualChannelUpdates.add(scheduler.scheduleWithFixedDelay(() -> {if(handler.getThing().getStatus() == ThingStatus.ONLINE) {handler.handleCommand(new ChannelUID(handler.getThing().getUID(), "BrickletNFCLastTagID"), RefreshType.REFRESH);}}, channelCfg.updateInterval, channelCfg.updateInterval, TimeUnit.MILLISECONDS));
}
		}
		if (cfg.mode == 4) {
		BrickletNFCTagTypeConfig channelCfg = getChannelConfigFn.apply("BrickletNFCLastTagType").as(BrickletNFCTagTypeConfig.class);
		
		if(channelCfg.updateInterval > 0) {
    this.manualChannelUpdates.add(scheduler.scheduleWithFixedDelay(() -> {if(handler.getThing().getStatus() == ThingStatus.ONLINE) {handler.handleCommand(new ChannelUID(handler.getThing().getUID(), "BrickletNFCLastTagType"), RefreshType.REFRESH);}}, channelCfg.updateInterval, channelCfg.updateInterval, TimeUnit.MILLISECONDS));
}
		}
		if (cfg.mode == 4) {
		BrickletNFCTagLastSeenConfig channelCfg = getChannelConfigFn.apply("BrickletNFCLastTagSeen").as(BrickletNFCTagLastSeenConfig.class);
		
		if(channelCfg.updateInterval > 0) {
    this.manualChannelUpdates.add(scheduler.scheduleWithFixedDelay(() -> {if(handler.getThing().getStatus() == ThingStatus.ONLINE) {handler.handleCommand(new ChannelUID(handler.getThing().getUID(), "BrickletNFCLastTagSeen"), RefreshType.REFRESH);}}, channelCfg.updateInterval, channelCfg.updateInterval, TimeUnit.MILLISECONDS));
}
		}
    }

    @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{
        BrickletNFCConfig cfg = (BrickletNFCConfig) config.as(BrickletNFCConfig.class);
List<String> result = new ArrayList<String>();
        if (cfg.mode != 4) {
                result.add("BrickletNFCState");
            }
		if (cfg.mode == 4) {
                result.add("BrickletNFCLastTagID");
            }
		if (cfg.mode == 4) {
                result.add("BrickletNFCLastTagType");
            }
		if (cfg.mode == 4) {
                result.add("BrickletNFCLastTagSeen");
            }
        return result;
    }

    public static @Nullable ChannelType getChannelType(ChannelTypeUID channelTypeUID) {
        switch(channelTypeUID.getId()) {
            case "BrickletNFCState":
                return ChannelTypeBuilder.state(new ChannelTypeUID("tinkerforge", "BrickletNFCState"), "State", "Number").withConfigDescriptionURI(URI.create("channel-type:tinkerforge:BrickletNFCState")).withDescription("The current state of the bricklet. The meaning of the state depends on the configured mode. Calling actions is only allowed in idle, ready and error states (e.g. all states >= 128). The following states are defined:<br/><br/>Reader:<ul><li>READER_STATE_INITIALIZATION = 0</li><li>READER_STATE_IDLE = 128</li><li>READER_STATE_ERROR = 192</li><li>READER_STATE_REQUEST_TAG_ID = 2</li><li>READER_STATE_REQUEST_TAG_ID_READY = 130</li><li>READER_STATE_REQUEST_TAG_ID_ERROR = 194</li><li>READER_STATE_AUTHENTICATE_MIFARE_CLASSIC_PAGE = 3</li><li>READER_STATE_AUTHENTICATE_MIFARE_CLASSIC_PAGE_READY = 131</li><li>READER_STATE_AUTHENTICATE_MIFARE_CLASSIC_PAGE_ERROR = 195</li><li>READER_STATE_WRITE_PAGE = 4</li><li>READER_STATE_WRITE_PAGE_READY = 132</li><li>READER_STATE_WRITE_PAGE_ERROR = 196</li><li>READER_STATE_REQUEST_PAGE = 5</li><li>READER_STATE_REQUEST_PAGE_READY = 133</li><li>READER_STATE_REQUEST_PAGE_ERROR = 197</li><li>READER_STATE_WRITE_NDEF = 6</li><li>READER_STATE_WRITE_NDEF_READY = 134</li><li>READER_STATE_WRITE_NDEF_ERROR = 198</li><li>READER_STATE_REQUEST_NDEF = 7</li><li>READER_STATE_REQUEST_NDEF_READY = 135</li><li>READER_STATE_REQUEST_NDEF_ERROR = 199</li></ul><br/>Cardemu:<ul><li>CARDEMU_STATE_INITIALIZATION = 0</li><li>CARDEMU_STATE_IDLE = 128</li><li>CARDEMU_STATE_ERROR = 192</li><li>CARDEMU_STATE_DISCOVER = 2</li><li>CARDEMU_STATE_DISCOVER_READY = 130</li><li>CARDEMU_STATE_DISCOVER_ERROR = 194</li><li>CARDEMU_STATE_TRANSFER_NDEF = 3</li><li>CARDEMU_STATE_TRANSFER_NDEF_READY = 131</li><li>CARDEMU_STATE_TRANSFER_NDEF_ERROR = 195</li></ul><br/>P2P:<ul><li>P2P_STATE_INITIALIZATION = 0</li><li>P2P_STATE_IDLE = 128</li><li>P2P_STATE_ERROR = 192</li><li>P2P_STATE_DISCOVER = 2</li><li>P2P_STATE_DISCOVER_READY = 130</li><li>P2P_STATE_DISCOVER_ERROR = 194</li><li>P2P_STATE_TRANSFER_NDEF = 3</li><li>P2P_STATE_TRANSFER_NDEF_READY = 131</li><li>P2P_STATE_TRANSFER_NDEF_ERROR = 195</li></ul>")
.withStateDescription(StateDescriptionFragmentBuilder.create().withPattern("%d %unit%").withReadOnly(true).build().toStateDescription()).build();
            case "BrickletNFCTagID":
                return ChannelTypeBuilder.state(new ChannelTypeUID("tinkerforge", "BrickletNFCTagID"), "Tag ID", "String").withConfigDescriptionURI(URI.create("channel-type:tinkerforge:BrickletNFCTagID")).withDescription("blah").build();
            case "BrickletNFCTagType":
                return ChannelTypeBuilder.state(new ChannelTypeUID("tinkerforge", "BrickletNFCTagType"), "Tag Type", "Number:Dimensionless").withConfigDescriptionURI(URI.create("channel-type:tinkerforge:BrickletNFCTagType")).withDescription("blah")
.withStateDescription(StateDescriptionFragmentBuilder.create().withPattern("%d").withReadOnly(true).build().toStateDescription()).build();
            case "BrickletNFCTagLastSeen":
                return ChannelTypeBuilder.state(new ChannelTypeUID("tinkerforge", "BrickletNFCTagLastSeen"), "Tag Last Seen", "DateTime").withConfigDescriptionURI(URI.create("channel-type:tinkerforge:BrickletNFCTagLastSeen")).withDescription("").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 NFC Bricklet").isListed(false).withSupportedBridgeTypeUIDs(Arrays.asList(TinkerforgeBindingConstants.THING_TYPE_BRICK_DAEMON.toString())).withConfigDescriptionURI(URI.create("thing-type:tinkerforge:" + thingTypeUID.getId())).withDescription("NFC tag read/write, NFC P2P and Card Emulation").withChannelDefinitions(Arrays.asList(new ChannelDefinitionBuilder("BrickletNFCState", new ChannelTypeUID("tinkerforge", "BrickletNFCState")).withLabel("State").build(), new ChannelDefinitionBuilder("BrickletNFCLastTagID", new ChannelTypeUID("tinkerforge", "BrickletNFCTagID")).withLabel("Tag ID").build(), new ChannelDefinitionBuilder("BrickletNFCLastTagType", new ChannelTypeUID("tinkerforge", "BrickletNFCTagType")).withLabel("Tag Type").build(), new ChannelDefinitionBuilder("BrickletNFCLastTagSeen", new ChannelTypeUID("tinkerforge", "BrickletNFCTagLastSeen")).withLabel("Tag Last Seen").build())).withProperties(props).build();
    }

    public static @Nullable ConfigDescription getConfigDescription(URI uri) {
        switch(uri.toASCIIString()) {
            case "thing-type:tinkerforge:brickletnfc":
                return ConfigDescriptionBuilder.create(uri).withParameters(Arrays.asList(ConfigDescriptionParameterBuilder.create("mode", Type.INTEGER).withDefault("0").withDescription("The NFC Bricklet supports five modes:<br/><br/><ul><li>Off</li><li>Card Emulation (Cardemu): Emulates a tag for other readers</li><li>Peer to Peer (P2P): Exchange data with other readers</li><li>Reader: Reads and writes tags</li><li>Simple: Automatically reads tag IDs</li></ul><br/><br/>If you change a mode, the Bricklet will reconfigure the hardware for this mode. Therefore, you can only use functions corresponding to the current mode. For example, in Reader mode you can only use Reader functions.").withLabel("Mode").withLimitToOptions(true).withOptions(Arrays.asList(new ParameterOption("0", "Off"), new ParameterOption("1", "Cardemu"), new ParameterOption("2", "P2P"), new ParameterOption("3", "Reader"), new ParameterOption("4", "Simple"))).build(), ConfigDescriptionParameterBuilder.create("detectionLEDConfig", Type.INTEGER).withDefault("3").withDescription("The detection LED configuration. By default the LED shows if a card/reader is detected.<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 off.").withLabel("Detection 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 Detection"))).build(), ConfigDescriptionParameterBuilder.create("maximumTimeout", Type.INTEGER).withDefault("2000").withDescription("This is a global maximum used for all internal state timeouts. The timeouts depend heavily on the used tags etc. For example: If you use a Type 2 tag and you want to detect if it is present, you have to use the readerRequestTagID action and wait for the state to change to either the error state or the ready state.<br/><br/>With the default configuration this takes 2-3 seconds. By setting the maximum timeout to 100ms you can reduce this time to ~150-200ms. For Type 2 this would also still work with a 20ms timeout (a Type 2 tag answers usually within 10ms). A type 4 tag can take up to 500ms in our tests.<br/><br/>If you need a fast response time to discover if a tag is present or not you can find a good timeout value by trial and error for your specific tag.<br/><br/>By default we use a very conservative timeout, to be sure that any tag can always answer in time.").withLabel("Maximum Timeout").withAdvanced(true).withMinimum(BigDecimal.valueOf(0)).withMaximum(BigDecimal.valueOf(65535)).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:BrickletNFCState":
                return ConfigDescriptionBuilder.create(uri).withParameters(Arrays.asList()).withParameterGroups(Arrays.asList()).build();
            case "channel-type:tinkerforge:BrickletNFCTagID":
                return ConfigDescriptionBuilder.create(uri).withParameters(Arrays.asList(ConfigDescriptionParameterBuilder.create("updateInterval", Type.INTEGER).withDefault("1000").withDescription("Specifies the update interval in milliseconds. A value of 0 disables automatic updates.").withLabel("Update Interval").withUnit("ms").build())).withParameterGroups(Arrays.asList()).build();
            case "channel-type:tinkerforge:BrickletNFCTagType":
                return ConfigDescriptionBuilder.create(uri).withParameters(Arrays.asList(ConfigDescriptionParameterBuilder.create("updateInterval", Type.INTEGER).withDefault("1000").withDescription("Specifies the update interval in milliseconds. A value of 0 disables automatic updates.").withLabel("Update Interval").withUnit("ms").build())).withParameterGroups(Arrays.asList()).build();
            case "channel-type:tinkerforge:BrickletNFCTagLastSeen":
                return ConfigDescriptionBuilder.create(uri).withParameters(Arrays.asList(ConfigDescriptionParameterBuilder.create("updateInterval", Type.INTEGER).withDefault("1000").withDescription("Specifies the update interval in milliseconds. A value of 0 disables automatic updates.").withLabel("Update Interval").withUnit("ms").build())).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 {
        BrickletNFCConfig cfg = (BrickletNFCConfig) config.as(BrickletNFCConfig.class);
switch(channel) {
            case "BrickletNFCState":
                   {
            BrickletNFC.ReaderGetState value = this.readerGetState();
            if(cfg.mode == 1)
                updateStateFn.accept(channel, transformBrickletNFCStateGetter0(value, cfg));
        }
                   {
            BrickletNFC.CardemuGetState value = this.cardemuGetState();
            if(cfg.mode == 2)
                updateStateFn.accept(channel, transformBrickletNFCStateGetter1(value, cfg));
        }
                   {
            BrickletNFC.P2PGetState value = this.p2pGetState();
            if(cfg.mode == 3)
                updateStateFn.accept(channel, transformBrickletNFCStateGetter2(value, cfg));
        }
                   return;
            case "BrickletNFCLastTagID":
                   {
            BrickletNFC.SimpleGetTagID value = this.simpleGetTagID(0);
            if(true)
                updateStateFn.accept(channel, transformBrickletNFCLastTagIDGetter0(value, cfg));
        }
                   return;
            case "BrickletNFCLastTagType":
                   {
            BrickletNFC.SimpleGetTagID value = this.simpleGetTagID(0);
            if(true)
                updateStateFn.accept(channel, transformBrickletNFCLastTagTypeGetter0(value, cfg));
        }
                   return;
            case "BrickletNFCLastTagSeen":
                   {
            BrickletNFC.SimpleGetTagID value = this.simpleGetTagID(0);
            if(value.lastSeen != 0)
                updateStateFn.accept(channel, transformBrickletNFCLastTagSeenGetter0(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) {
            default:
                logger.warn("Command for unknown channel {}", channel);
        }
        return result;
    }

        private org.eclipse.smarthome.core.types.State transformBrickletNFCStateCallback0(int state, boolean idle, BrickletNFCConfig cfg) {
        return new DecimalType(state);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletNFCStateCallback1(int state, boolean idle, BrickletNFCConfig cfg) {
        return new DecimalType(state);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletNFCStateCallback2(int state, boolean idle, BrickletNFCConfig cfg) {
        return new DecimalType(state);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletNFCStateGetter0(BrickletNFC.ReaderGetState value, BrickletNFCConfig cfg) {
        return new DecimalType(value.state);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletNFCStateGetter1(BrickletNFC.CardemuGetState value, BrickletNFCConfig cfg) {
        return new DecimalType(value.state);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletNFCStateGetter2(BrickletNFC.P2PGetState value, BrickletNFCConfig cfg) {
        return new DecimalType(value.state);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletNFCLastTagIDGetter0(BrickletNFC.SimpleGetTagID value, BrickletNFCConfig cfg) {
        return new StringType(Arrays.stream(value.tagID).mapToObj(i -> String.format("%02x", i)).collect(Collectors.joining(":")));
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletNFCLastTagTypeGetter0(BrickletNFC.SimpleGetTagID value, BrickletNFCConfig cfg) {
        return new DecimalType(value.tagType);
    }
	    private org.eclipse.smarthome.core.types.State transformBrickletNFCLastTagSeenGetter0(BrickletNFC.SimpleGetTagID value, BrickletNFCConfig cfg) {
        return new DateTimeType(ZonedDateTime.now().truncatedTo(ChronoUnit.SECONDS).minusSeconds(value.lastSeen / 1000));
    }

}