Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

picture showing 2 sets of planets in key #10

Closed
gshoebridge opened this issue Aug 20, 2021 · 7 comments
Closed

picture showing 2 sets of planets in key #10

gshoebridge opened this issue Aug 20, 2021 · 7 comments

Comments

@gshoebridge
Copy link

I have installed this today and found the image/camera is showing the key with each planet in twice.
See attached image.
Otherwise great solution.
image

@mjnovotny82
Copy link

It looks like the list is append to itself, hence the double entries in the legend. It was doing the same for me and I had once tripled the listings. My HA is running Debian 11 on an old Dell Latitude E6410.

Looks like adding self._points.clear() to the def _load_points(self): section of bodies.py did the trick for me. It is basically repopulating the list on each load.

def _load_points(self):
    """Initialize the objects representing the Sun, moon, and planets."""
    self._points.clear()
    for name, planet_label, color, size in BODIES:
        if self._planet_list is not None and name not in self._planet_list:
            # planet not requested. skip it.
            continue
        self._points.append(
            Point(name, self._planets[planet_label], color, size, self)
        )

@partofthething
Copy link
Owner

Good find. I can probably also just check to see if there are any points before loading the points to avoid this problem with a bit more performance. I didn't realize that was getting double called sometimes. Thanks.

@partofthething
Copy link
Owner

partofthething commented Dec 7, 2021

I've seen this before, but was unable to replicate today. I've also seen related funny-business when there are multiple tabs showing the skyfield. In 43e73a5 I made a few upgrades that I think should stabilize this. I released it as 1.2. Can you try it and see if it helps?

@mjnovotny82
Copy link

I redownloaded via HACS to wipe my change but still no luck. I needed to add self._points.clear() back in on the bodies.py.

A thing that happen with v.1.1 and this version is that the initial load on the lovelace tab is correct with one copy of the legend, but after the image reloads, that is when it duplicates. It stays duplicated throughout the entire session. Changing tabs, etc. not "reload". It could also be associated the the camera properties.

Wonder if the speed of the server may make a difference, too.

@partofthething
Copy link
Owner

Huh! Well I have no idea how those extra points could be added twice. Anyway I guess I'll have to do another version that checks to see if _points is empty before appending more. Did you try that option out by chance? I like it because it should be less overall cpu cycles than clearing and repopulating ever time.

@mjnovotny82
Copy link

I did not check if _points were emptied. Not sure the exact syntax with python. Now, with the little bit of reverse engineering, it would be weird if BODIES or _planet_list is being called twice, or maybe it thinks that it is null when the second reload occurs.

Ever since my C++ computer science courses 20 years ago, I still to this day dislike this kind of programming. I prefer servers or networks hands down anyday. I'm 3 months into HA running on Debian 11. A steeper learning curve than I expected with the HA syntax, but I'm loving that I'm using HA now though.

@partofthething
Copy link
Owner

Ok well I pushed a clear. Hopefully works now as you report.

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

No branches or pull requests

3 participants