enums.py 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. # SPDX-License-Identifier: Apache-2.0
  2. # Copyright 2020 Contributors to OpenLEADR
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS,
  9. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. # See the License for the specific language governing permissions and
  11. # limitations under the License.
  12. """
  13. A collection of useful enumerations that you can use to construct or
  14. interpret OpenADR messages. Can also be useful during testing.
  15. """
  16. from openleadr.objects import Measurement, PowerAttributes
  17. class Enum(type):
  18. def __getitem__(self, item):
  19. return getattr(self, item)
  20. @property
  21. def members(self):
  22. return sorted([item for item in list(set(dir(self)) - set(dir(Enum)))
  23. if not item.startswith("_")])
  24. @property
  25. def values(self):
  26. return [self[item] for item in self.members]
  27. class EVENT_STATUS(metaclass=Enum):
  28. NONE = "none"
  29. FAR = "far"
  30. NEAR = "near"
  31. ACTIVE = "active"
  32. COMPLETED = "completed"
  33. CANCELLED = "cancelled"
  34. class SIGNAL_TYPE(metaclass=Enum):
  35. DELTA = "delta"
  36. LEVEL = "level"
  37. MULTIPLIER = "multiplier"
  38. PRICE = "price"
  39. PRICE_MULTIPLIER = "priceMultiplier"
  40. PRICE_RELATIVE = "priceRelative"
  41. SETPOINT = "setpoint"
  42. X_LOAD_CONTROL_CAPACITY = "x-loadControlCapacity"
  43. X_LOAD_CONTROL_LEVEL_OFFSET = "x-loadControlLevelOffset"
  44. X_LOAD_CONTROL_PERCENT_OFFSET = "x-loadControlPercentOffset"
  45. X_LOAD_CONTROL_SETPOINT = "x-loadControlSetpoint"
  46. class SIGNAL_NAME(metaclass=Enum):
  47. SIMPLE = "SIMPLE"
  48. simple = "simple"
  49. ELECTRICITY_PRICE = "ELECTRICITY_PRICE"
  50. ENERGY_PRICE = "ENERGY_PRICE"
  51. DEMAND_CHARGE = "DEMAND_CHARGE"
  52. BID_PRICE = "BID_PRICE"
  53. BID_LOAD = "BID_LOAD"
  54. BID_ENERGY = "BID_ENERGY"
  55. CHARGE_STATE = "CHARGE_STATE"
  56. LOAD_DISPATCH = "LOAD_DISPATCH"
  57. LOAD_CONTROL = "LOAD_CONTROL"
  58. class SI_SCALE_CODE(metaclass=Enum):
  59. p = "p"
  60. n = "n"
  61. micro = "micro"
  62. m = "m"
  63. c = "c"
  64. d = "d"
  65. k = "k"
  66. M = "M"
  67. G = "G"
  68. T = "T"
  69. none = "none"
  70. class OPT(metaclass=Enum):
  71. OPT_IN = "optIn"
  72. OPT_OUT = "optOut"
  73. class OPT_REASON(metaclass=Enum):
  74. ECONOMIC = "economic"
  75. EMERGENCY = "emergency"
  76. MUST_RUN = "mustRun"
  77. NOT_PARTICIPATING = "notParticipating"
  78. OUTAGE_RUN_STATUS = "outageRunStatus"
  79. OVERRIDE_STATUS = "overrideStatus"
  80. PARTICIPATING = "participating"
  81. X_SCHEDULE = "x-schedule"
  82. class READING_TYPE(metaclass=Enum):
  83. DIRECT_READ = "Direct Read"
  84. NET = "Net"
  85. ALLOCATED = "Allocated"
  86. ESTIMATED = "Estimated"
  87. SUMMED = "Summed"
  88. DERIVED = "Derived"
  89. MEAN = "Mean"
  90. PEAK = "Peak"
  91. HYBRID = "Hybrid"
  92. CONTRACT = "Contract"
  93. PROJECTED = "Projected"
  94. X_RMS = "x-RMS"
  95. X_NOT_APPLICABLE = "x-notApplicable"
  96. class REPORT_TYPE(metaclass=Enum):
  97. READING = "reading"
  98. USAGE = "usage"
  99. DEMAND = "demand"
  100. SET_POINT = "setPoint"
  101. DELTA_USAGE = "deltaUsage"
  102. DELTA_SET_POINT = "deltaSetPoint"
  103. DELTA_DEMAND = "deltaDemand"
  104. BASELINE = "baseline"
  105. DEVIATION = "deviation"
  106. AVG_USAGE = "avgUsage"
  107. AVG_DEMAND = "avgDemand"
  108. OPERATING_STATE = "operatingState"
  109. UP_REGULATION_CAPACITY_AVAILABLE = "upRegulationCapacityAvailable"
  110. DOWN_REGULATION_CAPACITY_AVAILABLE = "downRegulationCapacityAvailable"
  111. REGULATION_SETPOINT = "regulationSetpoint"
  112. STORED_ENERGY = "storedEnergy"
  113. TARGET_ENERGY_STORAGE = "targetEnergyStorage"
  114. AVAILABLE_ENERGY_STORAGE = "availableEnergyStorage"
  115. PRICE = "price"
  116. LEVEL = "level"
  117. POWER_FACTOR = "powerFactor"
  118. PERCENT_USAGE = "percentUsage"
  119. PERCENT_DEMAND = "percentDemand"
  120. X_RESOURCE_STATUS = "x-resourceStatus"
  121. class SIGNAL_TARGET_MRID(metaclass=Enum):
  122. THERMOSTAT = "Thermostat"
  123. STRIP_HEATER = "Strip_Heater"
  124. BASEBOARD_HEATER = "Baseboard_Heater"
  125. WATER_HEATER = "Water_Heater"
  126. POOL_PUMP = "Pool_Pump"
  127. SAUNA = "Sauna"
  128. HOT_TUB = "Hot_tub"
  129. SMART_APPLIANCE = "Smart_Appliance"
  130. IRRIGATION_PUMP = "Irrigation_Pump"
  131. MANAGED_COMMERCIAL_AND_INDUSTRIAL_LOADS = "Managed_Commercial_and_Industrial_Loads"
  132. SIMPLE_RESIDENTIAL_ON_OFF_LOADS = "Simple_Residential_On_Off_Loads"
  133. EXTERIOR_LIGHTING = "Exterior_Lighting"
  134. INTERIOR_LIGHTING = "Interior_Lighting"
  135. ELECTRIC_VEHICLE = "Electric_Vehicle"
  136. GENERATION_SYSTEMS = "Generation_Systems"
  137. LOAD_CONTROL_SWITCH = "Load_Control_Switch"
  138. SMART_INVERTER = "Smart_Inverter"
  139. EVSE = "EVSE"
  140. RESU = "RESU"
  141. ENERGY_MANAGEMENT_SYSTEM = "Energy_Management_System"
  142. SMART_ENERGY_MODULE = "Smart_Energy_Module"
  143. STORAGE = "Storage"
  144. class REPORT_NAME(metaclass=Enum):
  145. METADATA_HISTORY_USAGE = "METADATA_HISTORY_USAGE"
  146. HISTORY_USAGE = "HISTORY_USAGE"
  147. METADATA_HISTORY_GREENBUTTON = "METADATA_HISTORY_GREENBUTTON"
  148. HISTORY_GREENBUTTON = "HISTORY_GREENBUTTON"
  149. METADATA_TELEMETRY_USAGE = "METADATA_TELEMETRY_USAGE"
  150. TELEMETRY_USAGE = "TELEMETRY_USAGE"
  151. METADATA_TELEMETRY_STATUS = "METADATA_TELEMETRY_STATUS"
  152. TELEMETRY_STATUS = "TELEMETRY_STATUS"
  153. class STATUS_CODES(metaclass=Enum):
  154. OUT_OF_SEQUENCE = 450
  155. NOT_ALLOWED = 451
  156. INVALID_ID = 452
  157. NOT_RECOGNIZED = 453
  158. INVALID_DATA = 454
  159. COMPLIANCE_ERROR = 459
  160. SIGNAL_NOT_SUPPORTED = 460
  161. REPORT_NOT_SUPPORTED = 461
  162. TARGET_MISMATCH = 462
  163. NOT_REGISTERED_OR_AUTHORIZED = 463
  164. DEPLOYMENT_ERROR_OR_OTHER_ERROR = 469
  165. class SECURITY_LEVEL:
  166. STANDARD = 'STANDARD'
  167. HIGH = 'HIGH'
  168. _CURRENCIES = ("AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM",
  169. "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BOV", "BRL",
  170. "BSD", "BTN", "BWP", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW",
  171. "CLF", "CLP", "CNY", "COP", "COU", "CRC", "CUC", "CUP", "CVE", "CZK",
  172. "DJF", "DKK", "DOP", "DZD", "EEK", "EGP", "ERN", "ETB", "EUR", "FJD",
  173. "FKP", "GBP", "GEL", "GHS", "GIP", "GMD", "GNF", "GTQ", "GWP", "GYD",
  174. "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "INR", "IQD", "IRR",
  175. "ISK", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW",
  176. "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LVL",
  177. "LYD", "MAD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO",
  178. "MUR", "MVR", "MWK", "MXN", "MXV", "MYR", "MZN", "NAD", "NGN", "NIO",
  179. "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN",
  180. "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG",
  181. "SEK", "SGD", "SHP", "SLL", "SOS", "SRD", "STD", "SVC", "SYP", "SZL",
  182. "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH",
  183. "UGX", "USD", "USN", "USS", "UYI", "UYU", "UZS", "VEF", "VND", "VUV",
  184. "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR",
  185. "XFU", "XOF", "XPD", "XPF", "XPF", "XPF", "XPT", "XTS", "XXX", "YER",
  186. "ZAR", "ZMK", "ZWL")
  187. _ACCEPTABLE_UNITS = {'currency': _CURRENCIES,
  188. 'currencyPerKW': _CURRENCIES,
  189. 'currencyPerKWh': _CURRENCIES,
  190. 'currencyPerThm': _CURRENCIES,
  191. 'current': ('A',),
  192. 'energyApparent': ('VAh',),
  193. 'energyReactive': ('VARh',),
  194. 'energyReal': ('Wh',),
  195. 'frequency': ('Hz',),
  196. 'powerApparent': ('VA',),
  197. 'powerReactive': ('VAR',),
  198. 'powerReal': ('W',),
  199. 'pulseCount': ('count',),
  200. 'temperature': ('celsius', 'fahrenheit'),
  201. 'Therm': ('thm',),
  202. 'voltage': ('V',)}
  203. _MEASUREMENT_DESCRIPTIONS = {'currency': 'currency',
  204. 'currencyPerKW': 'currencyPerKW',
  205. 'currencyPerKWh': 'currencyPerKWh',
  206. 'currencyPerThm': 'currency',
  207. 'current': 'Current',
  208. 'energyApparent': 'ApparentEnergy',
  209. 'energyReactive': 'ReactiveEnergy',
  210. 'energyReal': 'RealEnergy',
  211. 'frequency': 'Frequency',
  212. 'powerApparent': 'ApparentPower',
  213. 'powerReactive': 'ReactivePower',
  214. 'powerReal': 'RealPower',
  215. 'pulseCount': 'pulse count',
  216. 'temperature': 'temperature',
  217. 'Therm': 'Therm',
  218. 'voltage': 'Voltage'}
  219. _MEASUREMENT_NAMESPACES = {'currency': 'oadr',
  220. 'currencyPerWK': 'oadr',
  221. 'currencyPerKWh': 'oadr',
  222. 'currencyPerThm': 'oadr',
  223. 'current': 'oadr',
  224. 'energyApparent': 'power',
  225. 'energyReactive': 'power',
  226. 'energyReal': 'power',
  227. 'frequency': 'oadr',
  228. 'powerApparent': 'power',
  229. 'powerReactive': 'power',
  230. 'powerReal': 'power',
  231. 'pulseCount': 'oadr',
  232. 'temperature': 'oadr',
  233. 'Therm': 'oadr',
  234. 'voltage': 'power',
  235. 'customUnit': 'oadr'}
  236. class MEASUREMENTS(metaclass=Enum):
  237. VOLTAGE = Measurement(name='voltage',
  238. description=_MEASUREMENT_DESCRIPTIONS['voltage'],
  239. unit=_ACCEPTABLE_UNITS['voltage'][0],
  240. acceptable_units=_ACCEPTABLE_UNITS['voltage'],
  241. scale='none')
  242. CURRENT = Measurement(name='current',
  243. description=_MEASUREMENT_DESCRIPTIONS['current'],
  244. unit=_ACCEPTABLE_UNITS['current'][0],
  245. acceptable_units=_ACCEPTABLE_UNITS['current'],
  246. scale='none')
  247. ENERGY_REAL = Measurement(name='energyReal',
  248. description=_MEASUREMENT_DESCRIPTIONS['energyReal'],
  249. unit=_ACCEPTABLE_UNITS['energyReal'][0],
  250. acceptable_units=_ACCEPTABLE_UNITS['energyReal'],
  251. scale='none')
  252. REAL_ENERGY = Measurement(name='energyReal',
  253. description=_MEASUREMENT_DESCRIPTIONS['energyReal'],
  254. unit=_ACCEPTABLE_UNITS['energyReal'][0],
  255. acceptable_units=_ACCEPTABLE_UNITS['energyReal'],
  256. scale='none')
  257. ACTIVE_ENERGY = Measurement(name='energyReal',
  258. description=_MEASUREMENT_DESCRIPTIONS['energyReal'],
  259. unit=_ACCEPTABLE_UNITS['energyReal'][0],
  260. acceptable_units=_ACCEPTABLE_UNITS['energyReal'],
  261. scale='none')
  262. ENERGY_REACTIVE = Measurement(name='energyReactive',
  263. description=_MEASUREMENT_DESCRIPTIONS['energyReactive'],
  264. unit=_ACCEPTABLE_UNITS['energyReactive'][0],
  265. acceptable_units=_ACCEPTABLE_UNITS['energyReactive'],
  266. scale='none')
  267. REACTIVE_ENERGY = Measurement(name='energyReactive',
  268. description=_MEASUREMENT_DESCRIPTIONS['energyReactive'],
  269. unit=_ACCEPTABLE_UNITS['energyReactive'][0],
  270. acceptable_units=_ACCEPTABLE_UNITS['energyReactive'],
  271. scale='none')
  272. ENERGY_APPARENT = Measurement(name='energyApparent',
  273. description=_MEASUREMENT_DESCRIPTIONS['energyApparent'],
  274. unit=_ACCEPTABLE_UNITS['energyApparent'][0],
  275. acceptable_units=_ACCEPTABLE_UNITS['energyApparent'],
  276. scale='none')
  277. APPARENT_ENERGY = Measurement(name='energyApparent',
  278. description=_MEASUREMENT_DESCRIPTIONS['energyApparent'],
  279. unit=_ACCEPTABLE_UNITS['energyApparent'][0],
  280. acceptable_units=_ACCEPTABLE_UNITS['energyApparent'],
  281. scale='none')
  282. ACTIVE_POWER = Measurement(name='powerReal',
  283. description=_MEASUREMENT_DESCRIPTIONS['powerReal'],
  284. unit=_ACCEPTABLE_UNITS['powerReal'][0],
  285. acceptable_units=_ACCEPTABLE_UNITS['powerReal'],
  286. scale='none',
  287. power_attributes=PowerAttributes(hertz=50,
  288. voltage=230,
  289. ac=True))
  290. REAL_POWER = Measurement(name='powerReal',
  291. description=_MEASUREMENT_DESCRIPTIONS['powerReal'],
  292. unit=_ACCEPTABLE_UNITS['powerReal'][0],
  293. acceptable_units=_ACCEPTABLE_UNITS['powerReal'],
  294. scale='none',
  295. power_attributes=PowerAttributes(hertz=50,
  296. voltage=230,
  297. ac=True))
  298. POWER_REAL = Measurement(name='powerReal',
  299. description=_MEASUREMENT_DESCRIPTIONS['powerReal'],
  300. unit=_ACCEPTABLE_UNITS['powerReal'][0],
  301. acceptable_units=_ACCEPTABLE_UNITS['powerReal'],
  302. scale='none',
  303. power_attributes=PowerAttributes(hertz=50,
  304. voltage=230,
  305. ac=True))
  306. REACTIVE_POWER = Measurement(name='powerReactive',
  307. description=_MEASUREMENT_DESCRIPTIONS['powerReactive'],
  308. unit=_ACCEPTABLE_UNITS['powerReactive'][0],
  309. acceptable_units=_ACCEPTABLE_UNITS['powerReactive'],
  310. scale='none',
  311. power_attributes=PowerAttributes(hertz=50,
  312. voltage=230,
  313. ac=True))
  314. POWER_REACTIVE = Measurement(name='powerReactive',
  315. description=_MEASUREMENT_DESCRIPTIONS['powerReactive'],
  316. unit=_ACCEPTABLE_UNITS['powerReactive'][0],
  317. acceptable_units=_ACCEPTABLE_UNITS['powerReactive'],
  318. scale='none',
  319. power_attributes=PowerAttributes(hertz=50,
  320. voltage=230,
  321. ac=True))
  322. APPARENT_POWER = Measurement(name='powerApparent',
  323. description=_MEASUREMENT_DESCRIPTIONS['powerApparent'],
  324. unit=_ACCEPTABLE_UNITS['powerApparent'][0],
  325. acceptable_units=_ACCEPTABLE_UNITS['powerApparent'],
  326. scale='none',
  327. power_attributes=PowerAttributes(hertz=50,
  328. voltage=230,
  329. ac=True))
  330. POWER_APPARENT = Measurement(name='powerApparent',
  331. description=_MEASUREMENT_DESCRIPTIONS['powerApparent'],
  332. unit=_ACCEPTABLE_UNITS['powerApparent'][0],
  333. acceptable_units=_ACCEPTABLE_UNITS['powerApparent'],
  334. scale='none',
  335. power_attributes=PowerAttributes(hertz=50,
  336. voltage=230,
  337. ac=True))
  338. FREQUENCY = Measurement(name='frequency',
  339. description=_MEASUREMENT_DESCRIPTIONS['frequency'],
  340. unit=_ACCEPTABLE_UNITS['frequency'][0],
  341. acceptable_units=_ACCEPTABLE_UNITS['frequency'],
  342. scale='none')
  343. PULSE_COUNT = Measurement(name='pulseCount',
  344. description=_MEASUREMENT_DESCRIPTIONS['pulseCount'],
  345. unit=_ACCEPTABLE_UNITS['pulseCount'][0],
  346. acceptable_units=_ACCEPTABLE_UNITS['pulseCount'],
  347. pulse_factor=1000)
  348. TEMPERATURE = Measurement(name='temperature',
  349. description=_MEASUREMENT_DESCRIPTIONS['temperature'],
  350. unit=_ACCEPTABLE_UNITS['temperature'][0],
  351. acceptable_units=_ACCEPTABLE_UNITS['temperature'],
  352. scale='none')
  353. THERM = Measurement(name='Therm',
  354. description=_MEASUREMENT_DESCRIPTIONS['Therm'],
  355. unit=_ACCEPTABLE_UNITS['Therm'][0],
  356. acceptable_units=_ACCEPTABLE_UNITS['Therm'],
  357. scale='none')
  358. CURRENCY = Measurement(name='currency',
  359. description=_MEASUREMENT_DESCRIPTIONS['currency'],
  360. unit=_CURRENCIES[0],
  361. acceptable_units=_CURRENCIES,
  362. scale='none')
  363. CURRENCY_PER_KW = Measurement(name='currencyPerKW',
  364. description=_MEASUREMENT_DESCRIPTIONS['currencyPerKW'],
  365. unit=_CURRENCIES[0],
  366. acceptable_units=_CURRENCIES,
  367. scale='none')
  368. CURRENCY_PER_KWH = Measurement(name='currencyPerKWh',
  369. description=_MEASUREMENT_DESCRIPTIONS['currencyPerKWh'],
  370. unit=_CURRENCIES[0],
  371. acceptable_units=_CURRENCIES,
  372. scale='none')
  373. CURRENCY_PER_THM = Measurement(name='currencyPerThm',
  374. description=_MEASUREMENT_DESCRIPTIONS['currencyPerThm'],
  375. unit=_CURRENCIES[0],
  376. acceptable_units=_CURRENCIES,
  377. scale='none')