Add optional Home Assistant integration for battery percentage tracking
This commit is contained in:
@@ -28,6 +28,12 @@
|
||||
<td style="border:none;">{{ device.notes }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if ha_enabled and device.ha_entity_id %}
|
||||
<tr>
|
||||
<td style="padding:0.3rem 1rem 0.3rem 0;font-weight:600;color:#64748b;border:none;">HA Entity</td>
|
||||
<td style="border:none;"><code>{{ device.ha_entity_id }}</code></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -99,13 +105,22 @@ function addInstallRow() {
|
||||
<div class="table-wrap">
|
||||
<table class="responsive-table">
|
||||
<thead>
|
||||
<tr><th>Label</th><th>Brand</th><th>Notes</th><th>Actions</th></tr>
|
||||
<tr><th>Label</th><th>Brand</th>{% if ha_enabled %}<th>Bat %</th>{% endif %}<th>Notes</th><th>Actions</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for b in installed %}
|
||||
<tr>
|
||||
<td data-label="Label"><a href="{{ url_for('battery_detail', battery_id=b.id) }}">{{ b.label }}</a></td>
|
||||
<td data-label="Brand">{{ b.brand }}</td>
|
||||
{% if ha_enabled %}
|
||||
<td data-label="Bat %">
|
||||
{% 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="Notes" class="text-muted">{{ b.notes or '—' }}</td>
|
||||
<td data-label="Actions">
|
||||
<form class="inline" method="post" action="{{ url_for('battery_unassign', battery_id=b.id) }}">
|
||||
@@ -180,6 +195,14 @@ function addInstallRow() {
|
||||
<label for="edit-notes">Notes</label>
|
||||
<textarea id="edit-notes" name="notes">{{ device.notes or '' }}</textarea>
|
||||
</div>
|
||||
{% if ha_enabled %}
|
||||
<div class="form-group">
|
||||
<label for="edit-ha-entity">Home Assistant Entity ID</label>
|
||||
<input type="text" id="edit-ha-entity" name="ha_entity_id"
|
||||
value="{{ device.ha_entity_id or '' }}"
|
||||
placeholder="e.g. sensor.tv_remote_battery">
|
||||
</div>
|
||||
{% endif %}
|
||||
<button class="btn btn-primary" type="submit">Save Changes</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user