hoppla-sa icon indicating copy to clipboard operation
hoppla-sa copied to clipboard

[possible bug?] Manual refresh necessary for up-to-date information

Open tom-github-account opened this issue 3 years ago • 12 comments

Hi,

I'm on KDE Neon, using the latest version of the plasmoid available from the GUI installer (2.8.something, I think?). I can only get up-to-date information about my lights by manually hitting the "refresh" button.

My assumption is that the "check for status every n seconds" setting in the configuration is meant to set a polling interval for getting up-to-date information, but I might be wrong about that...

If you need any debugging information then let me know (although you may have to tell me where to find it).

Thanks!

P.S. Otherwise love the widget, really good work!

tom-github-account avatar May 17 '21 21:05 tom-github-account

Hi, thank you very much for the comment. If you start plasmashell on a console you should get some debug information, but by default the output is limited. You can set the debug flag in the main.qml and Hue.qml files with a text editor for more.

However: yes, there is a setting for polling and I recommend enabling it, else you indeed have to fetch updates manually. A delayed update is possible if the connection between your computer/laptop and the hue bridge is slow, e.g. if you proxy that through a VPN / your home webserver. Otherwise it should work. What version are you trying with?

Fuchs avatar Jun 07 '21 17:06 Fuchs

I'm on KDE Neon, and "configure hue light control -> about", it reports version 2.6. I don't have any fancy networking set up - both my laptop and the Hue Bridge are on the same network. If there's a polling setting, that fixes this "bug"! Is it available in this version? If so, how do I enable it?

tom-github-account avatar Jun 07 '21 21:06 tom-github-account

The default in the settings (where you configure the bridge, checkbox and spinbox below) should be 30 seconds and fine. It's odd that this doesn't work but the refresh button does, since the logic behind is roughly the same.

I assume neon has plasma 5.21? Then you could try the 4.0.0. I released today, not much changed, but 2.6.* is a bit old-ish, so worth a try.

Fuchs avatar Jun 07 '21 21:06 Fuchs

Okay, built and installed, but now this message (sorry, not really familiar with plasma development!)

$ plasmapkg2 -i package Error: Installation of /home/tom/customPrograms/hoppla-sa/package failed: /home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa already exists

When I right click on the desktop -> add widgets, then search "hue", I only get the old 2.6 version. Tried logging out and back in again, same thing. What am I missing?

tom-github-account avatar Jun 07 '21 22:06 tom-github-account

You need to rename or remove the /home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa folder (note that folders starting with ., e.g. the .local one, are hidden folders)

Fuchs avatar Jun 08 '21 15:06 Fuchs

Okay, lots of progress. I'm now running version 4.0 from the terminal, but the bug is still there.

When I go into the configuration menu, I see the following messages. If I had to guess, I'd say these look like layout stuff, and not relevant to this problem. When I toggle the "check for status every n seconds" checkbox I don't see any output in the terminal. Same when I change the value of n. Will now try turning on debug mode.

Click to show terminal messages

