Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# SPDX-License-Identifier: Apache-2.0 

2 

3# Copyright 2020 Contributors to OpenLEADR 

4 

5# Licensed under the Apache License, Version 2.0 (the "License"); 

6# you may not use this file except in compliance with the License. 

7# You may obtain a copy of the License at 

8 

9# http://www.apache.org/licenses/LICENSE-2.0 

10 

11# Unless required by applicable law or agreed to in writing, software 

12# distributed under the License is distributed on an "AS IS" BASIS, 

13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

14# See the License for the specific language governing permissions and 

15# limitations under the License. 

16 

17""" 

18A collection of useful enumerations that you can use to construct or 

19interpret OpenADR messages. Can also be useful during testing. 

20""" 

21from openleadr.objects import Measurement, PowerAttributes 

22 

23 

24class Enum(type): 

25 def __getitem__(self, item): 

26 return getattr(self, item) 

27 

28 @property 

29 def members(self): 

30 return sorted([item for item in list(set(dir(self)) - set(dir(Enum))) 

31 if not item.startswith("_")]) 

32 

33 @property 

34 def values(self): 

35 return [self[item] for item in self.members] 

36 

37 

38class EVENT_STATUS(metaclass=Enum): 

39 NONE = "none" 

40 FAR = "far" 

41 NEAR = "near" 

42 ACTIVE = "active" 

43 COMPLETED = "completed" 

44 CANCELLED = "cancelled" 

45 

46 

47class SIGNAL_TYPE(metaclass=Enum): 

48 DELTA = "delta" 

49 LEVEL = "level" 

50 MULTIPLIER = "multiplier" 

51 PRICE = "price" 

52 PRICE_MULTIPLIER = "priceMultiplier" 

53 PRICE_RELATIVE = "priceRelative" 

54 SETPOINT = "setpoint" 

55 X_LOAD_CONTROL_CAPACITY = "x-loadControlCapacity" 

56 X_LOAD_CONTROL_LEVEL_OFFSET = "x-loadControlLevelOffset" 

57 X_LOAD_CONTROL_PERCENT_OFFSET = "x-loadControlPercentOffset" 

58 X_LOAD_CONTROL_SETPOINT = "x-loadControlSetpoint" 

59 

60 

61class SIGNAL_NAME(metaclass=Enum): 

62 SIMPLE = "SIMPLE" 

63 simple = "simple" 

64 ELECTRICITY_PRICE = "ELECTRICITY_PRICE" 

65 ENERGY_PRICE = "ENERGY_PRICE" 

66 DEMAND_CHARGE = "DEMAND_CHARGE" 

67 BID_PRICE = "BID_PRICE" 

68 BID_LOAD = "BID_LOAD" 

69 BID_ENERGY = "BID_ENERGY" 

70 CHARGE_STATE = "CHARGE_STATE" 

71 LOAD_DISPATCH = "LOAD_DISPATCH" 

72 LOAD_CONTROL = "LOAD_CONTROL" 

73 

74 

75class SI_SCALE_CODE(metaclass=Enum): 

76 p = "p" 

77 n = "n" 

78 micro = "micro" 

79 m = "m" 

80 c = "c" 

81 d = "d" 

82 k = "k" 

83 M = "M" 

84 G = "G" 

85 T = "T" 

86 none = "none" 

87 

88 

89class OPT(metaclass=Enum): 

90 OPT_IN = "optIn" 

91 OPT_OUT = "optOut" 

92 

93 

94class OPT_REASON(metaclass=Enum): 

95 ECONOMIC = "economic" 

96 EMERGENCY = "emergency" 

97 MUST_RUN = "mustRun" 

98 NOT_PARTICIPATING = "notParticipating" 

99 OUTAGE_RUN_STATUS = "outageRunStatus" 

100 OVERRIDE_STATUS = "overrideStatus" 

101 PARTICIPATING = "participating" 

102 X_SCHEDULE = "x-schedule" 

103 

104 

105class READING_TYPE(metaclass=Enum): 

106 DIRECT_READ = "Direct Read" 

107 NET = "Net" 

108 ALLOCATED = "Allocated" 

109 ESTIMATED = "Estimated" 

110 SUMMED = "Summed" 

111 DERIVED = "Derived" 

112 MEAN = "Mean" 

