Metadata-Version: 2.4
Name: simt-emlite
Version: 1.2.10
Summary: API and CLI for communicating with the Emlite meters via EMOP
Author-email: Chris Hatch <chris@simtricity.com>
Requires-Python: <4.0,>=3.13
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: grpcio<2.0.0,>=1.76.0
Requires-Dist: tenacity==9.1.2
Requires-Dist: supabase==2.27.1
Requires-Dist: crcmod==1.7
Requires-Dist: structlog==25.5.0
Requires-Dist: docker==7.1.0
Requires-Dist: protobuf==6.33.3
Requires-Dist: python-dotenv==1.2.1
Requires-Dist: python-socks==2.8.0
Requires-Dist: rich==14.2.0
Requires-Dist: dnspython==2.8.0
Requires-Dist: httpx==0.28.1
Requires-Dist: argcomplete>=3.4.0
Requires-Dist: types-requests==2.32.4.20260107
Requires-Dist: emop-frame-protocol==0.4.14
Requires-Dist: simt-fly-machines==0.2.6
Requires-Dist: javaproperties<0.9.0,>=0.8.2
Requires-Dist: types-grpcio<2.0.0.0,>=1.0.0.20251009
Dynamic: license-file

# Simtricity Emlite Python APIs and CLI

This repository contains:

- API to connect to and send EMOP messages to Emlite meters
- a CLI (emop) for sending messages to the meters

## Configure

Configuration steps:

- create file ~/.simt/emlite.prod.env from Lastpass secret 'emop-cli-env-file (prod)'
- create file ~/.simt/emlite.qa.env from Lastpass secret 'emop-cli-env-file (qa)'
- ln -s ~/.simt/emlite.<qa|prod|custom>.env ~/.simt/emlite.env

NOTE:

- FLY_DNS_SERVER needs the DNS that wireguard uses (on Linux look under `resolvectl status` for the interface and DNS)

see also <https://www.notion.so/Emop-and-mediators-CLI-setup-834d32be5c794add8716399ab186abe8>

## Use

### emop

```sh
emop env_show
emop env_set prod

emop --help

emop prepay_balance EML2137555666
emop csq EML2137555666
emop profile_log_1 --timestamp 2024-07-19T00:00 EML2137555666
```

### Python API

You can also use the library directly in your Python scripts. The library offers two main client classes:

- `EmliteMediatorAPI`: The core client for standard meter operations (reads, basic writes).
- `EmlitePrepayAPI`: Extends the core API with prepay-specific functionality (balance, tokens, tariffs).

#### Initialization and Logging

The `EmliteMediatorAPI` constructor allows you to configure the connection and log verbosity.

```python
import logging
from simt_emlite.mediator.api_core import EmliteMediatorAPI

# Initialize the client
# The logging_level parameter controls the verbosity of the internal logger.
# It uses the standard python logging module levels (DEBUG, INFO, WARNING, ERROR).
client = EmliteMediatorAPI(
    mediator_address="localhost:50051",
    logging_level=logging.WARNING  # Set to logging.DEBUG for verbose output
)

# Example Usage
serial = "EML2137555666"
try:
    voltage = client.instantaneous_voltage(serial)
    print(f"Meter {serial} voltage: {voltage}V")
except Exception as e:
    print(f"Error: {e}")
```
