2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.enocean.internal.eep.A5_09;
15 import static org.openhab.binding.enocean.internal.EnOceanBindingConstants.*;
17 import java.util.function.Function;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.openhab.binding.enocean.internal.messages.ERP1Message;
21 import org.openhab.core.config.core.Configuration;
22 import org.openhab.core.library.types.QuantityType;
23 import org.openhab.core.library.unit.Units;
24 import org.openhab.core.types.State;
28 * @author Zhivka Dimova - Initial contribution
31 public class A5_09_0C extends A5_09_05 {
33 public A5_09_0C(ERP1Message packet) {
38 protected String[] getVOCIdentifications() {
39 String[] VOCIdsSuper = super.getVOCIdentifications();
40 int elFromSuper = VOCIdsSuper.length - 2;
41 String[] VOCIdsExtension = new String[] { "Naphthalene", "4-Phenylcyclohexene", "Limonene", "Trichloroethylene",
42 "Isovaleric acid", "Indole", "Cadaverine", "Putrescine", "Caproic acid", "Ozone" };
43 String[] VOCIdsExtended = new String[elFromSuper + VOCIdsExtension.length];
45 System.arraycopy(VOCIdsSuper, 0, VOCIdsExtended, 0, elFromSuper);
46 System.arraycopy(VOCIdsExtension, 0, VOCIdsExtended, elFromSuper, VOCIdsExtension.length);
48 return VOCIdsExtended;
52 protected State convertToStateImpl(String channelId, String channelTypeId,
53 Function<String, State> getCurrentStateFunc, Configuration config) {
54 if (CHANNEL_VOC.equals(channelId)) {
55 double scaledVOC = getUnscaledVOCValue() * getScalingFactor();
56 if (getBit(getDB0(), 2)) {
57 return new QuantityType<>(scaledVOC, Units.MICROGRAM_PER_CUBICMETRE);
59 return new QuantityType<>(scaledVOC, Units.PARTS_PER_BILLION);
62 return super.convertToStateImpl(channelId, channelTypeId, getCurrentStateFunc, config);