{% if is_state('sensor.tronity_q4_sportback_e_tron_plugged','on') %}
ja
{% else %}
nein
{% endif %}
It is a bit of a guess that this is a binary_sensor, which is either on or off. When writing templates, it is always best to go to developer tools, states and see what the state really is. In the user interface you only see translations.
You can also use developer tools to check your template.
I’ve already prepared some templates and I’ve now prepared binary sensors for those two states as suggested by you:
{{ 'ja' if is_state('sensor.steckerzustand','plugged') else 'nein' }}
I did substitute ‘true’ by ‘plugged’, because this is one of the attributes of the source entity. Is this correct or should I use the German translation of it (“Ausgesteckt”?
Nethertheless it isn’t working yet. Currently Zoe is plugged, but the helper only says “Aus” (shouldn’t it be “nein” at least?):
Check your sensor’s real state in Developer Tools / States. Here’s one of mine reporting “Waiting for schedule”:
but the actual state that must be used in templates is waiting-for-schedule:
If it is a template binary sensor that you are creating, the state will be either 'on' or 'off' (always lower-case, always in English) — or potentially 'unknown' / 'unavailable' if there are problems.
{{ 'on' if is_state('sensor.steckerzustand','plugged') else 'off' }}
or simply:
{{ is_state('sensor.steckerzustand','plugged') }}
When you give that binary sensor a device class of “plug”, the front end will translate the underlying state of 'on' or 'off' into your language’s version of “Plugged in” or “Unplugged”.
Ah, OK, now I understand! Then “ja” und “nein” in {{ ‘ja’ if is_state(‘sensor.steckerzustand’,‘true’) else ‘nein’ }} won’t work in a binary sensor. If I want to have “ja” und “nein” as a result, I have to use a non-binary sensor.
'sensor.tronity.Q4 Sportback e-tron.charging' is not a valid entity_id. You need to click the cog button and copy the entity_id from within that window.