| 1 | --- |
| 2 | language: uk |
| 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 | Таймерів немає. |
| 16 | {% elif num_active_timers == 0: %} |
| 17 | {# No active timers #} |
| 18 | {% if num_paused_timers == 1: %} |
| 19 | {% set next_timer = paused_timers[0] %} |
| 20 | Таймер на паузі. |
| 21 | {% else: %} |
| 22 | {% if num_paused_timers % 10 == 1 and num_paused_timers % 100 != 11: %} |
| 23 | {{ num_paused_timers }} таймер на паузі. |
| 24 | {% elif num_paused_timers % 10 in [2, 3, 4] and not (num_paused_timers % 100 in [12, 13, 14]): %} |
| 25 | {{ num_paused_timers }} таймери на паузі. |
| 26 | {% else: %} |
| 27 | {{ num_paused_timers }} таймерів на паузі. |
| 28 | {% endif %} |
| 29 | {% endif %} |
| 30 | {% else: %} |
| 31 | {# At least one active timer #} |
| 32 | {% if num_active_timers == 1: %} |
| 33 | {% set next_timer = active_timers[0] %} |
| 34 | {% else: %} |
| 35 | {# Get active timer that will finish soonest #} |
| 36 | {% set sorted_timers = active_timers | sort(attribute='total_seconds_left') %} |
| 37 | {% set next_timer = sorted_timers[0] %} |
| 38 | {% if num_active_timers % 10 == 1 and num_active_timers % 100 != 11: %} |
| 39 | {{ num_active_timers }} активний таймер. |
| 40 | {% elif num_active_timers % 10 in [2, 3, 4] and not (num_active_timers % 100 in [12, 13, 14]): %} |
| 41 | {{ num_active_timers }} активні таймери. |
| 42 | {% else: %} |
| 43 | {{ num_active_timers }} активних таймерів. |
| 44 | {% endif %} |
| 45 | {% endif %} |
| 46 | |
| 47 | {% if num_paused_timers > 0: %} |
| 48 | {% if num_paused_timers % 10 == 1 and num_paused_timers % 100 != 11: %} |
| 49 | {{ num_paused_timers }} таймер на паузі. |
| 50 | {% elif num_paused_timers % 10 in [2, 3, 4] and not (num_paused_timers % 100 in [12, 13, 14]): %} |
| 51 | {{ num_paused_timers }} таймери на паузі. |
| 52 | {% else: %} |
| 53 | {{ num_paused_timers }} таймерів на паузі. |
| 54 | {% endif %} |
| 55 | {% endif %} |
| 56 | {% endif %} |
| 57 | |
| 58 | {% if next_timer: %} |
| 59 | {# At least one active timer #} |
| 60 | {% if (next_timer.rounded_hours_left == 1) and (next_timer.rounded_minutes_left > 0): %} |
| 61 | 1 година та {{ next_timer.rounded_minutes_left }} хвилин |
| 62 | {% elif (next_timer.rounded_hours_left == 1): %} |
| 63 | 1 година |
| 64 | {% elif (next_timer.rounded_hours_left > 1) and (next_timer.rounded_minutes_left > 0): %} |
| 65 | {{ next_timer.rounded_hours_left }} годин та {{ next_timer.rounded_minutes_left }} хвилин |
| 66 | {% elif (next_timer.rounded_hours_left > 1): %} |
| 67 | {% if next_timer.rounded_hours_left % 10 == 1 and next_timer.rounded_hours_left % 100 != 11: %} |
| 68 | {{ next_timer.rounded_hours_left }} година |
| 69 | {% elif next_timer.rounded_hours_left % 10 in [2, 3, 4] and not (next_timer.rounded_hours_left % 100 in [12, 13, 14]): %} |
| 70 | {{ next_timer.rounded_hours_left }} години |
| 71 | {% else: %} |
| 72 | {{ next_timer.rounded_hours_left }} годин |
| 73 | {% endif %} |
| 74 | {% elif (next_timer.rounded_minutes_left == 1) and (next_timer.rounded_seconds_left > 0): %} |
| 75 | 1 хвилина {{ next_timer.rounded_seconds_left }} секунд |
| 76 | {% elif (next_timer.rounded_minutes_left == 1): %} |
| 77 | 1 хвилина |
| 78 | {% elif (next_timer.rounded_minutes_left > 1) and (next_timer.rounded_seconds_left > 0): %} |
| 79 | {{ next_timer.rounded_minutes_left }} хвилин та {{ next_timer.rounded_seconds_left }} сеунд |
| 80 | {% elif (next_timer.rounded_minutes_left > 1): %} |
| 81 | {% if next_timer.rounded_minutes_left % 10 == 1 and next_timer.rounded_minutes_left % 100 != 11: %} |
| 82 | {{ next_timer.rounded_minutes_left }} хвилина |
| 83 | {% elif next_timer.rounded_minutes_left % 10 in [2, 3, 4] and not (next_timer.rounded_minutes_left % 100 in [12, 13, 14]): %} |
| 84 | {{ next_timer.rounded_minutes_left }} хвилини |
| 85 | {% else: %} |
| 86 | {{ next_timer.rounded_minutes_left }} хвилин |
| 87 | {% endif %} |
| 88 | {% elif (next_timer.rounded_seconds_left == 1): %} |
| 89 | 1 секунда |
| 90 | {% elif (next_timer.rounded_seconds_left > 1): %} |
| 91 | {% if next_timer.rounded_seconds_left % 10 == 1 and next_timer.rounded_seconds_left % 100 != 11: %} |
| 92 | {{ next_timer.rounded_seconds_left }} секунда |
| 93 | {% elif next_timer.rounded_seconds_left % 10 in [2, 3, 4] and not (next_timer.rounded_seconds_left % 100 in [12, 13, 14]): %} |
| 94 | {{ next_timer.rounded_seconds_left }} секунди |
| 95 | {% else: %} |
| 96 | {{ next_timer.rounded_seconds_left }} секунд |
| 97 | {% endif %} |
| 98 | {% endif %} |
| 99 | |
| 100 | {% if num_timers > 1: %} |
| 101 | {# Give some extra information to disambiguate #} |
| 102 | залишилось на таймері |
| 103 | {% if (next_timer.start_hours > 0) and (next_timer.start_minutes > 0): %} |
| 104 | {{ next_timer.start_hours }} годин та {{ next_timer.start_minutes }} хвилин |
| 105 | {% elif (next_timer.start_hours > 0): %} |
| 106 | {% if next_timer.start_hours % 10 == 1 and next_timer.start_hours % 100 != 11: %} |
| 107 | {{ next_timer.start_hours }} година |
| 108 | {% elif next_timer.start_hours % 10 in [2, 3, 4] and not (next_timer.start_hours % 100 in [12, 13, 14]): %} |
| 109 | {{ next_timer.start_hours }} години |
| 110 | {% else: %} |
| 111 | {{ next_timer.start_hours }} годин |
| 112 | {% endif %} |
| 113 | {% elif (next_timer.start_minutes > 0) and (next_timer.start_seconds > 0): %} |
| 114 | {{ next_timer.start_minutes }} хвилин та {{ next_timer.start_seconds }} секунд |
| 115 | {% elif (next_timer.start_minutes > 0): %} |
| 116 | {% if next_timer.start_minutes % 10 == 1 and next_timer.start_minutes % 100 != 11: %} |
| 117 | {{ next_timer.start_minutes }} хвилина |
| 118 | {% elif next_timer.start_minutes % 10 in [2, 3, 4] and not (next_timer.start_minutes % 100 in [12, 13, 14]): %} |
| 119 | {{ next_timer.start_minutes }} хвилини |
| 120 | {% else: %} |
| 121 | {{ next_timer.start_minutes }} хвилин |
| 122 | {% endif %} |
| 123 | {% elif (next_timer.start_seconds > 0): %} |
| 124 | {% if next_timer.start_seconds % 10 == 1 and next_timer.start_seconds % 100 != 11: %} |
| 125 | {{ next_timer.start_seconds }} секунда |
| 126 | {% elif next_timer.start_seconds % 10 in [2, 3, 4] and not (next_timer.start_seconds % 100 in [12, 13, 14]): %} |
| 127 | {{ next_timer.start_seconds }} секунди |
| 128 | {% else: %} |
| 129 | {{ next_timer.start_seconds }} секунд |
| 130 | {% endif %} |
| 131 | {% endif %} |
| 132 | |
| 133 | {% if next_timer.name: %} |
| 134 | {{ next_timer.name }} |
| 135 | {% elif next_timer.area: %} |
| 136 | в приміщенні {{ next_timer.area }} |
| 137 | {% endif %} |
| 138 | |
| 139 | {% else: %} |
| 140 | залишилось. |
| 141 | {% endif %} |
| 142 | {% endif %} |