schmittx / home-assistant-eero

Eero integration for Home Assistant
MIT License
118 stars 23 forks source link

Config does not take into account multiple networks (bug) #31

Closed joerkl closed 1 year ago

joerkl commented 2 years ago

If I select two networks, I will only go through the configuration of one network (async_step_resources). I see that the response and the data contains all the data for both networks but the configuration screen is only once called. I can select one network and configure it or the other. Both work separately but not when both are selected.

I am not sure that this is related but async_step_activity does not seem to be called at all but immediately jumps to aysnc_step_advanced. I assume that it has something to do with the self.index variable handling in this code.

Thank you very much for your help.

joerkl commented 2 years ago

I found the bug with self.index as it would compare to the next network as self.index changes before the second comparison.

This is how I fixed it: if user_input is not None: nw = self.user_input[CONF_NETWORKS][self.index] for network in self.coordinator.data.networks: if network.id == nw: self.user_input[CONF_EEROS].extend([eero.id for eero in network.eeros if eero.name in user_input[CONF_EEROS]]) self.user_input[CONF_PROFILES].extend([profile.id for profile in network.profiles if profile.name in user_input[CONF_PROFILES]]) self.user_input[CONF_WIRED_CLIENTS].extend([client.id for client in network.clients if client.name_mac in user_input[CONF_WIRED_CLIENTS]]) self.user_input[CONF_WIRELESS_CLIENTS].extend([client.id for client in network.clients if client.name_mac in user_input[CONF_WIRELESS_CLIENTS]]) self.index += 1

The same error is in multiple locations.

The first simple test seem to show that all networks are now taken into account. I don't have a development or testing environment set up so I feel that I should not go further.

schmittx commented 1 year ago

I applied your suggested change in 1.2.0 but I can't confirm for myself since I only have a single network. Let me know if you continue to have problems.