Skip to content

Delivery site selection in config flow#108

Open
berendhaan wants to merge 7 commits intobajansen:mainfrom
berendhaan:feature/site_selection
Open

Delivery site selection in config flow#108
berendhaan wants to merge 7 commits intobajansen:mainfrom
berendhaan:feature/site_selection

Conversation

@berendhaan
Copy link
Copy Markdown

@berendhaan berendhaan commented Apr 24, 2024

The PR adds an extra step to the config flow which the user can select his current site, if he has multiple. Related to #104

The code still needs some little clean-up, title is not set correctly atm and the step could be skipped if there is only one delivery site active.

afbeelding

Copy link
Copy Markdown
Contributor

@HiDiHo01 HiDiHo01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

            number_of_sites = len(me.deliverySites)
            if number_of_sites == 1:
                # for backward compatibility (do nothing)
                # Check if entry with CONF_USERNAME exists, then abort
                if CONF_USERNAME in user_input:
                    await self.async_set_unique_id(user_input[CONF_USERNAME])
                    self._abort_if_unique_id_configured()

                # Create entry with unique_id as me.deliverySites[0].reference
                first_site = me.deliverySites[0]
                self.sign_in_data[CONF_SITE] = first_site.reference
                self.sign_in_data[CONF_USERNAME] = self.create_title(first_site)
                return await self._async_create_entry(self.sign_in_data)

@berendhaan
Copy link
Copy Markdown
Author

            number_of_sites = len(me.deliverySites)
            if number_of_sites == 1:
                # for backward compatibility (do nothing)
                # Check if entry with CONF_USERNAME exists, then abort
                if CONF_USERNAME in user_input:
                    await self.async_set_unique_id(user_input[CONF_USERNAME])
                    self._abort_if_unique_id_configured()

                # Create entry with unique_id as me.deliverySites[0].reference
                first_site = me.deliverySites[0]
                self.sign_in_data[CONF_SITE] = first_site.reference
                self.sign_in_data[CONF_USERNAME] = self.create_title(first_site)
                return await self._async_create_entry(self.sign_in_data)

I'm missing the reference where you want this part of the code, is it in config_flow.py?
I'll take a look in fixing all the linting issues aswell

@berendhaan
Copy link
Copy Markdown
Author

I'm having some issues with the dependencies, propbaly because some components got updated on the way.

Updating some deps resolves some issues localy, running in python 3.12, I see that in ci.yaml python 3.10 is still used.

What do you think is best, fixing all this stuff in this PR, or first create a PR to bump deps?

@HiDiHo01
Copy link
Copy Markdown
Contributor

HiDiHo01 commented Jun 13, 2024 via email

@HiDiHo01
Copy link
Copy Markdown
Contributor

HiDiHo01 commented Jun 13, 2024 via email

@HiDiHo01
Copy link
Copy Markdown
Contributor

I was thinking.....should we do only sites in delivery or all sites including closed sites?

@berendhaan
Copy link
Copy Markdown
Author

I was thinking.....should we do only sites in delivery or all sites including closed sites?

Yeah, I think that makes sense in a SmartHome context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants