Metadata-Version: 2.4
Name: enteliscript
Version: 0.2.2
Summary: A terminal application for interacting with the Delta Controls enteliWEB REST API. It provides a Textual-based interactive TUI for querying and writing BACnet data across sites, devices, objects, and properties.
Author: Matt Kaufman
License: MIT
Project-URL: Homepage, https://github.com/makaufmanOS/enteliscript
Project-URL: Issues, https://github.com/makaufmanOS/enteliscript/issues
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: rich>=13.0.0
Requires-Dist: requests>=2.0.0
Requires-Dist: textual>=0.50.0
Requires-Dist: platformdirs>=4.0.0
Dynamic: license-file

# enteliscript

A terminal application for interacting with the [Delta Controls](https://www.deltacontrols.com/) enteliWEB REST API. It provides a [Textual](https://textual.textualize.io/)-based interactive TUI for querying and writing BACnet data across sites, devices, objects, and properties.

![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue)
![PyPI - Version](https://img.shields.io/pypi/v/enteliscript)
![License: MIT](https://img.shields.io/badge/license-MIT-green)
![GitHub last commit](https://img.shields.io/github/last-commit/makaufmanOS/enteliscript)
![PyPI - Downloads](https://img.shields.io/pypi/dd/enteliscript)

## Features

- **Interactive TUI** – Rich terminal interface with command input, scrollable output log, spinner feedback for blocking operations, and command history (↑/↓ arrows).
- **Full BACnet hierarchy** – Query sites, devices, objects, and properties through the enteliWEB REST API.
- **Property writes** – Write individual properties or batch-write from a CSV file.
- **Persistent credentials** – Credentials are saved to a platform-appropriate config directory and reused across sessions.
- **Rotating log files** – All API calls and user actions are logged to rotating files for troubleshooting.

## Installation

```bash
pip install enteliscript
```

Or install from source:

```bash
git clone https://github.com/makaufmanOS/enteliscript.git
cd enteliscript
pip install .
```

## Quick Start

```bash
enteliscript
```

On first launch, follow the guided flow shown in the TUI:

1. **`setlogin <username> <password>`** – Save your enteliWEB credentials.
2. **`login`** – Authenticate against the enteliWEB server.
3. **`setsite`** – Select a site from the list of available sites.
4. Run any query or write command.

## Commands

| Command | Usage | Description |
| ------- | ----- | ----------- |
| `setlogin` | `setlogin <username> <password>` | Save enteliWEB credentials for this user. |
| `getlogin` | `getlogin` | Show the currently saved username. |
| `login` | `login` | Authenticate the enteliWEB API. |
| `setsite` | `setsite` | List available sites and select one. |
| `getsite` | `getsite` | Show the currently selected site. |
| `getdevices` | `getdevices` | List devices at the current site. |
| `getobjects` | `getobjects <device>` | List BACnet objects for a device. |
| `writeproperty` | `writeproperty <device> <obj> <prop> <value>` | Write a value to a property. |
| `writecsv` | `writecsv <csv_path>` | Write BACnet properties from a CSV file. |
| `whereconfig` | `whereconfig` | Show the config and log file directory. |
| `help` | `help <command>` | Show command list or details for one command. |
| `clear` | `clear` | Clear the output log. |

> [!TIP]
> Append `?` to any command name (e.g. `writecsv?`) to see its detailed help.

### `writeproperty` example

```
writeproperty 123456 AV1 Present_Value 72.5
```

This writes `72.5` to `Present_Value` on Analog Value instance 1 of device 123456.

### CSV batch writes

The `writecsv` command reads a CSV file with the following columns:

| Column | Required | Description |
| ------ | -------- | ----------- |
| `device` | Yes | Device identifier (e.g. `123456`) |
| `object_type` | Yes | BACnet object type (e.g. `AI`, `AO`, `AV`) |
| `instance` | Yes | Instance number of the object |
| `property_name` | Yes | Property to write (e.g. `Present_Value`) |
| `property_value` | Yes | Value to write |
| `site_name` | No | Overrides the currently selected site |

## Keyboard Shortcuts

| Key | Action |
| --- | ------ |
| `↑` / `↓` | Navigate command history |
| `Escape` | Clear current input |
| `Ctrl+C` | Quit the application |

## Configuration

Credentials and settings are stored as JSON in the platform config directory:

- **Windows:** `%LOCALAPPDATA%/enteliscript/config.json`
- **macOS:** `~/Library/Application Support/enteliscript/config.json`
- **Linux:** `~/.config/enteliscript/config.json`

Log files are written to the platform log directory:

- **Windows:** `%LOCALAPPDATA%/enteliscript/Logs/enteliscript.log`
- **macOS:** `~/Library/Logs/enteliscript/enteliscript.log`
- **Linux:** `~/.local/state/enteliscript/log/enteliscript.log`

Run `whereconfig` inside the TUI to see the exact paths on your system.

## Requirements

- Python 3.10+
- An accessible enteliWEB server

## License

[MIT](LICENSE)
