mireiawen/lumme-energia

此库帮助从Lumme-Energia获取电力使用数据

0.2.1 2022-05-22 23:50 UTC

This package is auto-updated.

Last update: 2024-09-23 04:56:02 UTC


README

此库帮助从Lumme Energia能耗数据中获取能源消耗。

登录和数据获取的过程已经通过读取浏览器和服务器之间的流量进行逆向工程,因此代码可能或可能无法针对特定情况工作,并且登录和数据获取可能会在没有任何警告的情况下随时更改,这使得代码可能无法正常工作。

要求

  • PHP 8.1
  • cURL
  • JSON
  • Gettext

安装

composer require "mireiawen/lumme-energia"

简单示例

<?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);