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

Add date/time metrics #32

Closed
mathoudebine opened this issue Aug 30, 2022 · 7 comments · Fixed by #72
Closed

Add date/time metrics #32

mathoudebine opened this issue Aug 30, 2022 · 7 comments · Fixed by #72
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mathoudebine
Copy link
Owner

Is your feature request related to a problem? If so, please describe the problem.
There is no entries in theme.yaml for date/time

Describe the feature / solution to your problem you'd like
Entries in theme.yaml to be able to display date and time on screen, with configurable format

Describe alternatives you've considered / and or tested
Using static_text entries but it is not updated at runtime

Environment:

  • Release 2.0.0-beta.1, feature/system-monitor branch
  • All OS with version [e.g. Windows 11, Ubuntu 22.04]
  • Python version > 3.7
@waynehuang85
Copy link

In addition to the date/time metrics, would love to see the Network In/Out if readily availalbe.

Why - this secondary monitor screen will be a nice addition to NAS system like Synology DS or other headless home theater PC(HTPC)

Currently using it on my Raspberry Pi 3B+ (running Retropie) however CPU temp is not supported

@Nealtron
Copy link

In addition to the date/time metrics, would love to see the Network In/Out if readily availalbe.

Why - this secondary monitor screen will be a nice addition to NAS system like Synology DS or other headless home theater PC(HTPC)

Currently using it on my Raspberry Pi 3B+ (running Retropie) however CPU temp is not supported

I love this idea, but it should probably be it's own feature request.

@mathoudebine
Copy link
Owner Author

@Nealtron and @waynehuang85 you can subscribe to this feature request for network metrics: #51

@Rollbacke
Copy link
Contributor

Hi,

My purpose:

I used datetime.

In main.py, add:

scheduler.DateStats()

In scheduler.py, add:

@async_job("Date_Stats")
@schedule(timedelta(seconds=THEME_DATA['STATS']['DATE'].get("INTERVAL", None)).total_seconds())
def DateStats():
    # logger.debug("Refresh date stats")
    stats.Date.stats()

In stats.py, add:

class Date:
    @staticmethod
    def stats():
        date_now = datetime.datetime.now()

        if THEME_DATA['STATS']['DATE']['DAY']['TEXT'].get("SHOW", False):
            display.lcd.DisplayText(
                text=f"{date_now.day}-{date_now.month}-{date_now.year}",
                x=THEME_DATA['STATS']['DATE']['DAY']['TEXT'].get("X", 0),
                y=THEME_DATA['STATS']['DATE']['DAY']['TEXT'].get("Y", 0),
                font=THEME_DATA['STATS']['DATE']['DAY']['TEXT'].get("FONT", "roboto-mono/RobotoMono-Regular.ttf"),
                font_size=THEME_DATA['STATS']['DATE']['DAY']['TEXT'].get("FONT_SIZE", 10),
                font_color=THEME_DATA['STATS']['DATE']['DAY']['TEXT'].get("FONT_COLOR", (0, 0, 0)),
                background_color=THEME_DATA['STATS']['DATE']['DAY']['TEXT'].get("BACKGROUND_COLOR", (255, 255, 255)),
                background_image=get_full_path(THEME_DATA['PATH'],
                                               THEME_DATA['STATS']['DATE']['DAY']['TEXT'].get("BACKGROUND_IMAGE",
                                                                                               None))
            )

        if THEME_DATA['STATS']['DATE']['HOUR']['TEXT'].get("SHOW", False):
            display.lcd.DisplayText(
                text=f"{date_now.strftime('%H:%M:%S')}",
                x=THEME_DATA['STATS']['DATE']['HOUR']['TEXT'].get("X", 0),
                y=THEME_DATA['STATS']['DATE']['HOUR']['TEXT'].get("Y", 0),
                font=THEME_DATA['STATS']['DATE']['HOUR']['TEXT'].get("FONT", "roboto-mono/RobotoMono-Regular.ttf"),
                font_size=THEME_DATA['STATS']['DATE']['HOUR']['TEXT'].get("FONT_SIZE", 10),
                font_color=THEME_DATA['STATS']['DATE']['HOUR']['TEXT'].get("FONT_COLOR", (0, 0, 0)),
                background_color=THEME_DATA['STATS']['DATE']['HOUR']['TEXT'].get("BACKGROUND_COLOR", (255, 255, 255)),
                background_image=get_full_path(THEME_DATA['PATH'],
                                               THEME_DATA['STATS']['DATE']['HOUR']['TEXT'].get("BACKGROUND_IMAGE",
                                                                                                None))
            )

In your theme.yaml:

  DATE:
    # In seconds. Longer intervals cause this to refresh more slowly.
    # Setting to lower values will display near real time data,
    # but may cause significant CPU usage or the display not to update properly
    INTERVAL: 1
    DAY:
      TEXT:
        SHOW: True
        X: 4
        Y: 4
        FONT: roboto-mono/RobotoMono-Regular.ttf
        FONT_SIZE: 16
        FONT_COLOR: 53, 191, 92
        # BACKGROUND_COLOR: 0, 0, 0
        BACKGROUND_IMAGE: background.png
    HOUR:
      TEXT:
        SHOW: True
        X: 160
        Y: 4
        FONT: roboto-mono/RobotoMono-Regular.ttf
        FONT_SIZE: 16
        FONT_COLOR: 53, 191, 92
        # BACKGROUND_COLOR: 0, 0, 0
        BACKGROUND_IMAGE: background.png

@RussNelson
Copy link
Contributor

I created a pull request for it.

@Rollbacke
Copy link
Contributor

Thanks @RussNelson ;)

@mathoudebine
Copy link
Owner Author

Implemented in #72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants