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 -v / fancli --version Print installed fancli version
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.2.tar.gz (13.5 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.2-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fancli-0.1.2.tar.gz
  • Upload date:
  • Size: 13.5 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.2.tar.gz
Algorithm Hash digest
SHA256 9a34d2b2d7c32b4a22748c017e6d48885b800cd9b712ab6bad267fc867124412
MD5 0f900ecbb51ec5b1074c94536de4e44e
BLAKE2b-256 e7f3e9aae549dd48b77e835dfe604c4e4e038b586f297017b17c3f27160f7e76

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fancli-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8a5213657ae6e1f0cce00b02c0f748dbc5b3dd2d1ba2af38e85f5afc10f4dd33
MD5 d3b32d04e083938c6814cfe3d1178568
BLAKE2b-256 095afe9ac6533cd61f3a6dcd94ecb01958fce1c5cc41ab5db8d56aee403873d9

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