kershner / screenBloom

Fake Ambilight for Philips Hue via Python
http://www.screenbloom.com
329 stars 48 forks source link

Error on startup #54

Open federicoemartinez opened 6 years ago

federicoemartinez commented 6 years ago

unnamed The problem seems to be related to the IP of the Bridge changing. It would be good to catch the error and force a reconfiguration, something like: Cannot contact the bridge, register your bridge again (or maybe perform a new search and reuse the token?)

I could try to create a PR if you agree and if you tell me where I should look.

kershner commented 6 years ago

Hey there, thanks for bringing this up.

The catch will probably have to go somewhere in here. I'm compiling a list of fixes/small things to add with some free time in the next few weeks, will definitely be investigating this one.

federicoemartinez commented 6 years ago

I was thinking of something like

try:
                    presets.update_presets_if_necessary()
                except ConnectionError:
                    # There was an error connecting to the hue lights
                    # let's pretend it is a new user
                    self._set_startup_for_new_user()
                    return

with

    def _set_startup_for_new_user(self):
        self.url = self.base_url + 'new-user'
        self.new_user = True

So I don't repeat that code. Did you have something like that in mind?