113 PEAK = "Peak" 

114 HYBRID = "Hybrid" 

115 CONTRACT = "Contract" 

116 PROJECTED = "Projected" 

117 X_RMS = "x-RMS" 

118 X_NOT_APPLICABLE = "x-notApplicable" 

119 

120 

121class REPORT_TYPE(metaclass=Enum): 

122 READING = "reading" 

123 USAGE = "usage" 

124 DEMAND = "demand" 

125 SET_POINT = "setPoint" 

126 DELTA_USAGE = "deltaUsage" 

127 DELTA_SET_POINT = "deltaSetPoint" 

128 DELTA_DEMAND = "deltaDemand" 

129 BASELINE = "baseline" 

130 DEVIATION = "deviation" 

131 AVG_USAGE = "avgUsage" 

132 AVG_DEMAND = "avgDemand" 

133 OPERATING_STATE = "operatingState" 

134 UP_REGULATION_CAPACITY_AVAILABLE = "upRegulationCapacityAvailable" 

135 DOWN_REGULATION_CAPACITY_AVAILABLE = "downRegulationCapacityAvailable" 

136 REGULATION_SETPOINT = "regulationSetpoint" 

137 STORED_ENERGY = "storedEnergy" 

138 TARGET_ENERGY_STORAGE = "targetEnergyStorage" 

139 AVAILABLE_ENERGY_STORAGE = "availableEnergyStorage" 

140 PRICE = "price" 

141 LEVEL = "level" 

142 POWER_FACTOR = "powerFactor" 

143 PERCENT_USAGE = "percentUsage" 

144 PERCENT_DEMAND = "percentDemand" 

145 X_RESOURCE_STATUS = "x-resourceStatus" 

146 

147 

148class SIGNAL_TARGET_MRID(metaclass=Enum): 

149 THERMOSTAT = "Thermostat" 

150 STRIP_HEATER = "Strip_Heater" 

151 BASEBOARD_HEATER = "Baseboard_Heater" 

152 WATER_HEATER = "Water_Heater" 

153 POOL_PUMP = "Pool_Pump" 

154 SAUNA = "Sauna" 

155 HOT_TUB = "Hot_tub" 

156 SMART_APPLIANCE = "Smart_Appliance" 

157 IRRIGATION_PUMP = "Irrigation_Pump" 

158 MANAGED_COMMERCIAL_AND_INDUSTRIAL_LOADS = "Managed_Commercial_and_Industrial_Loads" 

159 SIMPLE_RESIDENTIAL_ON_OFF_LOADS = "Simple_Residential_On_Off_Loads" 

160 EXTERIOR_LIGHTING = "Exterior_Lighting" 

161 INTERIOR_LIGHTING = "Interior_Lighting" 

162 ELECTRIC_VEHICLE = "Electric_Vehicle" 

163 GENERATION_SYSTEMS = "Generation_Systems" 

164 LOAD_CONTROL_SWITCH = "Load_Control_Switch" 

165 SMART_INVERTER = "Smart_Inverter" 

166 EVSE = "EVSE" 

167 RESU = "RESU" 

168 ENERGY_MANAGEMENT_SYSTEM = "Energy_Management_System" 

169 SMART_ENERGY_MODULE = "Smart_Energy_Module" 

170 STORAGE = "Storage" 

171 

172 

173class REPORT_NAME(metaclass=Enum): 

174 METADATA_HISTORY_USAGE = "METADATA_HISTORY_USAGE" 

175 HISTORY_USAGE = "HISTORY_USAGE" 

176 METADATA_HISTORY_GREENBUTTON = "METADATA_HISTORY_GREENBUTTON" 

177 HISTORY_GREENBUTTON = "HISTORY_GREENBUTTON" 

178 METADATA_TELEMETRY_USAGE = "METADATA_TELEMETRY_USAGE" 

179 TELEMETRY_USAGE = "TELEMETRY_USAGE" 

180 METADATA_TELEMETRY_STATUS = "METADATA_TELEMETRY_STATUS" 

181 TELEMETRY_STATUS = "TELEMETRY_STATUS" 

182 

183 

184class STATUS_CODES(metaclass=Enum): 

185 OUT_OF_SEQUENCE = 450 

186 NOT_ALLOWED = 451 

187 INVALID_ID = 452 