tom@tom-swift3:~$ QQmlEngine::setContextForObject(): Object already has a QQmlContext QQmlEngine::setContextForObject(): Object already has a QQmlContext file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/configBridge.qml:55:9: QML GroupBox: Binding loop detected for property "implicitWidth" file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/configBridge.qml:55:9: QML GroupBox: Binding loop detected for property "implicitWidth" file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/configBridge.qml:55:9: QML GroupBox: Binding loop detected for property "implicitWidth" file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/configBridge.qml:55:9: QML GroupBox: Binding loop detected for property "implicitWidth" file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/configBridge.qml:55:9: QML GroupBox: Binding loop detected for property "implicitWidth" file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/configBridge.qml:55:9: QML GroupBox: Binding loop detected for property "implicitWidth" file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/configBridge.qml:55:9: QML GroupBox: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/configBridge.qml:98:9: QML GroupBox: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/configBridge.qml:172:9: QML GroupBox: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. file:///usr/share/plasma/shells/org.kde.plasma.desktop/contents/configuration/ConfigurationAppletPage.qml:50:5: QML Loader: Binding loop detected for property "height" file:///usr/share/plasma/shells/org.kde.plasma.desktop/contents/configuration/ConfigurationAppletPage.qml:50:5: QML Loader: Binding loop detected for property "height" file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/configBridge.qml:55:9: QML GroupBox: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/configBridge.qml:98:9: QML GroupBox: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/configBridge.qml:172:9: QML GroupBox: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. file:///usr/lib/x86_64-linux-gnu/qt5/qml/org/kde/kirigami.2/templates/private/ScrollView.qml:131:9: QML ScrollBar: Binding loop detected for property "visible" file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/configBridge.qml:55:9: QML GroupBox: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/configBridge.qml:98:9: QML GroupBox: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/configBridge.qml:172:9: QML GroupBox: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. QFont::setPointSizeF: Point size <= 0 (0.000000), must be greater than 0 Both point size and pixel size set. Using pixel size. file:///usr/share/plasma/plasmoids/org.kde.plasma.digitalclock/contents/ui/Tooltip.qml:66:9: QML GridLayout (parent or ancestor of QQuickLayoutAttached): Binding loop detected for property "minimumWidth" file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/LightItem.qml:100:17: Unable to assign double to QQuickAnchorLine file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/LightItem.qml:100:17: Unable to assign double to QQuickAnchorLine file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/LightItem.qml:100:17: Unable to assign double to QQuickAnchorLine file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/LightItem.qml:100:17: Unable to assign double to QQuickAnchorLine file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/GroupItem.qml:93:17: Unable to assign double to QQuickAnchorLine file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/LightItem.qml:100:17: Unable to assign double to QQuickAnchorLine file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/LightItem.qml:100:17: Unable to assign double to QQuickAnchorLine file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/GroupItem.qml:93:17: Unable to assign double to QQuickAnchorLine file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/FullRepresentation.qml:0: ReferenceError: toolBar is not defined Error: cannot change the containment to AppletsLayout file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/configBridge.qml:55:9: QML GroupBox: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/configBridge.qml:98:9: QML GroupBox: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/configBridge.qml:172:9: QML GroupBox: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. file:///usr/share/plasma/shells/org.kde.plasma.desktop/contents/views/Panel.qml:26:1: QML Panel: Binding loop detected for property "state" file:///usr/share/plasma/shells/org.kde.plasma.desktop/contents/views/Panel.qml:26:1: QML Panel: Binding loop detected for property "state"

tom-github-account avatar Jun 08 '21 20:06 tom-github-account

Changed value of "contents/code/hue.js:23": var debugMode = true;

Similarly, contents/ui/main.qml:31: property bool debugMode: true

Not seeing anything different in the output. Re-started plasma shell, same.

I've noticed the following - I think this would have happened with debug mode off. When I right-click and manually refresh, I get the following output:

Click to show terminal messages

file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/FullRepresentation.qml:205:27: QML ActionItem: Binding loop detected for property "width" file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/FullRepresentation.qml:205:27: QML ActionItem: Binding loop detected for property "width" file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/LightItem.qml:100:17: Unable to assign double to QQuickAnchorLine file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/LightItem.qml:100:17: Unable to assign double to QQuickAnchorLine file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/LightItem.qml:100:17: Unable to assign double to QQuickAnchorLine file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/FullRepresentation.qml:251:27: QML LightItem: Binding loop detected for property "width" file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/FullRepresentation.qml:251:27: QML LightItem: Binding loop detected for property "width" file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/FullRepresentation.qml:251:27: QML LightItem: Binding loop detected for property "width" file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/GroupItem.qml:93:17: Unable to assign double to QQuickAnchorLine file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/GroupItem.qml:93:17: Unable to assign double to QQuickAnchorLine file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/FullRepresentation.qml:228:27: QML GroupItem: Binding loop detected for property "width" file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/FullRepresentation.qml:228:27: QML GroupItem: Binding loop detected for property "width" file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/LightItem.qml:100:17: Unable to assign double to QQuickAnchorLine file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/LightItem.qml:100:17: Unable to assign double to QQuickAnchorLine file:///home/tom/.local/share/plasma/plasmoids/ch.fuchsnet.plasma.hoppla-sa/contents/ui/LightItem.qml:100:17: Unable to assign double to QQuickAnchorLine file:///usr/share/plasma/shells/org.kde.plasma.desktop/contents/views/Panel.qml:26:1: QML Panel: Binding loop detected for property "state" file:///usr/share/plasma/shells/org.kde.plasma.desktop/contents/views/Panel.qml:26:1: QML Panel: Binding loop detected for property "state"

I do not see any such output at other times, even with my polling rate set to 1s. Clearly we're getting stuck before this output happens.

tom-github-account avatar Jun 08 '21 20:06 tom-github-account

I think I'm close... "function checkHueConnection" in hue.js:672 is called at the correct interval, so all the clocks appear to be working.

