Skip to content

Commit 8d55e91

Browse files
Add unit Hertz
Updated the MeterValues schema to allow a unit of measure called "Hertz". This was missing from the original 1.6 spec, but was added as an errata (see the OCPP 1.6 Errata sheet, v4.0 Release, 2019-10-23, on page 34). Fixes: mobilityhouse#71
1 parent a063a68 commit 8d55e91

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

ocpp/v16/enums.py

+1
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ class UnitOfMeasure:
467467
fahrenheit = "Fahrenheit"
468468
k = "K"
469469
percent = "Percent"
470+
hertz = "Hertz"
470471

471472

472473
class UnlockStatus:

ocpp/v16/schemas/MeterValues.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@
123123
"Celcius",
124124
"Celsius",
125125
"Fahrenheit",
126-
"Percent"
126+
"Percent",
127+
"Hertz"
127128
]
128129
}
129130
},

tests/test_messages.py

+26
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,29 @@ def test_serializing_decimal():
232232
[decimal.Decimal(2.000001)],
233233
cls=_DecimalEncoder
234234
) == "[2.0]"
235+
236+
237+
def test_validate_meter_values_hertz():
238+
"""
239+
Tests that a unit of measure called "Hertz" is permitted in validation.
240+
This was missing from the original 1.6 spec, but was added as an errata
241+
(see the OCPP 1.6 Errata sheet, v4.0 Release, 2019-10-23, page 34).
242+
"""
243+
message = Call(
244+
unique_id="1234",
245+
action="MeterValues",
246+
payload={
247+
'connectorId': 1,
248+
'transactionId': 123456789,
249+
'meterValue': [{
250+
'timestamp': '2020-02-21T13:48:45.459756Z',
251+
'sampledValue': [{
252+
"value": "50.0",
253+
"measurand": "Frequency",
254+
"unit": "Hertz",
255+
}]
256+
}]
257+
}
258+
)
259+
260+
validate_payload(message, ocpp_version="1.6")

tests/v16/test_enums.py

+1
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ def test_unit_of_measure():
288288
assert UnitOfMeasure.fahrenheit == "Fahrenheit"
289289
assert UnitOfMeasure.k == "K"
290290
assert UnitOfMeasure.percent == "Percent"
291+
assert UnitOfMeasure.hertz == "Hertz"
291292

292293

293294
def test_unlock_status():

0 commit comments

Comments
 (0)