{# Hosted trains. Add/remove happens via the openlcbCS JSON topic; a CS must already be wired into ctx._openlcb_cs via startup hook. #}
{% if hosted_error %}
Hosted-train action failed: {{ hosted_error }}
{% endif %} {% if not hosted %}

No hosted trains. Use the form below to add one (requires a CommandStationNode wired into ctx._openlcb_cs in a startup hook — the form 400s with a helpful message otherwise).

{% else %} {% for loco in hosted %} {% endfor %}
Name DCC address Node ID Alias Controller Consist
{{ loco.name }} {{ loco.address }} {% if loco.long_address %}long{% endif %} {{ loco.node_id }} {{ loco.alias }} {% if loco.controller == '00.00.00.00.00.00' %} unassigned {% else %} {{ loco.controller }} {% endif %} {% if loco.consist_members %} {{ loco.consist_members | length }} member{{ 's' if loco.consist_members | length != 1 }} {% else %} — {% endif %}
{% endif %}