Trying to make blueprints multilingual but failing

Hey all. My project View Assist extends Assist capabilities through custom sentence blueprints. I would like to make these multilingual but my efforts have not been met with success. I am trying to create a dictionary for each language and having those translations used in the blueprint description, name and other display settings. Unfortunately what I have is showing the JINJA text rather than the expanded variable values. Can someone tell me if what I’m trying to do is possible? This would make things easy to translate and self contained.

Here’s the attempt:


blueprint:
  name: View Assist - Multilingual
  description: Ask "How's the Weather?" and ViewAssist will respond with the weather and show the weather view (View Assist howstheweather v 1.0.0)
  domain: automation
  input:
    command_prompt:
      name: >-
        {{ translations[language]['command_prompt']['name'] }}
      description: >-
        {{ translations[language]['command_prompt']['description'] }}
      default: >-
        {{ translations[language]['command_prompt']['default'] }}
    weather_entity: 
      name: >-
        {{ translations[language]['weather_entity']['name'] }}
      description: >-
        {{ translations[language]['weather_entity']['description'] }}
      selector:
        entity:
          filter:
            - domain: weather
    group_entity: 
      name: >-
        {{ translations[language]['group_entity']['name'] }}
      description: >-
        {{ translations[language]['group_entity']['description'] }}
      selector:
        entity:
          filter:
            - domain: group
      default: "group.viewassist_satellites"                  
    dashboard:
      name: >-
        {{ translations[language]['dashboard']['name'] }}
      description: >-
        {{ translations[language]['dashboard']['description'] }}
      default: "/dashboard-viewassist/weather" 
alias: View Assist - How's the Weather
description: "Provides information on the current weather and forecast"
trigger:
  - platform: conversation
    command: !input command_prompt
variables:
  language: "es"
  group_entity: !input group_entity
  weather_entity: !input weather_entity
  dashboard: !input dashboard
  translations:
    en:
      command_prompt:
        name: "Command Text"
        description: "The phrase you want to use to trigger the automation"
        default: "(How's | How is | What's | What is) [the] weather"
      weather_entity:
        name: "Weather Entity"
        description: "The entity that provides weather information (example weather.home)"
      group_entity:
        name: "Group Entity"
        description: "The group that holds the list of View Assist satellites (example group.viewassist_satellites)"
      dashboard:
        name: "Dashboard Weather view"
        description: "The View Assist dashboard view to use for weather (example /dashboard-viewassist/weather)"
      responses:
        temperature: "It's {temperature} degrees and {condition}"
    es:
      command_prompt:
        name: "Texto de comando"
        description: "La frase que desea usar para activar la automatización"
        default: "(¿Cómo está | Cómo está | ¿Cuál es | Cuál es) [el] clima"
      weather_entity:
        name: "Entidad meteorológica"
        description: "La entidad que proporciona información meteorológica (ejemplo weather.home)"
      group_entity:
        name: "Entidad de grupo"
        description: "El grupo que contiene la lista de satélites de View Assist (ejemplo group.viewassist_satellites)"
      dashboard:
        name: "Vista del clima en el tablero"
        description: "La vista del tablero de View Assist para usar para el clima (ejemplo /dashboard-viewassist/weather)"
      responses:
        temperature: "Hace {temperature} grados y está {condition}"
condition: []
action:
  - variables:
      target_satellite_device: |-
        {% for sat in expand(group_entity) %}
          {% if (device_id(sat.attributes.mic_device)  == trigger.device_id) or (device_id(sat.attributes.display_device)  == trigger.device_id) %}
            {{ sat.entity_id }}
          {% endif %}
        {% endfor %}
      target_display_device: "{{ device_id(state_attr(target_satellite_device, 'display_device')) }}"
      target_mediaplayer_device: "{{ state_attr(target_satellite_device, 'mediaplayer_device') }}"
      target_satellite_device_type: "{{ state_attr(target_satellite_device, 'type') }}"
    enabled: true
  - set_conversation_response: >-
      {{ translations[language]['responses']['temperature'].replace("{temperature}", state_attr(weather_entity, 'temperature')).replace("{condition}", states[weather_entity].state) }}
    enabled: true
  - if:
      - condition: template
        value_template: "{% if target_satellite_device_type != 'audio_only' %}true{% else %}false{% endif %}"
    then:
      - service: browser_mod.navigate
        data:
          path: "{{ dashboard }}"
        target:
          device_id: "{{ target_display_device }}"
    enabled: true
mode: single

And this is what it looks like:

Any help would be greatly appreciated. Thanks!

1 Like

I don’t see any indication in the schema that input maps are templatable… and, AFAIK, there would likely be load order issues with something like that.

I guess it was wishful thinking. I suppose I should put in a feature request unless there’s another way to go about doing this.

So, not saying it will help, but the Author of the template macro Easy Time has managed to make that multilingual.

Perhaps something there would help your cause. Not necessarily the code functions themselves, but how he wrote it.

1 Like

Thanks for the share but that appears to be an integration so not quite the same. I’m really trying to make this as self contained as possible. One of our members created one that works for the response portion but the input section is still in a single language.

Does the approach I am trying to use make sense? I will put in a request if it does though not sure ven then if it would be acceptable. I would guess that HA would want to be as inclusive as possible in terms of making these universal, right?

It’s a template, not an integration.
You are using templates.
It is an example that might spark ideas…

Like I said, might help, might not.

Ah sorry. I see now. Seems as these inputs are not templatable as Didgeridrew mentions above so that makes that example also a no go. I’m confident that what I am saying could work but it is just not supported.

Maybe I am overlooking the obvious but is thee a way to make these multilingual short of making individual BPs per language? That would make maintaining overly difficult.

1 Like

Well, essentually if you have an input select to select a language, then have a variable section for each language that changed variables as needed per language, then build the actual code for the function using those variables, then it should work.
But that is what I gave you an example of, so obviously that is not possible.

I apologize if I have not looked at your example thoroughly enough as it may contain the answer but it does not seem that the input section allows for templated variables unless I am misinterpreting what Drew said above and from my experience trying.

I’ve started a feature request petition here:

I just find it really odd that blueprints, which are meant to be distributed, would be locked down to a single language for the input section. I think I can use what I wrote for things like Assist responses, but I really would make it easy for the user to modify these themselves through the input section without having to modify the blueprint themselves. It sort of defeats the nature of what blueprints are.

1 Like