{% if schedules_by_date %}
{% for date_key, date_group in schedules_by_date.items() %}

{{ date_group.date_display }}

{{ date_group.actions|length }} action{{ 's' if date_group.actions|length != 1 else '' }}

{% for item in date_group.actions %}
{% if item.schedule.action_type == 'start' %} Start {% elif item.schedule.action_type == 'stop' %} Stop {% elif item.schedule.action_type == 'download' %} Download {% else %} {{ item.schedule.action_type }} {% endif %} {% if item.schedule.execution_status == 'pending' %} Pending {% elif item.schedule.execution_status == 'completed' %} Completed {% elif item.schedule.execution_status == 'failed' %} Failed {% elif item.schedule.execution_status == 'cancelled' %} Cancelled {% endif %}
{{ item.schedule.scheduled_time|local_datetime('%H:%M') if item.schedule.scheduled_time else 'N/A' }}
{% if item.location %} {% endif %} {% if item.schedule.executed_at %}
Executed {{ item.schedule.executed_at|local_datetime('%H:%M') }}
{% endif %}
{% if item.schedule.error_message %}
Error: {{ item.schedule.error_message }}
{% endif %} {% if item.result and item.schedule.execution_status in ['completed', 'failed'] %}
{% if item.result.cycle_response %} {% set cycle = item.result.cycle_response %} {% if cycle.new_index is defined and cycle.new_index is not none %}
Index: {{ '%04d'|format(cycle.new_index) }} {% if cycle.old_index is defined and cycle.old_index is not none %} (was {{ '%04d'|format(cycle.old_index) }}) {% endif %}
{% endif %} {% if cycle.downloaded_folder %}
Folder: {{ cycle.downloaded_folder }} {% if cycle.download_success %} Downloaded {% elif cycle.download_attempted %} Download failed {% endif %}
{% endif %} {% if cycle.clock_synced %}
Clock synced: Yes
{% endif %} {% elif item.result.device_response %} {% set dev = item.result.device_response %}
Device: {{ dev.message or dev.status }}
{% endif %} {% if item.result.session_id %}
Session: {{ item.result.session_id[:8] }}...
{% endif %}
{% endif %}
{% if item.schedule.execution_status == 'pending' %} {% endif %}
{% endfor %}
{% endfor %}
{% else %}

No scheduled actions yet

Create schedules to automate tasks

{% endif %}