mathoudebine / turing-smart-screen-python

Unofficial Python system monitor and library for small IPS USB-C displays like Turing Smart Screen or XuanFang
GNU General Public License v3.0
966 stars 166 forks source link

[Add] Ping and Weather custom sensor + ColoredFlat Theme #510

Open Psykotik opened 2 months ago

Psykotik commented 2 months ago

Hello, I've added two sensors :

and one theme :

Ping Sensor

The ping sensor is used to know the latency of our network connection, and is based on the simple ping livrary from python (added to requirements.txt). It is using the "custom sensor" not-so-new architecture to allow the tracking of ping. pros: easy to do and maintain cons: the ping module cannot (for the moment) have it's own interval, making it strange/difficult to use if there are multiple custom sensor that need different interval.

Weather Sensor

Added a weather sensor, first using also the custom sensor module, but due to the interval of custom sensor, I had to change the way to do it and create a "real sensor". Modifications are based on the fork https://github.com/GaryStar/turing-smart-screen-python/tree/feature/names-alert-weather from @GaryStar with modifications. The weather sensor has it's own setup in config.yaml, and need an api key from OneCall 3.0 api openweathermap.org. It's free for the first daily 1000 api calls, so it's enough for a daily use even if the program is running 24/7 if the interval is setuped >90s (note the API refresh rate seems to be more like 10 to 20 minutes, so it's perfect.

New Theme : Colored Flat

preview

I don't know if it's the right way to do it, or even if it will be interesting for other, but I added my personnal theme called Colored Flat, that features the new weather component, and Ping component with line_graphs ping history