| 1 | --- |
| 2 | language: nb |
| 3 | responses: |
| 4 | intents: |
| 5 | HassTimerStatus: |
| 6 | default: | |
| 7 | {% set num_timers = slots.timers | length %} |
| 8 | {% set active_timers = slots.timers | selectattr('is_active') | list %} |
| 9 | {% set num_active_timers = active_timers | length %} |
| 10 | {% set paused_timers = slots.timers | rejectattr('is_active') | list %} |
| 11 | {% set num_paused_timers = paused_timers | length %} |
| 12 | {% set next_timer = None %} |
| 13 | |
| 14 | {% if num_timers == 0: %} |
| 15 | Ingen nedtellinger. |
| 16 | {% elif num_active_timers == 0: %} |
| 17 | {# No active timers #} |
| 18 | {% if num_paused_timers == 1: %} |
| 19 | {% set next_timer = paused_timers[0] %} |
| 20 | Nedtellingen er pauset. |
| 21 | {% else: %} |
| 22 | {{ num_paused_timers }} pausede nedtellinger. |
| 23 | {% endif %} |
| 24 | {% else: %} |
| 25 | {# At least one active timer #} |
| 26 | {% if num_active_timers == 1: %} |
| 27 | {% set next_timer = active_timers[0] %} |
| 28 | {% else: %} |
| 29 | {# Get active timer that will finish soonest #} |
| 30 | {% set sorted_timers = active_timers | sort(attribute='total_seconds_left') %} |
| 31 | {% set next_timer = sorted_timers[0] %} |
| 32 | {{ num_active_timers }} aktive nedtellinger. |
| 33 | {% endif %} |
| 34 | |
| 35 | {% if num_paused_timers == 1: %} |
| 36 | 1 pauset nedtelling. |
| 37 | {% elif num_paused_timers > 0: %} |
| 38 | {{ num_paused_timers }} pausede nedtellinger. |
| 39 | {% endif %} |
| 40 | {% endif %} |
| 41 | |
| 42 | {% if next_timer: %} |
| 43 | {# At least one active timer #} |
| 44 | {% if (next_timer.rounded_hours_left == 1) and (next_timer.rounded_minutes_left > 0): %} |
| 45 | 1 time og {{ next_timer.rounded_minutes_left }} minutter |
| 46 | {% elif (next_timer.rounded_hours_left == 1): %} |
| 47 | 1 time |
| 48 | {% elif (next_timer.rounded_hours_left > 1) and (next_timer.rounded_minutes_left > 0): %} |
| 49 | {{ next_timer.rounded_hours_left }} timer og {{ next_timer.rounded_minutes_left }} minutter |
| 50 | {% elif (next_timer.rounded_hours_left > 1): %} |
| 51 | {{ next_timer.rounded_hours_left }} timer |
| 52 | {% elif (next_timer.rounded_minutes_left == 1) and (next_timer.rounded_seconds_left > 0): %} |
| 53 | 1 minutt og {{ next_timer.rounded_seconds_left }} sekunder |
| 54 | {% elif (next_timer.rounded_minutes_left == 1): %} |
| 55 | 1 minutt |
| 56 | {% elif (next_timer.rounded_minutes_left > 1) and (next_timer.rounded_seconds_left > 0): %} |
| 57 | {{ next_timer.rounded_minutes_left }} minutter og {{ next_timer.rounded_seconds_left }} sekunder |
| 58 | {% elif (next_timer.rounded_minutes_left > 1): %} |
| 59 | {{ next_timer.rounded_minutes_left }} minutter |
| 60 | {% elif (next_timer.rounded_seconds_left == 1): %} |
| 61 | 1 sekund |
| 62 | {% elif (next_timer.rounded_seconds_left > 1): %} |
| 63 | {{ next_timer.rounded_seconds_left }} sekunder |
| 64 | {% endif %} |
| 65 | |
| 66 | {% if num_timers > 1: %} |
| 67 | {# Give some extra information to disambiguate #} |
| 68 | igjen på |
| 69 | {% if (next_timer.start_hours > 0) and (next_timer.start_minutes > 0): %} |
| 70 | {{ next_timer.start_hours }} timer og {{ next_timer.start_minutes }} minutter |
| 71 | {% elif (next_timer.start_hours > 0): %} |
| 72 | {{ next_timer.start_hours }} timer |
| 73 | {% elif (next_timer.start_minutes > 0) and (next_timer.start_seconds > 0): %} |
| 74 | {{ next_timer.start_minutes }} minutt og {{ next_timer.start_seconds }} sekunder |
| 75 | {% elif (next_timer.start_minutes > 0): %} |
| 76 | {{ next_timer.start_minutes }} minutter |
| 77 | {% elif (next_timer.start_seconds > 0): %} |
| 78 | {{ next_timer.start_seconds }} sekunder |
| 79 | {% endif %} |
| 80 | |
| 81 | {% if next_timer.name: %} |
| 82 | {{ next_timer.name }} |
| 83 | {% elif next_timer.area: %} |
| 84 | {{ next_timer.area }} |
| 85 | {% endif %} |
| 86 | |
| 87 | nedtelling. |
| 88 | {% else: %} |
| 89 | igjen. |
| 90 | {% endif %} |
| 91 | {% endif %} |