Python wrapper for controlling the GeekMagic SmallTV
Project description
GeekMagicWeatherClockAPI
A Python wrapper for controlling the GeekMagic SmallTV over your local network. Supports uploading images/GIFs, switching themes, adjusting brightness, and managing files on the device.
Installation
pip install GeekMagicWeatherClockAPI
Requirements
- Python 3.10+
requests(installed automatically)
Setup
Find your SmallTV's local IP address (check your router's device list or the SmallTV's settings menu), then:
from GeekMagicWeatherClockAPI import SmallTV
tv = SmallTV("192.168.1.85")
A persistent HTTP session is created automatically. All requests reuse this session, so there's no need to manage connections manually.
Return values
Every method returns the same dictionary — no exceptions are raised for network or validation errors:
{
"success": bool, # True if the device responded successfully
"status_code": int | None, # HTTP status code, or None if the request never completed
"response": str | None, # Raw response body from the device
"error": str | None, # Human-readable error message on failure, else None
}
Checking results
result = tv.set_brightness(50)
if result["success"]:
print("Done!")
else:
print("Something went wrong:", result["error"])
Usage
Upload an image
tv.upload("my_animation.gif")
# Increase retries for flaky firmware responses
tv.upload("my_animation.gif", retries=5)
Display an image
tv.set_image("my_animation.gif")
Upload and immediately display
tv.upload_and_set("my_animation.gif")
Replace an image
Deletes the old file, uploads the new one, and displays it — all in one call.
tv.replace("old_animation.gif", "new_animation.gif")
Delete an image
tv.delete("my_animation.gif")
Set brightness
Accepts a value from 0 to 100.
tv.set_brightness(75)
Set theme
Accepts either an integer (1–7) or the theme name as a string (case-insensitive).
tv.set_theme(3)
tv.set_theme("Photo Album")
| ID | Theme Name |
|---|---|
| 1 | Weather Clock Today |
| 2 | Weather Forecast |
| 3 | Photo Album |
| 4 | Time Style 1 |
| 5 | Time Style 2 |
| 6 | Time Style 3 |
| 7 | Simple Weather Clock |
Examples
Basic setup and display
from GeekMagicWeatherClockAPI import SmallTV
tv = SmallTV("192.168.1.85")
tv.upload_and_set("spaceman.gif")
tv.set_brightness(30)
tv.set_theme("Weather Clock Today")
Checking every result
tv = SmallTV("192.168.1.85")
for step, result in [
("upload", tv.upload("clock.gif")),
("display", tv.set_image("clock.gif")),
("brightness", tv.set_brightness(60)),
("theme", tv.set_theme(1)),
]:
status = "OK" if result["success"] else f"FAILED — {result['error']}"
print(f"{step:12} {status}")
Batch upload a folder of GIFs
from pathlib import Path
tv = SmallTV("192.168.1.85")
gifs = list(Path("./animations").glob("*.gif"))
for gif in gifs:
result = tv.upload(gif)
if result["success"]:
print(f"Uploaded: {gif.name}")
else:
print(f"Failed: {gif.name} — {result['error']}")
Rotate through themes on a schedule
import time
tv = SmallTV("192.168.1.85")
themes = list(tv.THEMES.keys()) # [1, 2, 3, 4, 5, 6, 7]
for theme_id in themes:
result = tv.set_theme(theme_id)
if result["success"]:
print(f"Now showing: {tv.THEMES[theme_id]}")
time.sleep(10)
Night mode — dim at a set hour
from datetime import datetime
tv = SmallTV("192.168.1.85")
hour = datetime.now().hour
brightness = 10 if 22 <= hour or hour < 7 else 80
result = tv.set_brightness(brightness)
print(f"Brightness set to {brightness}" if result["success"] else result["error"])
Upload with retry and graceful fallback
tv = SmallTV("192.168.1.85")
result = tv.upload("hero.gif", retries=5)
if result["success"]:
tv.set_image("hero.gif")
else:
print("Upload failed after all retries:", result["error"])
# Fall back to a theme instead
tv.set_theme("Weather Clock Today")
Swap a live image safely
tv = SmallTV("192.168.1.85")
# Removes "old.gif", uploads "new.gif", and displays it
result = tv.replace("old.gif", "new.gif")
if not result["success"]:
print("Replace failed:", result["error"])
Notes
- The SmallTV firmware occasionally returns malformed
Content-Lengthheaders on upload responses. Theuploadmethod automatically retries and cleans up partial uploads when this happens. - All methods return a structured dict and never raise — check
result["success"]instead of wrapping calls intry/except. - File management methods operate on the
/image/directory on the device. - The
THEMESdict is a public class attribute and can be read directly to enumerate valid theme names:SmallTV.THEMES.
Dev note: on release, bump the version in
pyproject.tomland runpython -m buildthentwine upload dist/*.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file geekmagicweatherclockapi-0.1.1.tar.gz.
File metadata
- Download URL: geekmagicweatherclockapi-0.1.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
997f73ccb00acc164a6a7ce0b60a354798a46b62d711a10f9098cad62544f59a
|
|
| MD5 |
8284e5b816faf2164c93138bfdc808fb
|
|
| BLAKE2b-256 |
dfae0e90a44d335a62aaf8831999d5aaeea24b910348ecdbb74d6a63b3d88701
|
File details
Details for the file geekmagicweatherclockapi-0.1.1-py3-none-any.whl.
File metadata
- Download URL: geekmagicweatherclockapi-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c00a6966617fcb24758b6e9c099e4c639e79a53d6dbbf887c6b8024d6888c1c9
|
|
| MD5 |
02705d300ab7f0748008bf2c88bc8f95
|
|
| BLAKE2b-256 |
965d1b89095bc2fcd63b1f8ca5d9b4ce9c08ee194a8cd87858dd88b7f085992b
|