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