Skip to content

Commit

Permalink
Add unit Hertz
Browse files Browse the repository at this point in the history
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: #71
  • Loading branch information
bengarrett1971 committed Feb 21, 2020
1 parent a52e474 commit 22306f0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions ocpp/v16/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ class UnitOfMeasure:
fahrenheit = "Fahrenheit"
k = "K"
percent = "Percent"
hertz = "Hertz"


class UnlockStatus:
Expand Down
3 changes: 2 additions & 1 deletion ocpp/v16/schemas/MeterValues.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@
"Celcius",
"Celsius",
"Fahrenheit",
"Percent"
"Percent",
"Hertz"
]
}
},
Expand Down
26 changes: 26 additions & 0 deletions tests/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,29 @@ def test_serializing_decimal():
[decimal.Decimal(2.000001)],
cls=_DecimalEncoder
) == "[2.0]"


def test_validate_meter_values_hertz():
"""
Tests that a unit of measure called "Hertz" is permitted in validation.
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, page 34).
"""
message = Call(
unique_id="1234",
action="MeterValues",
payload={
'connectorId': 1,
'transactionId': 123456789,
'meterValue': [{
'timestamp': '2020-02-21T13:48:45.459756Z',
'sampledValue': [{
"value": "50.0",
"measurand": "Frequency",
"unit": "Hertz",
}]
}]
}
)

validate_payload(message, ocpp_version="1.6")
1 change: 1 addition & 0 deletions tests/v16/test_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ def test_unit_of_measure():
assert UnitOfMeasure.fahrenheit == "Fahrenheit"
assert UnitOfMeasure.k == "K"
assert UnitOfMeasure.percent == "Percent"
assert UnitOfMeasure.hertz == "Hertz"


def test_unlock_status():
Expand Down

0 comments on commit 22306f0

Please sign in to comment.