Installation Guide
This guide covers the installation process for the Energy Manager IoT library and all required dependencies.
Library Installation
Install the library using npm:
Or using yarn:
Dependencies
Energy Manager IoT has the following direct dependencies:
- mqtt: For MQTT communication
- winston: For advanced logging capabilities
These will be installed automatically when you install the library.
MQTT Broker Setup
The Energy Manager IoT library requires an MQTT broker to function. Here are instructions for setting up the most common brokers:
Installing Mosquitto (Recommended for Development)
Mosquitto is a lightweight MQTT broker that works well for both development and production.
- Download the installer from https://mosquitto.org/download/
- Follow the installer instructions
- Add Mosquitto to your system PATH if the installer doesn't do it automatically
- Start the broker by opening a command prompt and running:
Basic Mosquitto Configuration
The default configuration works for testing, but for production, you should secure your MQTT broker.
Create or edit the mosquitto.conf
file (location depends on your OS):
# Basic listener configuration
listener 1883
protocol mqtt
# Enable persistent sessions
persistence true
persistence_location /var/lib/mosquitto/
# Logging
log_dest file /var/log/mosquitto/mosquitto.log
log_type all
TypeScript Configuration
If you're using TypeScript, the library includes type definitions. Ensure your tsconfig.json
includes:
{
"compilerOptions": {
"target": "ES2018",
"module": "CommonJS",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
Verification
To verify your installation, create a simple test file:
// test.ts
import { EnergyManager } from 'energy-manager-iot';
async function test() {
const manager = new EnergyManager();
console.log('Energy Manager IoT library installed successfully!');
console.log('Version:', manager.VERSION);
}
test();
Run it using:
If you see the success message, your installation is complete!
Next Steps
Now that you've installed Energy Manager IoT, proceed to the Quick Start Guide to learn how to use the library.