]> git.basschouten.com Git - openhab-addons.git/blob
c2abd7861c9a4d2560b6f039765b83001c128b5f
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.networkupstools.internal;
14
15 import java.net.URI;
16
17 import javax.measure.Unit;
18 import javax.measure.quantity.Power;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.core.library.unit.Units;
22 import org.openhab.core.thing.ThingTypeUID;
23 import org.openhab.core.thing.type.ChannelTypeUID;
24
25 import tec.uom.se.format.SimpleUnitFormat;
26 import tec.uom.se.unit.ProductUnit;
27
28 /**
29  * The {@link NUTBindingConstants} class defines common constants, which are
30  * used across the whole binding.
31  *
32  * @author Hilbrand Bouwkamp - Initial contribution
33  */
34 @NonNullByDefault
35 public class NUTBindingConstants {
36
37     public static final String BINDING_ID = "networkupstools";
38
39     // List of all Thing Type UIDs
40     public static final ThingTypeUID THING_TYPE_UPS = new ThingTypeUID(BINDING_ID, "ups");
41
42     public static final String METADATA_NETWORKUPSTOOLS = "networkupstools";
43     public static final ChannelTypeUID CHANNEL_TYPE_DYNAMIC_NUMBER = new ChannelTypeUID(BINDING_ID, "number");
44     public static final ChannelTypeUID CHANNEL_TYPE_DYNAMIC_STRING = new ChannelTypeUID(BINDING_ID, "string");
45     public static final ChannelTypeUID CHANNEL_TYPE_DYNAMIC_SWITCH = new ChannelTypeUID(BINDING_ID, "switch");
46     public static final URI DYNAMIC_CHANNEL_CONFIG_QUANTITY_TYPE = URI
47             .create("channel-type:ups:dynamic-channel-config-quantity-type");
48
49     public static final Unit<Power> AMPERE_PER_HOUR = new ProductUnit<>(Units.AMPERE.divide(Units.HOUR));
50     public static final Unit<Power> VOLT_AMPERE = new ProductUnit<>(Units.VOLT.multiply(Units.AMPERE));
51
52     static {
53         SimpleUnitFormat.getInstance().label(AMPERE_PER_HOUR, "Ah");
54         SimpleUnitFormat.getInstance().label(VOLT_AMPERE, "VA");
55     }
56
57     private static final String PARAMETER_PREFIX_UPS = "ups.";
58
59     /**
60      * Enum with nut names which value will be set a parameter on the thing.
61      * These are values that don't change at all (e.g. type of ups) or not very often (e.g. firmware version).
62      */
63     public enum Parameters {
64         UPS_FIRMWARE(PARAMETER_PREFIX_UPS + "firmware"),
65         UPS_FIRMWARE_AUX(PARAMETER_PREFIX_UPS + "firmware.aux"),
66         UPS_ID(PARAMETER_PREFIX_UPS + "id"),
67         UPS_MFR(PARAMETER_PREFIX_UPS + "mfr"),
68         UPS_MFR_DATE(PARAMETER_PREFIX_UPS + "mfr.date"),
69         UPS_MODEL(PARAMETER_PREFIX_UPS + "model"),
70         UPS_SERIAL(PARAMETER_PREFIX_UPS + "serial");
71
72         private final String nutName;
73
74         private Parameters(final String nutName) {
75             this.nutName = nutName;
76         }
77
78         public String getNutName() {
79             return nutName;
80         }
81     }
82 }