In that function, I've added the following debug: var json = request.responseText; dbgPrint("json = " + json); try { var myResult = JSON.parse(json); dbgPrint("myResult = " + myResult); } catch(e) { dbgPrint("Failed to parse json: " + json); return; } dbgPrint("myResult = " + myResult); dbgPrint("myResult[0] = " + myResult[0]); if(!myResult[0]) { callback("main", enforce); useAltConnection = false; dbgPrint("myResult[0] is falsey: " + myResult[0]); return; } if(myResult[0].error) { dbgPrint("myResult[0].error: " + myResult[0]); if(myResult[0].error.type == 1) { dbgPrint("myResult[0].error.type == 1: " + myResult[0]); callback("unauth", enforce); useAltConnection = false; return; } }

etc, etc...

I get the following output:

qml: [Hoppla-Hue] json = {"1":{"name":"living room","lights":["1","3"],"sensors":[],"type":"Room","state":{"all_on":true,"any_on":true},"recycle":false,"class":"Living room","action":{"on":true,"bri":254,"hue":7613,"sat":203,"effect":"none","xy":[0.5051,0.4151],"ct":454,"alert":"none","colormode":"ct"}},"2":{"name":"bedroom","lights":["2"],"sensors":[],"type":"Room","state":{"all_on":true,"any_on":true},"recycle":false,"class":"Bedroom","action":{"on":true,"bri":254,"hue":8402,"sat":140,"effect":"none","xy":[0.4575,0.4099],"ct":366,"alert":"none","colormode":"xy"}}} qml: [Hoppla-Hue] myResult = [object Object] qml: [Hoppla-Hue] myResult = [object Object] qml: [Hoppla-Hue] myResult[0] = undefined qml: [Hoppla-Hue] myResult[0] is falsey: undefined

That json looks correct - it seems to reflect the current state of the lights in the house. I can update the lights with my phone, and that json then updates accordingly.

It appears to parse correctly, but accessing element [0] then fails (?).

Compare that with this output when I manually refresh:

qml: [Hoppla-Hue] json = {"1":{"name":"living room","lights":["1","3"],"sensors":[],"type":"Room","state":{"all_on":true,"any_on":true},"recycle":false,"class":"Living room","action":{"on":true,"bri":254,"hue":7613,"sat":203,"effect":"none","xy":[0.5051,0.4151],"ct":454,"alert":"none","colormode":"ct"}},"2":{"name":"bedroom","lights":["2"],"sensors":[],"type":"Room","state":{"all_on":true,"any_on":true},"recycle":false,"class":"Bedroom","action":{"on":true,"bri":254,"hue":8402,"sat":140,"effect":"none","xy":[0.4575,0.4099],"ct":366,"alert":"none","colormode":"xy"}}} qml: [Hoppla-Hue] myResult = [object Object] qml: [Hoppla-Hue] myResult = [object Object] qml: [Hoppla-Hue] myResult[0] = undefined

When manually refreshing, myResult is still an Object, myResult[0] is still undefined, but it's somehow not false-y. The manual update works, whereas the polling update fails.

It's getting late here, and I suspect I'm starting to reach the limits of what I can do without understanding more about how javaScript works - @Fuchs , what do you make of it?

tom-github-account avatar Jun 08 '21 21:06 tom-github-account

Given that the json it gets is the same, my best guess would be that the bug is somewhere else and that it does have the data, but it does not update the GUI. The QML Layout warnings can be safely ignored I think. Can't say that I am terribly happy about the undefined / missing array entry there, but given it's the same (and the true/false shouldn't make the difference) for the working manual refresh, I guess that's not the issue either.

What info isn't automatically updated? The light state (on/off), the colour / brightness, all of it, ...? Are groups / rooms updated? (If you have any of these)

Fuchs avatar Jun 09 '21 11:06 Fuchs

Fair enough - js and xml aren't really my thing, I defer to your greater experience!

I have two groups (or rooms? I'm not really clear on the difference between groups and rooms - the above json output probably knows more than I do!). Nothing is updated when polling (although everything updates when manually refreshed).

tom-github-account avatar Jun 09 '21 12:06 tom-github-account

One thing you could try is to change the logic to do the full update (which will reload everything) periodically. This will likely put a bit more CPU load and traffic on it, but should work. It's still not ideal as it probably won't update when you change things (e.g. switch a light on) but it might help finding where the issue happens. Unfortunately I can't reproduce that behaviour here under a couple of distros, and you're the first case I hear from, which makes this harder to fix, sorry :/

Fuchs avatar Jun 09 '21 13:06 Fuchs

I probably wont' have time to look at this for at least three weeks, but at some stage I'd like to submit a patch properly. Thanks for your help!

I'll leave the ticket open - this is still an issue on my machine.

tom-github-account avatar Jun 09 '21 16:06 tom-github-account