Successfully Translating Sensor States in Home Assistant

I’ve been working on setting up an automation in Home Assistant to notify me whenever my vacuum cleaner’s error state changes. While the automation itself works perfectly, I encountered an issue with language translation that I wanted to share and how I resolved it. Problem: I configured Home Assistant to use German translations, expecting my notifications to display error states in German. However, the automation kept sending the original English state, resulting in a mix of languages in my notifications. Investigation: I tried two approaches to retrieve the translated state: {{ states.sensor.vacuum_error.state }} and {{ state_attr('sensor.vacuum_error.state', 'friendly_name') }}. The first returned the English state, while the second gave me a capitalized ‘None’, which wasn’t the translated ‘Keine’ I expected. Solution: After some research, I discovered that the correct way to access the translated state is through the sensor’s attributes. By modifying my template to {{ states.sensor.vacuum_error.attributes.friendly_name }}, I finally received the properly translated German state in my notifications. Conclusion: This experience taught me the importance of understanding how translations are handled in Home Assistant, particularly how they relate to state attributes. It’s a minor tweak but makes a big difference in maintaining consistency across my smart home setup. I hope this helps anyone else facing similar translation issues!