mireiawen/lumme-energia

This library helps fetching the electricity usage data from Lumme-Energia

0.2.1 2022-05-22 23:50 UTC

This package is auto-updated.

Last update: 2024-04-23 04:07:14 UTC


README

This library helps fetching the energy consumption from the Lumme Energia consumption data.

The process of login and data fetching has been reverse-engineered by reading the traffic between the browser and the server, and as such the code may or may not work for specific case, and the login and data fetching may change at any time without warning, making this code to not work.

Requirements

  • PHP 8.1
  • cURL
  • JSON
  • Gettext

Installation

composer require "mireiawen/lumme-energia"

Simple example

<?php
// Username and password to access Oma Lumme
$username = 'root@localhost';
$password = 'REALLY_SECRET_PASSWORT!';

// Usage location number (Käyttöpaikkanumero), available at Oma Lumme
$location = '12334567890';

// Create time zone
$tz = new \DateTimeZone('Europe/Helsinki');

// Create the start and end times, get last 6 days of data
$start = new \DateTime('now', $tz);
$start->modify('- 6 days');
$end = new \DateTime('now', $tz);
	
// Create the instance
$lumme = new Lumme();

// Log in
// The method returns the token if you wish to use it elsewhere
$lumme->Login($username, $password);

// Fetch the usage data
$usage = $lumme->FetchUsage($loc, $start, $end);

// The data is array of Usage objects
// Usage has following methods: GetFrom(), GetTo(), GetValue()
var_dump($usage);