Skip to content

Commit

Permalink
OCPP 1.6: support multiple temperature readings (#986)
Browse files Browse the repository at this point in the history
* OCPP 1.6: support multiple teamperature readings
Add optional location to temperature type
* Add a simulated temperature to JsYetiSimulator powermeter
* Bump libocpp dependency

---------

Signed-off-by: Kai-Uwe Hermann <[email protected]>
  • Loading branch information
hikinggrass authored Dec 10, 2024
1 parent 39fe934 commit 7771a02
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ libevse-security:
# OCPP
libocpp:
git: https://github.com/EVerest/libocpp.git
git_tag: 469629c615e369f4bb77b3b2f861e0d56b550d15
git_tag: 2f005e04460149f71a223e381733b2e2471abdc0
cmake_condition: "EVEREST_DEPENDENCY_ENABLED_LIBOCPP"
# Josev
Josev:
Expand Down
3 changes: 3 additions & 0 deletions modules/OCPP/OCPP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ void OCPP::init_evse_subscriptions() {
// soc is present, so add this to the measurement
measurement.soc_Percent = ocpp::StateOfCharge{this->evse_soc_map[evse_id].value()};
}
if (powermeter.temperatures.has_value()) {
measurement.temperature_C = conversions::to_ocpp_temperatures(powermeter.temperatures.value());
}
this->charge_point->on_meter_values(evse_id, measurement);
});

Expand Down
13 changes: 13 additions & 0 deletions modules/OCPP/conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,19 @@ ocpp::Powermeter to_ocpp_power_meter(const types::powermeter::Powermeter& powerm
return ocpp_powermeter;
}

std::vector<ocpp::Temperature> to_ocpp_temperatures(const std::vector<types::temperature::Temperature>& temperatures) {
std::vector<ocpp::Temperature> ocpp_temperatures;
for (const auto temperature : temperatures) {
ocpp::Temperature ocpp_temperature;
ocpp_temperature.value = temperature.temperature;
if (temperature.location.has_value()) {
ocpp_temperature.location = temperature.location.value();
}
ocpp_temperatures.push_back(ocpp_temperature);
}
return ocpp_temperatures;
}

ocpp::v201::HashAlgorithmEnum to_ocpp_hash_algorithm_enum(const types::iso15118_charger::HashAlgorithm hash_algorithm) {
switch (hash_algorithm) {
case types::iso15118_charger::HashAlgorithm::SHA256:
Expand Down
3 changes: 3 additions & 0 deletions modules/OCPP/conversions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ ocpp::v16::BootReasonEnum to_ocpp_boot_reason_enum(const types::system::BootReas
/// \brief Converts a given types::powermeter::Powermeter \p powermeter to a ocpp::Powermeter
ocpp::Powermeter to_ocpp_power_meter(const types::powermeter::Powermeter& powermeter);

/// \brief Converts a given vector of types::temperature::Temperature \p powermeter to a vector of ocpp::Temperature
std::vector<ocpp::Temperature> to_ocpp_temperatures(const std::vector<types::temperature::Temperature>& temperatures);

/// \brief Converts a given types::iso15118_charger::HashAlgorithm \p hash_algorithm to a ocpp::v201::HashAlgorithmEnum.
ocpp::v201::HashAlgorithmEnum to_ocpp_hash_algorithm_enum(const types::iso15118_charger::HashAlgorithm hash_algorithm);

Expand Down
6 changes: 6 additions & 0 deletions modules/simulation/JsYetiSimulator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,12 @@ function power_meter_external(p) {
L2: p.freqL2,
L3: p.freqL3,
},
temperatures: [
{
temperature: p.tempL1,
location: "Body"
}
]
});
}

Expand Down
5 changes: 3 additions & 2 deletions types/temperature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ types:
identification:
description: A (vendor specific) ID if required
type: string


location:
description: Location of the measurement
type: string

0 comments on commit 7771a02

Please sign in to comment.