{% extends "base.html" %} {% block title %}{{ device.name }} — Battery Tracker{% endblock %} {% block content %} {% if device.parent %}
← {{ device.parent.name }} / {{ device.name }}
{% endif %}

{{ device.name }}

{% if ha_enabled and device.ha_entity_id and ha_live_pct is not none %} {% set _pct = ha_live_pct %} {% set _fill = ((_pct / 100) * 48) | int %} {% if _pct < 20 %}{% set _color = '#ef4444' %} {% elif _pct < 60 %}{% set _color = '#f59e0b' %} {% else %}{% set _color = '#22c55e' %}{% endif %}
{% if _fill > 0 %} {% endif %} {{ _pct }}%
{% endif %} {% if device.device_type %} {% endif %} {% if device.battery_size %} {% endif %} {% if device.has_mixed_brands() %} {% endif %} {% if device.location %} {% endif %} {% if device.is_subcomponent() and device.parent %} {% if device.parent.device_type %} {% endif %} {% if device.parent.location %} {% endif %} {% endif %} {% if device.notes %} {% endif %} {% if device.parent %} {% endif %} {% if ha_enabled and device.ha_entity_id %} {% endif %}
Slots {% if device.has_children() %}{% set ns = namespace(inst=0, slots=0) %}{% for c in device.children %}{% set ns.inst = ns.inst + c.installed_count() %}{% set ns.slots = ns.slots + c.battery_slots %}{% endfor %}{{ ns.inst }} / {{ ns.slots }} (across sub-components){% else %}{{ device.installed_count() }} / {{ device.battery_slots }} used{% endif %}
Type {{ device.device_type }}
Battery Size {{ device.battery_size }}
Warning ⚠ Mixed brands installed
Location {{ device.location }}
Type {{ device.parent.device_type }} (inherited)
Location {{ device.parent.location }} (inherited)
Notes {{ device.notes }}
Part of {{ device.parent.name }}
HA Live % {% if ha_live_pct is not none %} {% if ha_live_pct < 20 %} ⚠ {{ ha_live_pct }}% {% else %} {{ ha_live_pct }}% {% endif %} {% else %} {% endif %}
{% if device.children or not device.is_subcomponent() %}
{% if device.children %}

Sub-components

{% for child in device.children %} {% set child_free = child.battery_slots - child.installed_count() %} {% set child_batteries = children_avail.get(child.id, []) %}
{{ child.name }} {{ child.installed_count() }}/{{ child.battery_slots }} slots · {{ child.battery_size }}{% if child.ha_entity_id %} · HA{% endif %} {% if child_free > 0 and child_batteries %}{{ child_batteries|length }} available{% endif %} View
{% if child_free <= 0 %}

No free slots.

{% elif not child_batteries %}

No compatible batteries available.

{% else %}
{% for b in child_batteries %}
{% endfor %}
{% endif %}
{% endfor %}
{% else %}

Sub-components

No sub-components. Batteries are tracked at the device level.

{% endif %} + Add Sub-component
{% endif %} {% if device.has_children() %}

Installed Batteries

{% if flat_installed %}
{% if ha_enabled %}{% endif %} {% for b, comp_name, comp_id in flat_installed %} {% if ha_enabled %} {% endif %} {% endfor %}
ComponentLabelBrandBat %Last Charged
{{ comp_name }} {{ b.label }} {{ b.brand }} {% if b.battery_percentage is not none %} {% if b.battery_percentage < 20 %}⚠ {{ b.battery_percentage }}% {% else %}{{ b.battery_percentage }}%{% endif %} {% else %}—{% endif %} {{ b.charge_logs[-1].charged_date if b.charge_logs else '—' }}
{% else %}

No batteries installed across sub-components.

{% endif %}
{% endif %} {% if not device.has_children() %}

Install Batteries

{% set free_slots = device.battery_slots - device.installed_count() %}

{{ free_slots }} slot(s) free{% if device.battery_size %} — showing {{ device.battery_size }} batteries only{% endif %}

Brand Qty

{% endif %} {% if not device.has_children() %}

Installed Batteries

{% set installed = device.batteries | selectattr('status', 'eq', 'installed') | list %} {% if installed %}
{% if ha_enabled %}{% endif %} {% for b in installed %} {% if ha_enabled %} {% endif %} {% endfor %}
LabelBrandBat %Last ChargedNotesActions
{{ b.label }} {{ b.brand }} {% if b.battery_percentage is not none %} {% if b.battery_percentage < 20 %} ⚠ {{ b.battery_percentage }}% {% else %}{{ b.battery_percentage }}%{% endif %} {% else %}—{% endif %} {{ b.charge_logs[-1].charged_date if b.charge_logs else '—' }} {{ b.notes or '—' }}
{% else %}

No batteries installed.

{% endif %} {% if installed %}
{% endif %}
{% if installed %}

Charge All Installed Batteries

{% endif %}

Install Specific Batteries{% if device.battery_size %} ({{ device.battery_size }} only){% endif %}

{% if available_batteries %}
{% for b in available_batteries %}
{% endfor %}
{% else %}

No compatible batteries available.

{% endif %}
{% endif %}

Logbook

{% if logbook_entries %}
{% for entry in logbook_entries %}
{{ entry.recorded_at }}
{{ entry.body }}
{% endfor %}
{% else %}

No logbook entries yet.

{% endif %}

Add Entry

Edit Device

{% if not device.has_children() %}
{% endif %} {% if not device.is_subcomponent() %}
{% set _preset_types = ['Remote Control','Game Controller','Flashlight','Lock','Sensor','Toy','Clock','Smoke Detector'] %}
{% endif %} {% if not device.has_children() %}
{% set _preset_sizes = ['AA','AAA','C','D','9V','CR2032','CR2025','CR2016','18650','14500','16340','26650','LR44/AG13'] %}
{% endif %} {% if not device.is_subcomponent() %}
{% endif %}
{% if not device.has_children() %}
{% endif %} {% if ha_enabled %}
{% endif %}

Delete Device

Deleting this device will unassign all installed batteries and mark them available. {% if device.has_children() %} Sub-components ({{ device.children|map(attribute='name')|join(', ') }}) will become independent devices. {% endif %}

← Back to Devices {% if ha_enabled %} {% endif %} {% endblock %}