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.0.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.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fancli-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 49107d7983a9379b53074eebc3e670b752abf528967b8e9f8970ce619aee87dc
MD5 14fe456e61da90cb602c42a431a81306
BLAKE2b-256 ef527992735c95b44e22c6058286616fc848e11912a62070169a0d41578ffefc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fancli-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 20309cfa0cdb9e6b37d294f19a378b34d0b026ab7bcd996bfdbd2a5e7c6b523f
MD5 691c87790e4d86494a2d59b6e6d067a5
BLAKE2b-256 b5852c445007c52b1a2a077c4668853d1b700af966a7338543f79468d3e68d3f

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