Debian Codegraph @

intents/responses/sr/HassTimerStatus.yaml

raw
1 language: sr
2 responses:
3 intents:
4 HassTimerStatus:
5 default: |
6 {% macro normalize_string(sentence) %}
7 {%- set ns = namespace(is_finished=false,is_first=true,current_term = '', in_square_brackets = false, in_round_brackets = false) %}
8 {%- for char in sentence %}
9 {% if not ns.is_finished %}
10 {%- if char == ' ' %}
11 {%- set ns.is_first = true %}
12 {%- endif %}
13 {%- if char == '[' %}
14 {%- set ns.in_square_brackets = true %}
15 {%- elif char == ']' %}
16 {%- set ns.in_square_brackets = false %}
17 {%- elif char == '(' %}
18 {%- set ns.in_round_brackets = true %}
19 {%- elif char == ')' %}
20 {%- set ns.in_round_brackets = false %}
21 {%- elif char == '|' and not ns.in_square_brackets and not ns.in_round_brackets %}
22 {# break is not working #}
23 {%- set ns.is_finished = true %}
24 {%- elif ns.in_round_brackets and ns.is_first %}
25 {%- set ns.current_term = ns.current_term + char %}
26 {%- set ns.is_first = false %}
27 {%- elif not ns.in_square_brackets and not ns.in_round_brackets %}
28 {%- set ns.current_term = ns.current_term + char %}
29 {%- endif %}
30 {%- endif %}
31 {%- endfor %}
32 {{ ns.current_term }}
33 {% endmacro %}
34
35 {% set num_timers = slots.timers | length %}
36 {% set active_timers = slots.timers | selectattr('is_active') | list %}
37 {% set num_active_timers = active_timers | length %}
38 {% set paused_timers = slots.timers | rejectattr('is_active') | list %}
39 {% set num_paused_timers = paused_timers | length %}
40 {% set next_timer = None %}
41
42 {% if num_timers == 0: %}
43 Нема тајмера.
44 {% elif num_active_timers == 0: %}
45 {# No active timers #}
46 {% if num_paused_timers == 1: %}
47 {% set next_timer = paused_timers[0] %}
48 Тајмер је паузиран.
49 {% else: %}
50 {{ num_paused_timers }} паузирани тајмери.
51 {% endif %}
52 {% else: %}
53 {# At least one active timer #}
54 {% if num_active_timers == 1: %}
55 {% set next_timer = active_timers[0] %}
56 {% else: %}
57 {# Get active timer that will finish soonest #}
58 {% set sorted_timers = active_timers | sort(attribute='total_seconds_left') %}
59 {% set next_timer = sorted_timers[0] %}
60 {{ num_active_timers }} активних тајмери.
61 {% endif %}
62
63 {% if num_paused_timers == 1: %}
64 1 паузирани тајмер.
65 {% elif num_paused_timers > 0: %}
66 {{ num_paused_timers }} паузирани тајмери.
67 {% endif %}
68 {% endif %}
69
70 {% if next_timer: %}
71 {# At least one active timer #}
72 {% if (next_timer.rounded_hours_left == 1) and (next_timer.rounded_minutes_left > 0): %}
73 1 сат и {{ next_timer.rounded_minutes_left }} минута
74 {% elif (next_timer.rounded_hours_left == 1): %}
75 1 сат
76 {% elif (next_timer.rounded_hours_left > 1) and (next_timer.rounded_minutes_left > 0): %}
77 {{ next_timer.rounded_hours_left }} сати и {{ next_timer.rounded_minutes_left }} минута
78 {% elif (next_timer.rounded_hours_left > 1): %}
79 {{ next_timer.rounded_hours_left }} сати
80 {% elif (next_timer.rounded_minutes_left == 1) and (next_timer.rounded_seconds_left > 0): %}
81 1 минут и {{ next_timer.rounded_seconds_left }} секунди
82 {% elif (next_timer.rounded_minutes_left == 1): %}
83 1 минут
84 {% elif (next_timer.rounded_minutes_left > 1) and (next_timer.rounded_seconds_left > 0): %}
85 {{ next_timer.rounded_minutes_left }} минута и {{ next_timer.rounded_seconds_left }} секунди
86 {% elif (next_timer.rounded_minutes_left > 1): %}
87 {{ next_timer.rounded_minutes_left }} минута
88 {% elif (next_timer.rounded_seconds_left == 1): %}
89 1 секунд
90 {% elif (next_timer.rounded_seconds_left > 1): %}
91 {{ next_timer.rounded_seconds_left }} секунди
92 {% endif %}
93
94 {% if num_timers > 1: %}
95 {# Give some extra information to disambiguate #}
96 преостало на
97 {% if (next_timer.start_hours > 0) and (next_timer.start_minutes > 0): %}
98 {{ next_timer.start_hours }} сат и {{ next_timer.start_minutes }} минута
99 {% elif (next_timer.start_hours > 0): %}
100 {{ next_timer.start_hours }} сат
101 {% elif (next_timer.start_minutes > 0) and (next_timer.start_seconds > 0): %}
102 {{ next_timer.start_minutes }} минутни и {{ next_timer.start_seconds }} секунда
103 {% elif (next_timer.start_minutes > 0): %}
104 {{ next_timer.start_minutes }} минутни
105 {% elif (next_timer.start_seconds > 0): %}
106 {{ next_timer.start_seconds }} секунда
107 {% endif %}
108
109 тајмеру
110 {% if next_timer.name: %}
111 {{ next_timer.name }}
112 {% elif next_timer.area: %}
113
114 {% set area_name = normalize_string(next_timer.area) %}
115
116 у просторији
117 {{ area_name }}
118 {% endif %}
119
120 {% else: %}
121 преостало.
122 {% endif %}
123 {% endif %}