188 NOT_RECOGNIZED = 453 

189 INVALID_DATA = 454 

190 COMPLIANCE_ERROR = 459 

191 SIGNAL_NOT_SUPPORTED = 460 

192 REPORT_NOT_SUPPORTED = 461 

193 TARGET_MISMATCH = 462 

194 NOT_REGISTERED_OR_AUTHORIZED = 463 

195 DEPLOYMENT_ERROR_OR_OTHER_ERROR = 469 

196 

197 

198class SECURITY_LEVEL: 

199 STANDARD = 'STANDARD' 

200 HIGH = 'HIGH' 

201 

202 

203_CURRENCIES = ("AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", 

204 "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BOV", "BRL", 

205 "BSD", "BTN", "BWP", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", 

206 "CLF", "CLP", "CNY", "COP", "COU", "CRC", "CUC", "CUP", "CVE", "CZK", 

207 "DJF", "DKK", "DOP", "DZD", "EEK", "EGP", "ERN", "ETB", "EUR", "FJD", 

208 "FKP", "GBP", "GEL", "GHS", "GIP", "GMD", "GNF", "GTQ", "GWP", "GYD", 

209 "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "INR", "IQD", "IRR", 

210 "ISK", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", 

211 "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LVL", 

212 "LYD", "MAD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO", 

213 "MUR", "MVR", "MWK", "MXN", "MXV", "MYR", "MZN", "NAD", "NGN", "NIO", 

214 "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", 

215 "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", 

216 "SEK", "SGD", "SHP", "SLL", "SOS", "SRD", "STD", "SVC", "SYP", "SZL", 

217 "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", 

218 "UGX", "USD", "USN", "USS", "UYI", "UYU", "UZS", "VEF", "VND", "VUV", 

219 "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", 

220 "XFU", "XOF", "XPD", "XPF", "XPF", "XPF", "XPT", "XTS", "XXX", "YER", 

221 "ZAR", "ZMK", "ZWL") 

222 

223_ACCEPTABLE_UNITS = {'currency': _CURRENCIES, 

224 'currencyPerKW': _CURRENCIES, 

225 'currencyPerKWh': _CURRENCIES, 

226 'currencyPerThm': _CURRENCIES, 

227 'current': ('A',), 

228 'energyApparent': ('VAh',), 

229 'energyReactive': ('VARh',), 

230 'energyReal': ('Wh',), 

231 'frequency': ('Hz',), 

232 'powerApparent': ('VA',), 

233 'powerReactive': ('VAR',), 

234 'powerReal': ('W',), 

235 'pulseCount': ('count',), 

236 'temperature': ('celsius', 'fahrenheit'), 

237 'Therm': ('thm',), 

238 'voltage': ('V',)} 

239 

240_MEASUREMENT_DESCRIPTIONS = {'currency': 'currency', 

241 'currencyPerKW': 'currencyPerKW', 

242 'currencyPerKWh': 'currencyPerKWh', 

243 'currencyPerThm': 'currency', 

244 'current': 'Current', 

245 'energyApparent': 'ApparentEnergy', 

246 'energyReactive': 'ReactiveEnergy', 

247 'energyReal': 'RealEnergy', 

248 'frequency': 'Frequency', 

249 'powerApparent': 'ApparentPower', 

250 'powerReactive': 'ReactivePower', 

251 'powerReal': 'RealPower', 

252 'pulseCount': 'pulse count', 

253 'temperature': 'temperature', 

254 'Therm': 'Therm', 

255 'voltage': 'Voltage'} 

256 

257_MEASUREMENT_NAMESPACES = {'currency': 'oadr', 

258 'currencyPerWK': 'oadr', 

259 'currencyPerKWh': 'oadr', 

260 'currencyPerThm': 'oadr', 

261 'current': 'oadr', 

262 'energyApparent': 'power', 

263 'energyReactive': 'power', 

264 'energyReal': 'power', 

265 'frequency': 'oadr', 

266 'powerApparent': 'power', 

267 'powerReactive': 'power', 

268 'powerReal': 'power', 

269 'pulseCount': 'oadr', 

270 'temperature': 'oadr', 

271 'Therm': 'oadr', 

272 'voltage': 'power', 

273 'customUnit': 'oadr'} 

274 

275 

276class MEASUREMENTS(metaclass=Enum): 

