Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

range and energy charged since mode switch #1436

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/modules/web_themes/standard_legacy/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@
<span class="charge-point-set-current">--</span>
</div>
<div class="col-3 collPlus">
<span class="charge-point-energy-since-plugged">--</span><span
class="charge-point-range-since-plugged" data-consumption="0"></span>
<span class="charge-point-energy-since-mode-switch">--</span><span
class="charge-point-range-since-mode-switch"></span>
</div>
</div>
<div class="form-row">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -790,15 +790,14 @@ function processChargePointMessages(mqttTopic, mqttPayload) {
// console.log("charged since plugged counter");
var index = getIndex(mqttTopic); // extract number between two / /
var parent = $('.charge-point-card[data-cp="' + index + '"]'); // get parent row element for charge point
var element = parent.find('.charge-point-energy-since-plugged'); // now get parents respective child element
var element = parent.find('.charge-point-energy-since-mode-switch'); // now get parents respective child element
var logData = JSON.parse(mqttPayload);
var energyCharged = parseFloat(logData.imported_since_plugged) / 1000;
var energyCharged = parseFloat(logData.imported_since_mode_switch) / 1000;
if (isNaN(energyCharged)) {
energyCharged = 0;
}
element.text(energyCharged.toLocaleString(undefined, { minimumFractionDigits: 1, maximumFractionDigits: 1 }) + ' kWh');
var rangeChargedElement = parent.find('.charge-point-range-since-plugged'); // now get parents child element
var consumption = parseFloat($(rangeChargedElement).data('consumption'));
var rangeChargedElement = parent.find('.charge-point-range-since-mode-switch'); // now get parents child element
var rangeCharged = parseFloat(logData.range_charged);
rangeCharged = ' / ' + rangeCharged.toLocaleString(undefined, { minimumFractionDigits: 1, maximumFractionDigits: 1 }) + ' km';
$(rangeChargedElement).text(rangeCharged);
Expand Down Expand Up @@ -931,17 +930,6 @@ function processChargePointMessages(mqttTopic, mqttPayload) {
// element.prop('checked', false);
priorityElement.bootstrapToggle('off', true); // do not fire a changed-event to prevent a loop!
}
// "average_consumption" int unit: Wh/100km
var rangeChargedElement = parent.find('.charge-point-range-since-plugged');
rangeChargedElement.data('consumption', configData.average_consumption).attr('data-consumption', configData.average_consumption);
// if already energyCharged-displayed, update rangeCharged
var energyCharged = parseFloat(parent.find('.charge-point-energy-since-plugged').text().replace(',', '.')); // now get parents respective energyCharged child element
var rangeCharged = '';
if (!isNaN(energyCharged) && configData.average_consumption > 0) {
rangeCharged = (energyCharged / configData.average_consumption) * 100;
rangeCharged = ' / ' + rangeCharged.toLocaleString(undefined, { minimumFractionDigits: 1, maximumFractionDigits: 1 }) + ' km';
}
$(rangeChargedElement).text(rangeCharged);
}
// else if ( mqttTopic.match( /^openwb\/lp\/[0-9]+\/kWhactualcharged$/i ) ) {
// // energy charged since reset of limitation
Expand Down