# API and Integration Notes

## IAMMETER
Application scripts:
- `application/v1/sync_from_cloud.php`
- `application/v1/kva.php`
- equivalent copies also exist in V2

The scripts read configured smart meters from the standalone RBE database and request meter data from IAMMETER's cloud API.

Credential/configuration:
- `RBE_IAMMETER_TOKEN`

The live token from the former environment is not included. RBE must configure a valid token/account for any IAMMETER meters it intends to continue operating.

Data written includes:
- `smart_meter_readings`
- `smart_meter_readings_kva`

## Flecto electric / TL300
Application script:
- `application/v1/cron/flecto_electric_sync.php`
- corresponding V2 copy under `application/v2/cron/`

Configured API base:
- `RBE_FLECTO_ELECTRIC_API_URL`

Default URL currently represented by the source configuration:
- `https://api.flecto.xyz/flecto_tl_v1.6.php`

The electric sync reads the latest bearer token from the RBE database table:
- `flecto_tokens`

RBE must obtain/manage the token required for its new environment. No MY.TOWN live private Flecto token is supplied.

Data written:
- `flecto_meter_readings`

A Flecto TL300 API document supplied with the V2 source is retained at:
- `application/v2/TL300 Flecto Sense Rest API V1.6 Doc v1.6.pdf`

## Flecto water
Application script:
- `application/v1/cron/water_meter_sync.php`
- corresponding V2 copy under `application/v2/cron/`

Configured API base:
- `RBE_FLECTO_WATER_API_URL`

Configured bearer placeholder:
- `RBE_FLECTO_WATER_TOKEN`

Data written:
- `water_meter_readings`

RBE must obtain/configure its own valid Flecto water credentials/token where required.

## SMTP/email
Email functionality uses PHPMailer in relevant codepaths.

Configuration variables:
- `RBE_SMTP_HOST`
- `RBE_SMTP_PORT`
- `RBE_SMTP_USER`
- `RBE_SMTP_PASS`
- `RBE_MAIL_FROM`
- `RBE_MAIL_FROM_NAME`

No former live SMTP password is included.

## MQTT
Both applications contain `mqtt_listener.js` and npm manifests with the `mqtt` package dependency. The MQTT listener is retained because it may be relevant to the operating/metering environment, but RBE's developer must confirm whether it is required in the destination setup before enabling it.

### MQTT credential configuration
The retained MQTT listener uses environment variables only for private account credentials:
- `RBE_MQTT_HOST`
- `RBE_MQTT_USERNAME`
- `RBE_MQTT_PASSWORD`
- `RBE_MQTT_CLIENT_ID`

No former live MQTT username/password is included in the handover candidate.
