craigcabrey / luminance

A Philips Hue client for Linux written in Python and GTK+.
https://craigcabrey.github.io/luminance/
GNU General Public License v2.0
155 stars 26 forks source link

Crashes after selecting bridge #33

Open diadras opened 5 years ago

diadras commented 5 years ago

The first time the application ran I selected my bridge and hit next. I then saw the "press bridge button" picture and pressed the button on my bridge. Immediately after I did this all my lights switched off and the application had crashed. Now when I start Luminance again I can select my bridge. Then if I press "next" the application crashes with the message:

Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/luminance/application.py", line 133, in _setup_finished self._init() File "/usr/lib/python3.6/site-packages/luminance/application.py", line 114, in _init application=self File "/usr/lib/python3.6/site-packages/luminance/views/window.py", line 42, in init self.groups_page.add(Groups(self.bridge)) File "/usr/lib/python3.6/site-packages/luminance/views/groups.py", line 32, in init self.groups_list.add(ListBoxRow(group)) File "/usr/lib/python3.6/site-packages/luminance/views/entity.py", line 69, in init self.brightness_scale.set_value(self.model.brightness) File "/usr/local/lib/python3.6/dist-packages/phue.py", line 185, in brightness self._brightness = self._get('bri') File "/usr/local/lib/python3.6/dist-packages/phue.py", line 484, in _get return self.bridge.get_group(self.group_id, *args, **kwargs) File "/usr/local/lib/python3.6/dist-packages/phue.py", line 1069, in get_group return self.request('GET', '/api/' + self.username + '/groups/' + str(group_id))['action'][parameter] KeyError: 'bri'

PanderMusubi commented 5 years ago

Note that phue has a new release, please see https://pypi.org/project/phue/#history

stellarpower commented 5 years ago

I'm on phue 1.1 and this error is still occuring. I've uninstalled and reinstalled and now I see no GUI but I get a terminal mesage saying Failed to register: timeout was reached.

PanderMusubi commented 5 years ago

You will need to do some manual fixes, see the issues.

lavacano commented 4 years ago

Is this the same issue?

$ luminance

(luminance:57988): Gtk-WARNING **: 21:10:06.281: Theme parsing error: gtk.css:68:35: The style property GtkButton:child-displacement-x is deprecated and shouldn't be used anymore. It will be removed in a future version

(luminance:57988): Gtk-WARNING **: 21:10:06.281: Theme parsing error: gtk.css:69:35: The style property GtkButton:child-displacement-y is deprecated and shouldn't be used anymore. It will be removed in a future version

(luminance:57988): Gtk-WARNING **: 21:10:06.281: Theme parsing error: gtk.css:73:46: The style property GtkScrolledWindow:scrollbars-within-bevel is deprecated and shouldn't be used anymore. It will be removed in a future version
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/luminance/application.py", line 133, in _setup_finished
    self._init()
  File "/usr/lib/python3.8/site-packages/luminance/application.py", line 112, in _init
    self.window = Window(
  File "/usr/lib/python3.8/site-packages/luminance/views/window.py", line 42, in __init__
    self.groups_page.add(Groups(self.bridge))
  File "/usr/lib/python3.8/site-packages/luminance/views/groups.py", line 32, in __init__
    self.groups_list.add(ListBoxRow(group))
  File "/usr/lib/python3.8/site-packages/luminance/views/entity.py", line 69, in __init__
    self.brightness_scale.set_value(self.model.brightness)
  File "/usr/lib/python3.8/site-packages/phue.py", line 194, in brightness
    self._brightness = self._get('bri')
  File "/usr/lib/python3.8/site-packages/phue.py", line 484, in _get
    return self.bridge.get_group(self.group_id, *args, **kwargs)
  File "/usr/lib/python3.8/site-packages/phue.py", line 1059, in get_group
    return self.request('GET', '/api/' + self.username + '/groups/' + str(group_id))['action'][parameter]
KeyError: 'bri'

I've read through the phue issues it is installed from git. I cant figure it out, do you have a direct link?

PanderMusubi commented 4 years ago

Also after sudo pip3 install -U phue? See also https://github.com/craigcabrey/luminance/issues/30

tatoosh commented 4 years ago

Same problem here on manjaro linux with phue 1.1 - crashing after selecting my brige.

luminance

(luminance:6391): Gtk-WARNING **: 21:20:37.543: Locale not supported by C library.
    Using the fallback 'C' locale.
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/phue.py", line 843, in get_light
    return state['state'][parameter]
KeyError: 'bri'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/luminance/application.py", line 133, in _setup_finished
    self._init()
  File "/usr/lib/python3.8/site-packages/luminance/application.py", line 112, in _init
    self.window = Window(
  File "/usr/lib/python3.8/site-packages/luminance/views/window.py", line 39, in __init__
    self.lights_page.add(FramedEntityList(self.bridge.get_light_objects('id').values()))
  File "/usr/lib/python3.8/site-packages/luminance/views/entity.py", line 27, in __init__
    self.list.add(ListBoxRow(entity))
  File "/usr/lib/python3.8/site-packages/luminance/views/entity.py", line 69, in __init__
    self.brightness_scale.set_value(self.model.brightness)
  File "/usr/lib/python3.8/site-packages/phue.py", line 194, in brightness
    self._brightness = self._get('bri')
  File "/usr/lib/python3.8/site-packages/phue.py", line 117, in _get
    return self.bridge.get_light(self.light_id, *args, **kwargs)
  File "/usr/lib/python3.8/site-packages/phue.py", line 845, in get_light
    raise KeyError(
KeyError: 'Not a valid key, parameter bri is not associated with light 5)'
florianorineveu commented 3 years ago

Up ? Same problem on my manjaro, with phue1.1...

PanderMusubi commented 2 years ago

Note to self for future reference, also apply this patch

diff --git a/luminance/views/entity.py b/luminance/views/entity.py
index e65dda9..06956a0 100644
--- a/luminance/views/entity.py
+++ b/luminance/views/entity.py
@@ -57,16 +57,37 @@ class ListBoxRow(Gtk.ListBoxRow):
         self.color_chooser = builder.get_object('color-chooser')

         if self.model.on:
-            self.color_chooser.set_rgba(
-                hsv_to_gdk_rgb(
-                    self.model.hue,
-                    self.model.saturation,
-                    self.model.brightness
+            try:
+                self.color_chooser.set_rgba(
+                    hsv_to_gdk_rgb(
+                        self.model.hue,
+                        self.model.saturation,
+                        self.model.brightness
+                    )
                 )
-            )
+            except KeyError:
+                try:
+                    self.color_chooser.set_rgba(
+                        hsv_to_gdk_rgb(
+                            0,
+                            0,
+                            self.model.brightness
+                        )
+                    )
+                except KeyError:
+                    self.color_chooser.set_rgba(
+                        hsv_to_gdk_rgb(
+                            0,
+                            0,
+                            0
+                        )
+                    )

         self.brightness_scale = builder.get_object('brightness-scale')
-        self.brightness_scale.set_value(self.model.brightness)
+        try:
+            self.brightness_scale.set_value(self.model.brightness)
+        except KeyError:
+            self.brightness_scale.set_value(0)

         self.color_chooser_popover_button = builder.get_object('color-chooser-popover-button')