277 VOLTAGE = Measurement(name='voltage', 

278 description=_MEASUREMENT_DESCRIPTIONS['voltage'], 

279 unit=_ACCEPTABLE_UNITS['voltage'][0], 

280 acceptable_units=_ACCEPTABLE_UNITS['voltage'], 

281 scale='none') 

282 CURRENT = Measurement(name='current', 

283 description=_MEASUREMENT_DESCRIPTIONS['current'], 

284 unit=_ACCEPTABLE_UNITS['current'][0], 

285 acceptable_units=_ACCEPTABLE_UNITS['current'], 

286 scale='none') 

287 ENERGY_REAL = Measurement(name='energyReal', 

288 description=_MEASUREMENT_DESCRIPTIONS['energyReal'], 

289 unit=_ACCEPTABLE_UNITS['energyReal'][0], 

290 acceptable_units=_ACCEPTABLE_UNITS['energyReal'], 

291 scale='none') 

292 REAL_ENERGY = Measurement(name='energyReal', 

293 description=_MEASUREMENT_DESCRIPTIONS['energyReal'], 

294 unit=_ACCEPTABLE_UNITS['energyReal'][0], 

295 acceptable_units=_ACCEPTABLE_UNITS['energyReal'], 

296 scale='none') 

297 ACTIVE_ENERGY = Measurement(name='energyReal', 

298 description=_MEASUREMENT_DESCRIPTIONS['energyReal'], 

299 unit=_ACCEPTABLE_UNITS['energyReal'][0], 

300 acceptable_units=_ACCEPTABLE_UNITS['energyReal'], 

301 scale='none') 

302 ENERGY_REACTIVE = Measurement(name='energyReactive', 

303 description=_MEASUREMENT_DESCRIPTIONS['energyReactive'], 

304 unit=_ACCEPTABLE_UNITS['energyReactive'][0], 

305 acceptable_units=_ACCEPTABLE_UNITS['energyReactive'], 

306 scale='none') 

307 REACTIVE_ENERGY = Measurement(name='energyReactive', 

308 description=_MEASUREMENT_DESCRIPTIONS['energyReactive'], 

309 unit=_ACCEPTABLE_UNITS['energyReactive'][0], 

310 acceptable_units=_ACCEPTABLE_UNITS['energyReactive'], 

311 scale='none') 

312 ENERGY_APPARENT = Measurement(name='energyApparent', 

313 description=_MEASUREMENT_DESCRIPTIONS['energyApparent'], 

314 unit=_ACCEPTABLE_UNITS['energyApparent'][0], 

315 acceptable_units=_ACCEPTABLE_UNITS['energyApparent'], 

316 scale='none') 

317 APPARENT_ENERGY = Measurement(name='energyApparent', 

318 description=_MEASUREMENT_DESCRIPTIONS['energyApparent'], 

319 unit=_ACCEPTABLE_UNITS['energyApparent'][0], 

320 acceptable_units=_ACCEPTABLE_UNITS['energyApparent'], 

321 scale='none') 

322 ACTIVE_POWER = Measurement(name='powerReal', 

323 description=_MEASUREMENT_DESCRIPTIONS['powerReal'], 

324 unit=_ACCEPTABLE_UNITS['powerReal'][0], 

325 acceptable_units=_ACCEPTABLE_UNITS['powerReal'], 

326 scale='none', 

327 power_attributes=PowerAttributes(hertz=50, 

328 voltage=230, 

329 ac=True)) 

330 REAL_POWER = Measurement(name='powerReal', 

331 description=_MEASUREMENT_DESCRIPTIONS['powerReal'], 

332 unit=_ACCEPTABLE_UNITS['powerReal'][0], 

333 acceptable_units=_ACCEPTABLE_UNITS['powerReal'], 

334 scale='none', 

335 power_attributes=PowerAttributes(hertz=50, 

336 voltage=230, 

337 ac=True)) 

338 POWER_REAL = Measurement(name='powerReal', 

339 description=_MEASUREMENT_DESCRIPTIONS['powerReal'], 

340 unit=_ACCEPTABLE_UNITS['powerReal'][0], 

341 acceptable_units=_ACCEPTABLE_UNITS['powerReal'], 

342 scale='none', 

343 power_attributes=PowerAttributes(hertz=50, 

344 voltage=230, 

345 ac=True)) 

