Add em states from dbus
parent
0d17f86ccc
commit
441705087f
|
|
@ -34,11 +34,12 @@ class DashboardApp {
|
|||
this.chargerColumns = [
|
||||
{ key: 'id', label: 'ID', hidden: true },
|
||||
{ key: 'name', label: 'Name' },
|
||||
{ key: 'assignedCar', label: 'Car' },
|
||||
{ key: 'energyManagerMode', label: 'Energy manager mode' },
|
||||
{ key: 'connected', label: 'Connected' },
|
||||
{ key: 'status', label: 'Status' },
|
||||
{ key: 'chargingCurrent', label: 'Charging current' },
|
||||
{ key: 'chargingAllowed', label: 'Charging allowed' },
|
||||
{ key: 'currentPower', label: 'Current power' },
|
||||
{ key: 'pluggedIn', label: 'Plugged in' },
|
||||
{ key: 'version', label: 'Version' },
|
||||
{ key: 'sessionEnergy', label: 'Session energy' },
|
||||
{ key: 'temperature', label: 'Temperature' },
|
||||
|
|
@ -735,27 +736,42 @@ class DashboardApp {
|
|||
this.elements.chargerEmptyRow.classList.toggle('hidden', hasChargers);
|
||||
}
|
||||
|
||||
formatNumber(value, unit) {
|
||||
if (!Number.isFinite(value))
|
||||
return '—';
|
||||
|
||||
const rounded = Number.parseFloat(value.toFixed(2));
|
||||
return unit ? `${rounded} ${unit}` : String(rounded);
|
||||
}
|
||||
|
||||
formatChargerValue(key, value) {
|
||||
if (value === null || value === undefined || value === '')
|
||||
return '—';
|
||||
|
||||
if ((key === 'currentPower' || key === 'sessionEnergy') && typeof value === 'number') {
|
||||
if (!Number.isFinite(value))
|
||||
return '—';
|
||||
const unit = key === 'currentPower' ? 'kW' : 'kWh';
|
||||
if (key === 'currentPower') {
|
||||
value = value / 1000;
|
||||
return `${value.toFixed(2)} ${unit}`;
|
||||
}
|
||||
if (key === 'energyManagerMode') {
|
||||
const modes = {
|
||||
0: 'Quick',
|
||||
1: 'Eco',
|
||||
2: 'Eco + Time'
|
||||
};
|
||||
if (value in modes)
|
||||
return modes[value];
|
||||
return Number.isFinite(value) ? `Unknown (${value})` : '—';
|
||||
}
|
||||
|
||||
return `${value.toFixed(2)} ${unit}`;
|
||||
if ((key === 'currentPower' || key === 'sessionEnergy') && typeof value === 'number') {
|
||||
const unit = key === 'currentPower' ? 'kW' : 'kWh';
|
||||
if (key === 'currentPower')
|
||||
return this.formatNumber(value / 1000, unit);
|
||||
|
||||
return this.formatNumber(value, unit);
|
||||
}
|
||||
|
||||
if (typeof value === 'boolean')
|
||||
return value ? 'Yes' : 'No';
|
||||
|
||||
if (typeof value === 'number')
|
||||
return Number.isFinite(value) ? String(value) : '—';
|
||||
return this.formatNumber(value);
|
||||
|
||||
if (typeof value === 'string')
|
||||
return value;
|
||||
|
|
|
|||
|
|
@ -240,7 +240,6 @@
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
max-width: 1100px;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
flex: 1 1 auto;
|
||||
|
|
@ -310,6 +309,7 @@
|
|||
|
||||
.table-wrapper {
|
||||
overflow-x: auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table.chargers-table {
|
||||
|
|
@ -625,11 +625,12 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Name</th>
|
||||
<th scope="col">Car</th>
|
||||
<th scope="col">Energy manager mode</th>
|
||||
<th scope="col">Connected</th>
|
||||
<th scope="col">Status</th>
|
||||
<th scope="col">Charging current</th>
|
||||
<th scope="col">Charging allowed</th>
|
||||
<th scope="col">Current power</th>
|
||||
<th scope="col">Plugged in</th>
|
||||
<th scope="col">Version</th>
|
||||
<th scope="col">Session energy</th>
|
||||
<th scope="col">Temperature</th>
|
||||
|
|
@ -638,7 +639,7 @@
|
|||
</thead>
|
||||
<tbody id="chargerTableBody">
|
||||
<tr id="chargerEmptyRow" class="empty-row">
|
||||
<td colspan="10">No chargers loaded yet.</td>
|
||||
<td colspan="11">No chargers loaded yet.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -410,6 +410,8 @@ QJsonObject EvDashEngine::packCharger(Thing *charger) const
|
|||
foreach (const QVariant &chargingInfoVariant, m_energyManagerClient->chargingInfos()) {
|
||||
QVariantMap chargingInfo = chargingInfoVariant.toMap();
|
||||
if (chargingInfo.value("evChargerId").toUuid() == charger->id()) {
|
||||
|
||||
// Set assigned car name
|
||||
if (chargingInfo.value("assignedCarId").toString().isEmpty()) {
|
||||
chargerObject.insert("assignedCar", "");
|
||||
} else {
|
||||
|
|
@ -420,9 +422,14 @@ QJsonObject EvDashEngine::packCharger(Thing *charger) const
|
|||
chargerObject.insert("assignedCar", "");
|
||||
}
|
||||
}
|
||||
|
||||
// Set energyManagerMode
|
||||
chargerObject.insert("energyManagerMode", chargingInfo.value("chargingMode").toInt());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
chargerObject.insert("connected", charger->stateValue("connected").toBool());
|
||||
chargerObject.insert("status", charger->stateValue("status").toString());
|
||||
chargerObject.insert("chargingCurrent", charger->stateValue("maxChargingCurrent").toDouble());
|
||||
|
|
|
|||
Loading…
Reference in New Issue