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.modbus.sunspec.internal;
15 import java.util.HashMap;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.binding.modbus.ModbusBindingConstants;
20 import org.openhab.core.thing.ThingTypeUID;
23 * The {@link SunSpecConstants} class defines common constants, which are
24 * used across the whole binding.
26 * @author Nagy Attila Gábor - Initial contribution
29 public class SunSpecConstants {
31 private static final String BINDING_ID = ModbusBindingConstants.BINDING_ID;
33 // List of all Thing Type UIDs
34 public static final ThingTypeUID THING_TYPE_INVERTER_SINGLE_PHASE = new ThingTypeUID(BINDING_ID,
35 "inverter-single-phase");
36 public static final ThingTypeUID THING_TYPE_INVERTER_SPLIT_PHASE = new ThingTypeUID(BINDING_ID,
37 "inverter-split-phase");
38 public static final ThingTypeUID THING_TYPE_INVERTER_THREE_PHASE = new ThingTypeUID(BINDING_ID,
39 "inverter-three-phase");
40 public static final ThingTypeUID THING_TYPE_METER_SINGLE_PHASE = new ThingTypeUID(BINDING_ID, "meter-single-phase");
41 public static final ThingTypeUID THING_TYPE_METER_SPLIT_PHASE = new ThingTypeUID(BINDING_ID, "meter-split-phase");
42 public static final ThingTypeUID THING_TYPE_METER_WYE_PHASE = new ThingTypeUID(BINDING_ID, "meter-wye-phase");
43 public static final ThingTypeUID THING_TYPE_METER_DELTA_PHASE = new ThingTypeUID(BINDING_ID, "meter-delta-phase");
46 public static final int COMMON_BLOCK = 1;
47 public static final int INVERTER_SINGLE_PHASE = 101;
48 public static final int INVERTER_SPLIT_PHASE = 102;
49 public static final int INVERTER_THREE_PHASE = 103;
50 public static final int METER_SINGLE_PHASE = 201;
51 public static final int METER_SPLIT_PHASE = 202;
52 public static final int METER_WYE_PHASE = 203;
53 public static final int METER_DELTA_PHASE = 204;
54 public static final int FINAL_BLOCK = 0xffff;
57 * Map of the supported thing type uids, with their block type id
59 public static final Map<Integer, ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = new HashMap<>();
61 SUPPORTED_THING_TYPES_UIDS.put(INVERTER_SINGLE_PHASE, THING_TYPE_INVERTER_SINGLE_PHASE);
62 SUPPORTED_THING_TYPES_UIDS.put(INVERTER_SPLIT_PHASE, THING_TYPE_INVERTER_SPLIT_PHASE);
63 SUPPORTED_THING_TYPES_UIDS.put(INVERTER_THREE_PHASE, THING_TYPE_INVERTER_THREE_PHASE);
64 SUPPORTED_THING_TYPES_UIDS.put(METER_SINGLE_PHASE, THING_TYPE_METER_SINGLE_PHASE);
65 SUPPORTED_THING_TYPES_UIDS.put(METER_SPLIT_PHASE, THING_TYPE_METER_SPLIT_PHASE);
66 SUPPORTED_THING_TYPES_UIDS.put(METER_WYE_PHASE, THING_TYPE_METER_WYE_PHASE);
67 SUPPORTED_THING_TYPES_UIDS.put(METER_DELTA_PHASE, THING_TYPE_METER_DELTA_PHASE);
71 public static final String PROPERTY_VENDOR = "vendor";
72 public static final String PROPERTY_MODEL = "model";
73 public static final String PROPERTY_VERSION = "version";
74 public static final String PROPERTY_PHASE_COUNT = "phaseCount";
75 public static final String PROPERTY_SERIAL_NUMBER = "serialNumber";
76 public static final String PROPERTY_BLOCK_ADDRESS = "blockAddress";
77 public static final String PROPERTY_BLOCK_LENGTH = "blockLength";
78 public static final String PROPERTY_UNIQUE_ADDRESS = "uniqueAddress";
81 public static final String GROUP_DEVICE_INFO = "deviceInformation";
82 public static final String GROUP_AC_GENERAL = "acGeneral";
83 public static final String GROUP_AC_PHASE_A = "acPhaseA";
84 public static final String GROUP_AC_PHASE_B = "acPhaseB";
85 public static final String GROUP_AC_PHASE_C = "acPhaseC";
86 public static final String GROUP_DC_GENERAL = "dcGeneral";
88 // List of all Channel ids in device information group
89 public static final String CHANNEL_PHASE_CONFIGURATION = "phase-configuration";
90 public static final String CHANNEL_CABINET_TEMPERATURE = "cabinet-temperature";
91 public static final String CHANNEL_HEATSINK_TEMPERATURE = "heatsink-temperature";
92 public static final String CHANNEL_TRANSFORMER_TEMPERATURE = "transformer-temperature";
93 public static final String CHANNEL_OTHER_TEMPERATURE = "other-temperature";
94 public static final String CHANNEL_STATUS = "status";
95 public static final String CHANNEL_STATUS_VENDOR = "status-vendor";
97 // List of channel ids in AC general group for inverter
98 public static final String CHANNEL_AC_TOTAL_CURRENT = "ac-total-current";
99 public static final String CHANNEL_AC_POWER = "ac-power";
100 public static final String CHANNEL_AC_FREQUENCY = "ac-frequency";
101 public static final String CHANNEL_AC_APPARENT_POWER = "ac-apparent-power";
102 public static final String CHANNEL_AC_REACTIVE_POWER = "ac-reactive-power";
103 public static final String CHANNEL_AC_POWER_FACTOR = "ac-power-factor";
104 public static final String CHANNEL_AC_LIFETIME_ENERGY = "ac-lifetime-energy";
106 // List of channels ids in AC general group for meter
107 public static final String CHANNEL_AC_AVERAGE_VOLTAGE_TO_N = "ac-average-voltage-to-n";
108 public static final String CHANNEL_AC_AVERAGE_VOLTAGE_TO_NEXT = "ac-average-voltage-to-next";
109 public static final String CHANNEL_AC_TOTAL_REAL_POWER = "ac-total-real-power";
110 public static final String CHANNEL_AC_TOTAL_APPARENT_POWER = "ac-total-apparent-power";
111 public static final String CHANNEL_AC_TOTAL_REACTIVE_POWER = "ac-total-reactive-power";
112 public static final String CHANNEL_AC_AVERAGE_POWER_FACTOR = "ac-average-power-factor";
113 public static final String CHANNEL_AC_TOTAL_EXPORTED_REAL_ENERGY = "ac-total-exported-real-energy";
114 public static final String CHANNEL_AC_TOTAL_IMPORTED_REAL_ENERGY = "ac-total-imported-real-energy";
115 public static final String CHANNEL_AC_TOTAL_EXPORTED_APPARENT_ENERGY = "ac-total-exported-apparent-energy";
116 public static final String CHANNEL_AC_TOTAL_IMPORTED_APPARENT_ENERGY = "ac-total-imported-apparent-energy";
117 public static final String CHANNEL_AC_TOTAL_IMPORTED_REACTIVE_ENERGY_Q1 = "ac-total-imported-reactive-energy-q1";
118 public static final String CHANNEL_AC_TOTAL_IMPORTED_REACTIVE_ENERGY_Q2 = "ac-total-imported-reactive-energy-q2";
119 public static final String CHANNEL_AC_TOTAL_EXPORTED_REACTIVE_ENERGY_Q3 = "ac-total-exported-reactive-energy-q3";
120 public static final String CHANNEL_AC_TOTAL_EXPORTED_REACTIVE_ENERGY_Q4 = "ac-total-exported-reactive-energy-q4";
122 // List of channel ids in AC phase group for inverter
123 public static final String CHANNEL_AC_PHASE_CURRENT = "ac-phase-current";
124 public static final String CHANNEL_AC_VOLTAGE_TO_NEXT = "ac-voltage-to-next";
125 public static final String CHANNEL_AC_VOLTAGE_TO_N = "ac-voltage-to-n";
127 // List of channel ids in DC group for inverter
128 public static final String CHANNEL_DC_CURRENT = "dc-current";
129 public static final String CHANNEL_DC_VOLTAGE = "dc-voltage";
130 public static final String CHANNEL_DC_POWER = "dc-power";
132 // List of channel ids in AC phase group for meter
133 public static final String CHANNEL_AC_REAL_POWER = "ac-real-power";
134 public static final String CHANNEL_AC_EXPORTED_REAL_ENERGY = "ac-exported-real-energy";
135 public static final String CHANNEL_AC_IMPORTED_REAL_ENERGY = "ac-imported-real-energy";
136 public static final String CHANNEL_AC_EXPORTED_APPARENT_ENERGY = "ac-exported-apparent-energy";
137 public static final String CHANNEL_AC_IMPORTED_APPARENT_ENERGY = "ac-imported-apparent-energy";
138 public static final String CHANNEL_AC_IMPORTED_REACTIVE_ENERGY_Q1 = "ac-imported-reactive-energy-q1";
139 public static final String CHANNEL_AC_IMPORTED_REACTIVE_ENERGY_Q2 = "ac-imported-reactive-energy-q2";
140 public static final String CHANNEL_AC_EXPORTED_REACTIVE_ENERGY_Q3 = "ac-exported-reactive-energy-q3";
141 public static final String CHANNEL_AC_EXPORTED_REACTIVE_ENERGY_Q4 = "ac-exported-reactive-energy-q4";
143 // Expected SunSpec ID This is a magic constant to distinguish SunSpec compatible
144 // devices from other modbus devices
145 public static final long SUNSPEC_ID = 0x53756e53;
146 // Size of SunSpect ID in words
147 public static final int SUNSPEC_ID_SIZE = 2;
148 // Size of any block header in words
149 public static final int MODEL_HEADER_SIZE = 2;