Skip to content

API Reference

Welcome to the Energy Manager IoT API reference documentation. This section provides detailed information about the classes, methods, and interfaces available in the library.

Core Classes

The Energy Manager IoT library is organized around these main classes:

Types and Interfaces

The library includes several TypeScript interfaces and types:

API Overview Diagram

API Overview Diagram

API Overview Diagram

The diagram shows the relationships between core components (EnergyManager, DeviceRegistry, MqttHandler) and how they interact with types and external systems.

Usage Example

Here's a simple example showing how the main classes interact:

import {
  EnergyManager,
  DeviceType,
  CommandType
} from 'energy-manager-iot';

// Create the main manager
const manager = new EnergyManager();

// Connect to MQTT broker
await manager.connect('mqtt://localhost:1883');

// Register a device
manager.registerDevice('sensor1', 'Temperature Sensor', DeviceType.SENSOR);

// Send a command
await manager.sendCommand('sensor1', CommandType.SET_REPORTING, { interval: 60 });

// Listen for events
manager.on('statusUpdate', (deviceId, status) => {
  console.log(`Status update from ${deviceId}:`, status);
});

Explore the documentation for each class to learn more about the available methods and properties.