use Exception;
use Inexogy\API1 as InexogyAPI;
try {
$api = new InexogyAPI(
// Required parameters
$client, // Your own application identifier
$identifier, // Login for the Inexogy portal, mostly your email address
$secret
);
// Use cache, system temp dir.
$api->setCache(true);
// Use your own cache dir.
$api->setCache('/path/to/your/cache/dir');
// If cache is used, default TTL is 1 day
// Cache for 1 hour
$api->setTTL(3600);
// Authorize
$api->init();
} catch (Exception $e) {
die($e->getMessage());
}The API class authorizes at the API and tries up to 5 times in case of an error.
With the $api instance you can now query the data.
At the moment the GET endpoints are implemented (via __call()):
/devices/field_names
/readings/last_reading/statistics/load_profile/raw_load_profile
/disaggregation/activities
/website_access_code
/virtual_meters
Naming convention is: endpoint /snake_case must be called as getCamelCase().
getMeters() is separate, with lazy load and caching in file.
All methods expect the same required (and optional) paramters as described in the API docs.
So the call have to be
$last_reading = $api->getMeter('YOUR-METER-ID')->getLastReading();With optional paramters a call would be
For example the endpoint /readings expect a resolution.
$readings = $api->getMeter('YOUR-METER-ID')->getReadings([ 'resolution' => $resolution, 'from' => $from ]);