346 REACTIVE_POWER = Measurement(name='powerReactive', 

347 description=_MEASUREMENT_DESCRIPTIONS['powerReactive'], 

348 unit=_ACCEPTABLE_UNITS['powerReactive'][0], 

349 acceptable_units=_ACCEPTABLE_UNITS['powerReactive'], 

350 scale='none', 

351 power_attributes=PowerAttributes(hertz=50, 

352 voltage=230, 

353 ac=True)) 

354 POWER_REACTIVE = Measurement(name='powerReactive', 

355 description=_MEASUREMENT_DESCRIPTIONS['powerReactive'], 

356 unit=_ACCEPTABLE_UNITS['powerReactive'][0], 

357 acceptable_units=_ACCEPTABLE_UNITS['powerReactive'], 

358 scale='none', 

359 power_attributes=PowerAttributes(hertz=50, 

360 voltage=230, 

361 ac=True)) 

362 APPARENT_POWER = Measurement(name='powerApparent', 

363 description=_MEASUREMENT_DESCRIPTIONS['powerApparent'], 

364 unit=_ACCEPTABLE_UNITS['powerApparent'][0], 

365 acceptable_units=_ACCEPTABLE_UNITS['powerApparent'], 

366 scale='none', 

367 power_attributes=PowerAttributes(hertz=50, 

368 voltage=230, 

369 ac=True)) 

370 POWER_APPARENT = Measurement(name='powerApparent', 

371 description=_MEASUREMENT_DESCRIPTIONS['powerApparent'], 

372 unit=_ACCEPTABLE_UNITS['powerApparent'][0], 

373 acceptable_units=_ACCEPTABLE_UNITS['powerApparent'], 

374 scale='none', 

375 power_attributes=PowerAttributes(hertz=50, 

376 voltage=230, 

377 ac=True)) 

378 FREQUENCY = Measurement(name='frequency', 

379 description=_MEASUREMENT_DESCRIPTIONS['frequency'], 

380 unit=_ACCEPTABLE_UNITS['frequency'][0], 

381 acceptable_units=_ACCEPTABLE_UNITS['frequency'], 

382 scale='none') 

383 PULSE_COUNT = Measurement(name='pulseCount', 

384 description=_MEASUREMENT_DESCRIPTIONS['pulseCount'], 

385 unit=_ACCEPTABLE_UNITS['pulseCount'][0], 

386 acceptable_units=_ACCEPTABLE_UNITS['pulseCount'], 

387 pulse_factor=1000) 

388 TEMPERATURE = Measurement(name='temperature', 

389 description=_MEASUREMENT_DESCRIPTIONS['temperature'], 

390 unit=_ACCEPTABLE_UNITS['temperature'][0], 

391 acceptable_units=_ACCEPTABLE_UNITS['temperature'], 

392 scale='none') 

393 THERM = Measurement(name='Therm', 

394 description=_MEASUREMENT_DESCRIPTIONS['Therm'], 

395 unit=_ACCEPTABLE_UNITS['Therm'][0], 

396 acceptable_units=_ACCEPTABLE_UNITS['Therm'], 

397 scale='none') 

398 CURRENCY = Measurement(name='currency', 

399 description=_MEASUREMENT_DESCRIPTIONS['currency'], 

400 unit=_CURRENCIES[0], 

401 acceptable_units=_CURRENCIES, 

402 scale='none') 

403 CURRENCY_PER_KW = Measurement(name='currencyPerKW', 

404 description=_MEASUREMENT_DESCRIPTIONS['currencyPerKW'], 

405 unit=_CURRENCIES[0], 

406 acceptable_units=_CURRENCIES, 

407 scale='none') 

408 CURRENCY_PER_KWH = Measurement(name='currencyPerKWh', 

409 description=_MEASUREMENT_DESCRIPTIONS['currencyPerKWh'], 

410 unit=_CURRENCIES[0], 

411 acceptable_units=_CURRENCIES, 

412 scale='none') 

413 CURRENCY_PER_THM = Measurement(name='currencyPerThm', 

414 description=_MEASUREMENT_DESCRIPTIONS['currencyPerThm'], 

415 unit=_CURRENCIES[0], 

416 acceptable_units=_CURRENCIES, 

417 scale='none')