How can I localize “Home” in my installation?
I would very much like to use this great example from @NotoriousBDG which is very dynamic and includes predefined zones.
I would like to show the notify messages in Norwegian. Home in Norwegian is Hjem
The Expression left {{trigger.from_state.state}} should return forlot MY_HOME_ADDRESS.
Now I get a mix of norwegian text and english every place the system value for home is used…
BTW: changing the homeassistant entry in configuraion.yaml
homeassistant:
name: "XXX"
does not seem to affect this.
- service: notify.my_iphone
data_template:
message: >-
{%- if trigger.to_state.state == "not_home" -%}
{{ trigger.to_state.attributes.friendly_name }} left {{trigger.from_state.state}}
{%- elif trigger.from_state.state == "not_home" -%}
{{ trigger.to_state.attributes.friendly_name }} arrived at {{trigger.to_state.state}}
{%- else -%}
{{ trigger.to_state.attributes.friendly_name }} left {{trigger.from_state.state}} and arrived at {{trigger.to_state.state}}
{%- endif -%}
The states are 'not_home' (when not in any zone), 'home' (when in zone.home, no matter what zone.home's friendly name is) or the friendly name of a zone. Maybe this will do what you want:
- service: notify.my_iphone
data_template:
message: >-
{%- set from_name = trigger.from_state.state -%}
{%- if from_name == 'home' -%}
{%- set from_name = state_attr('zone.home', 'friendly_name') -%}
{%- endif -%}
{%- set to_name = trigger.to_state.state -%}
{%- if to_name == 'home' -%}
{%- set to_name = state_attr('zone.home', 'friendly_name') -%}
{%- endif -%}
{%- if trigger.to_state.state == 'not_home' -%}
{{ trigger.to_state.attributes.friendly_name }} left {{from_name}}
{%- elif trigger.from_state.state == 'not_home' -%}
{{ trigger.to_state.attributes.friendly_name }} arrived at {{to_name}}
{%- else -%}
{{ trigger.to_state.attributes.friendly_name }} left {{from_name}} and arrived at {{to_name}}
{%- endif -%}
If you change the homeassistant: name: xxx in your configuration, and do not create zone.home via the zone: configuration, then that will become the friendly_name of zone.home, in which case, what I suggested should work.