language: gl responses: intents: HassGetState: # the number of names returned is limited to 4, in case there are more, the first 3 names and the remaining count is returned # with 4 names or less, the names are joined with a comma ", " and the last name is joined with " and " one: | {{ state.state_with_unit }} one_yesno: | {% if query.matched %} Si {% else %} Non{% if slots.domain != 'lock' %}, {{ state.state_with_unit }}{% endif %} {% endif %} any: | {% if query.matched %} {% set match = query.matched | map(attribute="name") | sort | list %} {% if match | length > 4 %} Si, {{ match[:3] | join(", ") }} e {{ (match | length - 3) }} máis {%- else -%} Si, {% for name in match -%} {% if not loop.first and not loop.last %}, {% elif loop.last and not loop.first %} e {% endif -%} {{ name }} {%- endfor -%} {% endif %} {% else %} Non {% endif %} all: | {% macro word_gender(word) %} {%- set word_lower = word.strip().lower() -%} {%- set known_words = { 'luz': true } -%} {%- set feminine_endings = ['a', 'á', 'ión', 'dad', 'tad', 'eza', 'ura'] -%} {%- if word_lower in known_words -%} {%- if known_words[word_lower] -%}feminine{%- else -%}masculine{%- endif -%} {%- else -%} {%- set is_feminine = false -%} {%- for ending in feminine_endings -%} {%- if word_lower.endswith(ending) -%} {%- set is_feminine = true -%} {%- endif -%} {%- endfor -%} {%- if is_feminine -%}feminine{%- else -%}masculine{%- endif -%} {%- endif -%} {% endmacro %} {% macro is_feminine(entity_name) %} {%- set first_word = entity_name.strip().split()[0] -%} {{- word_gender(first_word) == 'feminine' -}} {% endmacro %} {% macro all_feminine(entity_list) %} {%- set ns = namespace(all_feminine=true) -%} {%- for entity in entity_list -%} {%- if not is_feminine(entity.name) -%} {%- set ns.all_feminine = false -%} {%- endif -%} {%- endfor -%} {{- ns.all_feminine -}} {% endmacro %} {% if not query.unmatched %} Si {% else %} {% set no_match = query.unmatched | map(attribute="name") | sort | list %} {% if no_match | length > 4 %} {% if slots.domain == 'lock' %} Non, {{ no_match[:3] | join(", ") }} e {{ (no_match | length - 3) }} máis non están {% if all_feminine(query.unmatched) == true %}pechadas{% else %}pechados{% endif %} {% else %} Non, {{ no_match[:3] | join(", ") }} e {{ (no_match | length - 3) }} máis non están {{ slots.state }} {% endif %} {%- else -%} Non, {% for name in no_match -%} {% if not loop.first and not loop.last %}, {% elif loop.last and not loop.first %} e {% endif -%} {{ name }} {%- endfor %} non {% if no_match | length > 1 %}están{% else %}está{% endif %} {% if slots.domain == 'lock' %}{% if all_feminine(query.unmatched) == true %}{% if no_match | length > 1 %}pechadas{% else %}pechada{% endif %}{% else %}{% if no_match | length > 1 %}pechados{% else %}pechado{% endif %}{% endif %}{% else %}{{ slots.state }}{% endif %} {% endif %} {% endif %} which: | {% if not query.matched %} {% if slots.domain == 'lock' %}{% if query.unmatched and all_feminine(query.unmatched) == true %}Ningunha{% else %}Ningún{% endif %}{% else %}Ningún{% endif %} {% else %} {% set match = query.matched | map(attribute="name") | sort | list %} {% if match | length > 4 %} {{ match[:3] | join(", ") }} e {{ (match | length - 3) }} máis {% else %} {%- for name in match -%} {% if not loop.first and not loop.last %}, {% elif loop.last and not loop.first %} e {% endif -%} {{ name }} {%- endfor -%} {% endif %} {% endif %} how_many: | {{ query.matched | length }} where: | {% if state == "not_home" %} {{ slots.name | capitalize }} está fora {% else %} {{ slots.name | capitalize }} está en {{ state.state }} {% endif %}