Code Monkey home page Code Monkey logo

Comments (7)

mjnovotny82 avatar mjnovotny82 commented on May 26, 2024

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)
        )

from ha_skyfield.

partofthething avatar partofthething commented on May 26, 2024

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.

from ha_skyfield.

partofthething avatar partofthething commented on May 26, 2024

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?

from ha_skyfield.

mjnovotny82 avatar mjnovotny82 commented on May 26, 2024

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.

from ha_skyfield.

partofthething avatar partofthething commented on May 26, 2024

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.

from ha_skyfield.

mjnovotny82 avatar mjnovotny82 commented on May 26, 2024

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.

from ha_skyfield.

partofthething avatar partofthething commented on May 26, 2024

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

from ha_skyfield.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.