-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Media More Info: Convert to Lit Element #6619
Conversation
const services = this.hass.services.tts; | ||
const serviceKeys = Object.keys(services).sort(); | ||
let service: string | undefined; | ||
|
||
for (let i = 0; i < serviceKeys.length; i++) { | ||
if (serviceKeys[i].indexOf("_say") !== -1) { | ||
service = serviceKeys[i]; | ||
break; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, this is so ugly, we should look into it sometime...
const services = this.hass.services.tts; | ||
const serviceKeys = Object.keys(services).sort(); | ||
|
||
const service = serviceKeys.find((key) => key.indexOf("_say") !== -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bramkragten This should be a bit better than the for loop I think. Still maybe not the best way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the fact that we just pick the first one is wrong, to begin with... But yeah, this code is a lot better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea... that's what I was thinking. We also sort them... but from the data, we are given from the service there doesn't seem to be a way to find the preferred one
Proposed change
Convert to Lit
Type of change