Skip to main content

CLI for controlling smart fans (currently Atomberg)

Project description

fancli

PyPI version Python versions License: MIT

Terminal CLI for smart fans. It refreshes and caches an access token, reads device state, and sends commands (power, speed, timer, lights, and more). Atomberg is supported today via the Atomberg IoT developer API; more vendors may be added later.

Repository: github.com/Affan-sajid/fancli

Requirements

  • Python 3.9+

Install

From PyPI

pip install fancli

CLI only, isolated from your default Python environment (recommended):

pipx install fancli

That installs the fancli command on your PATH. With plain pip, prefer a virtual environment or pip install --user and ensure your user scripts directory is on PATH.

From source (development)

From a clone of this repository:

python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -e .

You should then have the fancli command on your PATH.

Quick start

  1. Run interactive setup (credentials, device list, save DEVICE_ID):

    fancli setup
    
  2. Check status:

    fancli status
    
  3. Send a command:

    fancli set power true
    fancli set speed 3
    
  4. Key/value reference for set:

    fancli set --help
    

    Or: fancli set -h

Run fancli or fancli help for the full user guide (same text as the bundled help.txt).

Environment

Configure via a .env file (project directory, current working directory, or after setup ~/.config/fancli/.env) or your shell. Do not commit .env or paste real tokens into issues—use placeholders when asking for help.

Variables are names only below; get real values from the vendor developer portal and fancli setup.

Variable Required Description
REFRESH_TOKEN Yes OAuth refresh token from the developer portal
API_KEY Yes API key (x-api-key header)
DEVICE_ID For status / set Target device UUID

Optional:

Variable Description
API_URL API base URL (default: https://api.developer.atomberg-iot.com)
FANCLI_COMPANY Vendor name (e.g. atomberg); set by fancli setup
FANCLI_TOKEN_FILE Override path for cached access token JSON (default: ~/.config/fancli/token.json)

Access tokens are cached for up to 23 hours; fancli refreshes when the cache is stale or the API returns 401.

Commands (summary)

Command Purpose
fancli / fancli help Full user guide
fancli setup Interactive wizard: vendor, credentials, list devices, save selection
fancli status Device state (--json for raw JSON)
fancli set <key> <value> Send a command; fancli set --help / -h for the key/value reference (Quick start)

Troubleshooting

  • REFRESH_TOKEN is not set — Run fancli setup or set variables in .env or your environment.
  • HTTP 401 — fancli tries to refresh the token once; verify refresh token and API key if it keeps failing.
  • help file not found — Reinstall the package or run from a checkout with fancli/help.txt present.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fancli-0.1.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fancli-0.1.1-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file fancli-0.1.1.tar.gz.

File metadata

  • Download URL: fancli-0.1.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for fancli-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c17af300e8640889729460305e8b0aaf56033307ae44dea48c1cd82e00f82c60
MD5 7766efb4370bb32745c27d791bf58d68
BLAKE2b-256 e265457c58c6b0bf3d17e8149edcd129b54fb45aaadbb4b65e1f17efe066abc6

See more details on using hashes here.

File details

Details for the file fancli-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: fancli-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for fancli-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e68ad8cf5f689ae435656cfec2dfa469663a39adedc0cbb676bafffaff0a5d80
MD5 7c60673c1acacb1e91428f7a52e8ac82
BLAKE2b-256 744347227da99a786b95062b54e5d742dd9404264ed10e9e9bece85af3970f47

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page