Metadata-Version: 2.1
Name: pymea
Version: 0.4.5
Summary: Python bindings for nymea JSONRPC
Author: Leonhard Heizinger
Author-email: l.heizinger@consolinno.de
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE

# pymea

`pymea` is a Python library that provides a convenient interface for interacting with
Nymea. It uses the TCP protocol to communicate with the Nymea server.

## Installation

You can install `pymea` using `apt`. Open a terminal and run:

```bash
apt install python3-pymea
```

You can also install it directly from source to a leaflet, for which you have access
via ssh, for development purposes:

```bash
./dev_scripts/upload.sh root@1u0022-co-1234.local
```

## Configuration (no authentication)

To use `pymea` without authentication, follow these steps:

1. Open the Nymea configuration file `/etc/nymea/nymea.conf`

2. Locate the `[TcpServer]` section in the configuration file.

3. Set the `default\authenticationEnabled` parameter to `false`.

   ```ini
   [TcpServer]
   default\authenticationEnabled=false
   ```

## Tests

```bash
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -r requirements.txt --break-system-packages
python3 -m pip install -e .
python3 -m pytest src/pymea/tests
```

## Usage

### `NymeaClient(hostname, username, password, port)`

Creates a new `NymeaClient` instance connected to the specified `hostname`.
Optionally, you can provide a `username`, `password`, and `port` for authentication
and port configuration.

#### Parameters
- `hostname` (str): The hostname or IP address of the Nymea server.
- `username` (str, optional): The username for authentication.
- `password` (str, optional): The password for authentication.
- `port` (int, optional): The port number for the Nymea server.

#### Example

```python
import pymea

# Replace these variables with your actual values
host = "localhost"
user = "your_username"
password = "your_password"
port = 1234  

# Create a Nymea client instance with authentication
nycli = pymea.NymeaClient(
    host,
    user=user,
    password=password,
    port=port,
)

# Example: handshake with the Nymea server
nycli.handshake()

# Example: Get a list of things, states and their values
things_response = nycli.get_things()
```
