Skip to content

Commit

Permalink
API: publish ocpp schedule only when updated
Browse files Browse the repository at this point in the history
Signed-off-by: Cornelius Claussen <[email protected]>
  • Loading branch information
corneliusclaussen committed Mar 8, 2024
1 parent e994710 commit 7b5104b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
7 changes: 2 additions & 5 deletions modules/API/API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,8 @@ void API::init() {
}
});

this->r_ocpp.at(0)->subscribe_charging_schedules([this, &var_ocpp_schedule](json schedule) {
std::scoped_lock lock(ocpp_data_mutex);
this->ocpp_charging_schedule = schedule;
});
this->r_ocpp.at(0)->subscribe_charging_schedules(
[this, &var_ocpp_schedule](json schedule) { this->mqtt.publish(var_ocpp_schedule, schedule.dump()); });
}

std::string var_info = api_base + "info/var/info";
Expand All @@ -519,7 +517,6 @@ void API::init() {
{
std::scoped_lock lock(ocpp_data_mutex);
this->mqtt.publish(var_ocpp_connection_status, this->ocpp_connection_status);
this->mqtt.publish(var_ocpp_schedule, ocpp_charging_schedule.dump());
}

next_tick += NOTIFICATION_PERIOD;
Expand Down
1 change: 0 additions & 1 deletion modules/API/API.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ class API : public Everest::ModuleBase {
std::unique_ptr<LimitDecimalPlaces> limit_decimal_places;

std::mutex ocpp_data_mutex;
json ocpp_charging_schedule;
std::string ocpp_connection_status = "unknown";
// ev@211cfdbe-f69a-4cd6-a4ec-f8aaa3d1b6c8:v1
};
Expand Down

0 comments on commit 7b5104b

Please sign in to comment.