Add optional Home Assistant integration for battery percentage tracking
This commit is contained in:
@@ -26,6 +26,15 @@
|
||||
<div style="font-size:1.8rem;font-weight:700;color:var(--count-retired);">{{ retired }}</div>
|
||||
<div class="text-muted">Retired</div>
|
||||
</div>
|
||||
{% if ha_enabled %}
|
||||
{% set low_pct = batteries | selectattr('battery_percentage', 'ne', none) | selectattr('battery_percentage', 'lt', 20) | list %}
|
||||
{% if low_pct %}
|
||||
<div class="card" style="flex:1;min-width:120px;text-align:center;border:2px solid #f59e0b;">
|
||||
<div style="font-size:1.8rem;font-weight:700;color:#f59e0b;">{{ low_pct|length }}</div>
|
||||
<div class="text-muted">Low Battery</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
@@ -38,7 +47,8 @@
|
||||
<label style="display:block;cursor:pointer;margin-bottom:0.3rem;font-size:0.875rem;"><input type="checkbox" data-col="capacity" onchange="toggleCol(this)" style="margin-right:0.4rem;"> Capacity</label>
|
||||
<label style="display:block;cursor:pointer;margin-bottom:0.3rem;font-size:0.875rem;"><input type="checkbox" data-col="storage" onchange="toggleCol(this)" style="margin-right:0.4rem;"> Storage Location</label>
|
||||
<label style="display:block;cursor:pointer;margin-bottom:0.3rem;font-size:0.875rem;"><input type="checkbox" data-col="purchase" onchange="toggleCol(this)" style="margin-right:0.4rem;"> Purchase Date</label>
|
||||
<label style="display:block;cursor:pointer;font-size:0.875rem;"><input type="checkbox" data-col="cycles" onchange="toggleCol(this)" style="margin-right:0.4rem;"> Charge Cycles</label>
|
||||
<label style="display:block;cursor:pointer;margin-bottom:0.3rem;font-size:0.875rem;"><input type="checkbox" data-col="cycles" onchange="toggleCol(this)" style="margin-right:0.4rem;"> Charge Cycles</label>
|
||||
{% if ha_enabled %}<label style="display:block;cursor:pointer;font-size:0.875rem;"><input type="checkbox" data-col="ha-pct" onchange="toggleCol(this)" style="margin-right:0.4rem;"> Battery %</label>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -150,6 +160,7 @@
|
||||
<th class="col-storage" style="display:none;">Storage</th>
|
||||
<th class="col-purchase" style="display:none;">Purchase Date</th>
|
||||
<th class="col-cycles" style="display:none;">Cycles</th>
|
||||
{% if ha_enabled %}<th class="col-ha-pct" style="display:none;">Bat %</th>{% endif %}
|
||||
<th>Status</th>
|
||||
<th>Assigned To</th>
|
||||
<th>Actions</th>
|
||||
@@ -172,6 +183,15 @@
|
||||
<td data-label="Storage" class="col-storage" style="display:none;">{{ b.storage_location or '—' }}</td>
|
||||
<td data-label="Purchase" class="col-purchase" style="display:none;">{{ b.purchase_date or '—' }}</td>
|
||||
<td data-label="Cycles" class="col-cycles" style="display:none;">{{ b.charge_cycles or '—' }}</td>
|
||||
{% if ha_enabled %}
|
||||
<td data-label="Bat %" class="col-ha-pct" style="display:none;">
|
||||
{% if b.battery_percentage is not none %}
|
||||
{% if b.battery_percentage < 20 %}
|
||||
<span class="badge badge-warning" title="Low — consider replacing">⚠ {{ b.battery_percentage }}%</span>
|
||||
{% else %}{{ b.battery_percentage }}%{% endif %}
|
||||
{% else %}—{% endif %}
|
||||
</td>
|
||||
{% endif %}
|
||||
<td data-label="Status">
|
||||
<span class="badge badge-{{ b.status }}">{{ b.status|capitalize }}</span>
|
||||
</td>
|
||||
@@ -358,7 +378,7 @@ updateToolbar();
|
||||
|
||||
// Column picker
|
||||
var COL_KEY = 'battery_cols';
|
||||
var ALL_COLS = ['chemistry','capacity','storage','purchase','cycles'];
|
||||
var ALL_COLS = ['chemistry','capacity','storage','purchase','cycles'{% if ha_enabled %},'ha-pct'{% endif %}];
|
||||
|
||||
function toggleCol(cb) {
|
||||
var col = cb.dataset.col;
|
||||
|
||||
Reference in New Issue
Block a user