Comments (7)
Hello @oerkel47! I think I have a solution for the HA API returning states/attributes in English. Since it only affects the Home Assistant component, I've created an api_translations
folder with the languages' translations that come back from the HA API (in a new branch - #279)
The idea being that any English response that comes back from the API indicating a state (like on
or off
) is defined in the api_translations/[language].json
file. This gets autoloaded by the Home Assistant component and is setup in the HomeAssistant
component.
In all of the domain-specific controller and their language files it can be accessed with self.ha.api_translation
. So in switch/de.py
, you could use self.ha.api_translations["on"]
and it would return an
.
I kinda like the idea of having all the responses from the API translated in the same place. If you want to try out the branch and let me know how it goes that would be great! I tried it out a bit and I hope it'll be useful overall.
from homeintent.
Thanks @JarvyJ, I will try it out soon.
from homeintent.
Wouldn't it be a good idea to directly translate the translatable entries inside the response dict inside the base class? Would take the work from the translators while also keeping the language specific code tidy.
response = self._toggle_light(light)
response["state"] = self.ha.api_translation[response["state"]]
This works, but looks ugly.
from homeintent.
Oh, I like that idea! It'll make it a lot nicer for translators. I'll see if I can get it worked in today along with a workaround for #274
from homeintent.
The branch has been updated!
So I ended up doing the translation work in the Home Assistant api code. This way any get_entity
call that has a state
attribute will get translated with the json file.
I've also made the get_entity
to take in the response from call_service
and check if it's an empty list, perform the delay, and then return. This should solve the issue in #274.
I'll do a bit more testing on my end, and if it seems good for you, we can merge and go from there!
from homeintent.
Regarding the translation: my first tests worked without issue, but have not done many. Nice work!
from homeintent.
closed with #279
from homeintent.
Related Issues (20)
- Can't view Rhasspy Logs in UI if using an external Rhasspy instance HOT 3
- [Feature Reuest] Make this Hassio Addon HOT 4
- Timer not working with satellites HOT 3
- [Translation development] If language files are missing, home intent won't start up correctly HOT 4
- Language setting in docker-compose.yaml does not affect Rhasspy TTS language HOT 3
- Response["state"] is inaccurate if polled instantly after switching entity state HOT 8
- [UI] save button only clickable when option is enabled
- [Feature Request] Option to disable voice feedback
- Home Intent Going to Maintenance Mode HOT 7
- Remove duplicate word at the end of a response sentence
- French translation HOT 6
- Mimic 3
- Add German and French Example sentences HOT 1
- [Question] - Can Home Intent access sensor entities? HOT 1
- Managed Satellites Customisation HOT 1
- How to access entities of a specific room? HOT 3
- Timeout while restarting / configuring satellites HOT 6
- External MQTT with internal Rhasspy instance HOT 1
- Components without required settings don't get added to the settings page HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from homeintent.