Skip to content

About

A cloud integration to IEC

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

39 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

# IEC Meter Application

This repository contains the IEC Meter Application and Driver, designed for authenticating and managing IEC meters using the Hubitat platform.

## Features

- Authenticate with IEC Okta
- Manage IEC meter data
- Fetch electricity **consumption (import)** and **export (backstream)**
- Fetch billing details
- Schedule automatic updates for consumption and billing data
- Optional posting of consumption and export data to **InfluxDB v2**
- Backward compatible with existing InfluxDB history (no data loss)

## Installation

### 1. Add the App Code to Hubitat

1. Open your Hubitat web interface
2. Navigate to **Apps Code**
3. Click **+ New App**
4. Copy the entire content of `IEC_Meter_Application.groovy`
5. Paste the code into the Hubitat app editor
6. Click **Save**

### 2. Add the Driver Code to Hubitat

1. Navigate to **Drivers Code**
2. Click **+ New Driver**
3. Copy the entire content of `IEC_Meter_Driver.groovy`
4. Paste the code into the Hubitat driver editor
5. Click **Save**

## Configuration

> **Important**  
> It is highly recommended to keep a **Logs** window open during the setup process.

### 1. Install the App

1. Navigate to **Apps**
2. Click **Add User App**
3. Select **IEC Meter Application**

### 2. Set Up the App

#### 2.1 Initiate Authentication

- Enter **User ID** (same user used on the IEC website)
- Click **Initiate Authentication**
- An OTP code will be sent via SMS

#### 2.2 Verify OTP

- Enter the OTP code
- Click **Verify OTP Code**

#### 2.3 Authorize Session

- Click **Authorize Session**

#### 2.4 Get Access Token

- Click **Get Access Token**

#### 2.5 Create or Update Device

- Click **Create or Update Device**
- A device using the **IEC Meter Driver** will be created or updated

#### 2.6 Get BP Number

- Click **Get BP Number**

#### 2.7 Get Contracts

- Click **Get Contracts**

#### 2.8 Get Devices

- Click **Get Devices**

#### 2.9 Logging and Scheduling

- **Enable Debug Logging** (optional)

**Update Consumption Interval (minutes)**  
Controls updates for:
- Today
- Yesterday
- Two Days Ago
- This Month  
(Default: 60 minutes)

**Update Bill Interval (hours)**  
Controls electric bill refresh  
(Default: 24 hours)

#### 2.10 InfluxDB Logging (Optional)

- Posts both **consumption** and **export**
- Uses a single measurement: `IEC_Meter`
- Keeps existing `value` field for consumption
- Adds `export` field for backstream
- Does **not** modify historical data

**InfluxDB Settings**

- InfluxDB Host
- InfluxDB Port (usually 8086)
- InfluxDB Org
- InfluxDB Bucket
- InfluxDB Token

#### 2.11 Save Configuration

- Click **Done**

## Checks

After installation:

1. Open the IEC Meter Application
2. Click the **gear icon**
3. Verify scheduled jobs:
   - `updateTwoDaysAgoConsumption`
   - `updateYesterdayConsumption`
   - `updateTodayConsumption`
   - `updateThisMonthConsumption`
   - `getElectricBill`
   - `refreshToken`

## Usage

The app automatically updates:

- Two Days Ago Consumption & Export
- Yesterday Consumption & Export
- Today Consumption & Export
- This Month Consumption & Export
- Electric Bill Data
- OAuth Token Refresh (every 45 minutes)

All values are available for:
- Dashboards
- Rule Machine
- InfluxDB
- Grafana

## License

Licensed under the Apache License, Version 2.0.  
See the LICENSE file for details.

## Support

For issues or questions, please open an issue in the GitHub repository.

About

A cloud integration to IEC

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors