#So the new aidot integration PR has an
1 messages · Page 1 of 1 (latest)
Currently they use the region + username
I pushed back on this because I saw a user id in the tests, so there was something better
now apparently there can only be a single session active at a time, so trying to login to get the ID would sign out the existing entry
Would you mind telling us what the proposed unique ID is? 😄
"{region}-{username}" (e.g. "us-user@email.com")
I thought that's what Joost rejected?
- Would it be dirty to keep the resuilt of the second login and update the existing entry?
oh
just a user ID
like ID ID
123123
- And now that I was typing this, maybe it'd make sense to do an initial check with
_async_abort_entries_match
apparently there can only be a single session active at a time, so trying to login to get the ID would sign out the existing entry
And what's the problem with that? Does it regenerate the ID?
Nope, it invalidates the existing tokens
So you'd setup the entry, everything works fine
you'd try to set it up again, it fails because it was setup
then the old entry stops working
(you'd need to reauth)
what old integration?
The PR you're reviewing is a perfect example of when an empty PR description simply is not acceptable
The author should link to the existing integration, explain why the new one is better, link to the library etc.
ah, ok
What if the config flow updates the token of the existing entry before aborting?
so what's the problem then? the problem is that trying to set up the same entry again will log out the existing one?
yes
yea that's what I was thinking as well, but it also felt dirty
like I consider updatign existing entries because you add a new one a bit meh
what's the problem?
since they tried to login again, a new token was generated. hence we need to update the existing entry
I still insist on this btw, if the author can't be bothered to write 10 lines introducing the integration, why should someone else be bothered to review it?
But it's off topic for the unique id / reauth issue of course
I think this also is a case of language/culture barrier, but I'll tell them
I think we can check with _async_abort_entries_match first to do matching, and then try
If they don't match because the username changed, then I think a reauth makes sense as there's data to change I guess
if that means they need to store some extra data in the entry only for that, I think it's a bad idea
I'd just keep it very simple, do the auth, check if there's a collision and if there is abort and update the existing entry
you're over thinking this
It'd only be the region they need more
no wait huh
no their tests are busted
thanks
their reauth flow is fetching the country code from the entry data
so it's in there, it's just not in their mocks
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Handle reauth confirmation."""
errors: dict[str, str] = {}
if user_input is not None:
login_info = self._get_reauth_entry().data[CONF_LOGIN_INFO]
client = AidotClient(
session=async_get_clientsession(self.hass),
country_code=login_info.get(CONF_COUNTRY_CODE, DEFAULT_COUNTRY_CODE),
username=user_input[CONF_USERNAME],
password=user_input[CONF_PASSWORD],
)
I am not sure why it uses a .get(), but in any case, even if the country code would not be in there, I think it'd still be a good practice to keep the country code in the entry data, if it doesn't change and we need it for reauth
Otherwise we'd need to ask again when you reauth