| 1 | --- |
| 2 | language: fi |
| 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 | Ei ajastimia. |
| 16 | {% elif num_active_timers == 0: %} |
| 17 | {# Ei aktiivisia ajastimia #} |
| 18 | {% if num_paused_timers == 1: %} |
| 19 | {% set next_timer = paused_timers[0] %} |
| 20 | Ajastin on keskeytetty. |
| 21 | {% else: %} |
| 22 | {{ num_paused_timers }} keskeytettyä ajastinta. |
| 23 | {% endif %} |
| 24 | {% else: %} |
| 25 | {# Ainakin yksi aktiivinen ajastin #} |
| 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 }} käynnissä olevaa ajastinta. |
| 33 | {% endif %} |
| 34 | |
| 35 | {% if num_paused_timers == 1: %} |
| 36 | 1 keskeytetty ajastin. |
| 37 | {% elif num_paused_timers > 0: %} |
| 38 | {{ num_paused_timers }} keskeytettyä ajastinta. |
| 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 | noin 1 tunti ja {{ next_timer.rounded_minutes_left }} minuuttia |
| 46 | {% elif (next_timer.rounded_hours_left == 1): %} |
| 47 | 1 tunti |
| 48 | {% elif (next_timer.rounded_hours_left > 1) and (next_timer.rounded_minutes_left > 0): %} |
| 49 | noin {{ next_timer.rounded_hours_left }} tuntia ja {{ next_timer.rounded_minutes_left }} minuuttia |
| 50 | {% elif (next_timer.rounded_hours_left > 1): %} |
| 51 | {{ next_timer.rounded_hours_left }} tuntia |
| 52 | {% elif (next_timer.rounded_minutes_left == 1) and (next_timer.rounded_seconds_left > 0): %} |
| 53 | 1 minuutti ja {{ next_timer.rounded_seconds_left }} sekuntia |
| 54 | {% elif (next_timer.rounded_minutes_left == 1): %} |
| 55 | 1 minuutti |
| 56 | {% elif (next_timer.rounded_minutes_left > 1) and (next_timer.rounded_seconds_left > 0): %} |
| 57 | {{ next_timer.rounded_minutes_left }} minuuttia ja {{ next_timer.rounded_seconds_left }} sekuntia |
| 58 | {% elif (next_timer.rounded_minutes_left > 1): %} |
| 59 | {{ next_timer.rounded_minutes_left }} minuuttia |
| 60 | {% elif (next_timer.rounded_seconds_left == 1): %} |
| 61 | 1 sekunti |
| 62 | {% elif (next_timer.rounded_seconds_left > 1): %} |
| 63 | {{ next_timer.rounded_seconds_left }} sekuntia |
| 64 | {% endif %} |
| 65 | |
| 66 | |
| 67 | {% if num_timers > 1: %} |
| 68 | {# Give some extra information to disambiguate #} |
| 69 | jäljellä |
| 70 | {% if (next_timer.start_hours > 0) and (next_timer.start_minutes > 0): %} |
| 71 | {{ next_timer.start_hours }} tuntia ja {{ next_timer.start_minutes }} minuuttia |
| 72 | {% elif (next_timer.start_hours == 1): %} |
| 73 | yhden tunnin |
| 74 | {% elif (next_timer.start_hours == 2): %} |
| 75 | kahden tunnin |
| 76 | {% elif (next_timer.start_hours == 3): %} |
| 77 | kolmen tunnin |
| 78 | {% elif (next_timer.start_hours == 4): %} |
| 79 | neljän tunnin |
| 80 | {% elif (next_timer.start_hours == 5): %} |
| 81 | viiden tunnin |
| 82 | {% elif (next_timer.start_hours == 6): %} |
| 83 | kuuden tunnin |
| 84 | {% elif (next_timer.start_hours > 6): %} |
| 85 | {{ next_timer.start_hours }} tunnin |
| 86 | {% elif (next_timer.start_minutes > 0) and (next_timer.start_seconds > 0): %} |
| 87 | {{ next_timer.start_minutes }} minuuttia ja {{ next_timer.start_seconds }} sekuntia |
| 88 | {% elif (next_timer.start_minutes > 0): %} |
| 89 | {{ next_timer.start_minutes }} minuutin |
| 90 | {% elif (next_timer.start_seconds > 0): %} |
| 91 | {{ next_timer.start_seconds }} sekuntia |
| 92 | {% endif %} |
| 93 | |
| 94 | {% if next_timer.name: %} |
| 95 | {{ next_timer.name }} |
| 96 | {% elif next_timer.area: %} |
| 97 | {{ next_timer.area }} |
| 98 | {% endif %} |
| 99 | |
| 100 | ajastimessa. |
| 101 | {% else: %} |
| 102 | jäljellä. |
| 103 | {% endif %} |
| 104 | {% endif %} |