Green Button, JavaScript and PHP
Outline
-
About me
-
What's Green Button?
-
How to implement this standard in PHP and JavaScript?
-
Green Button libraries Introduction
About me
-
Peter
-
Active open source contributor
-
An software engineer
-
DevOps
-
Back-end
-
-
3+ years for PHP development
-
PHP 5.3 → PHP 7+
-
No framework→Slim→Laravel
-
Working for ITRI currently
-
Smart Grid technology
What's Green Button?
- It is an industry-led effort that responds to a 2012 White House call-to-action to provide utility customers.
- A easy and secure access to their energy usage information in a consumer-friendly and computer-friendly format
- electricity
- natural gas
- water usage
- Using atom+xml based
- Atom Feed
How to implement this standard in PHP and JavaScript?
It's hard.
But don't be worried.
npm i green-button-data-converter
var DataWriter = require('green-button-data-converter').DataWriter
var options = {
'interval_duration': 86400,
'time_period_duration': 3600,
'start_date': '2019-07-18 17:00:00',
'interval_readings': [
{date: '1563440400', mwh: 912},
],
'power_of_ten_multiplier': 0,
'uom': 72,
}
var dataWriter = new DataWriter(options)
console.log(dataWriter.output(true))
<?php
use Carbon\Carbon;
use Lee\Green\Button\CustomerDataWriter;
$carbon = Carbon::now(self::$timezone);
$dateTimeString = $carbon->format('Y-m-d\TH:i:s\Z');
$options = [
'title' => 'Green Button Customer Feed',
'account_id' => 'Peter',
'meter_form_number' => 'TD17234599',
'end_device_serial_number' => '99123456',
];
$customerDataWriter = new CustomerDataWriter($options);
$customerDataWriter->setPublishedDateTime($dateTimeString);
$customerDataWriter->setUpdatedDateTime($dateTimeString);
$result = $customerDataWriter->createCustomerAccountData();
composer require lee/php-green-button
TODO
Energy Usage Point Generator
References
-
Green Button References
- http://dmdvalidator.greenbuttonalliance.org
- http://dev.greenbuttonalliance.org/library.html
- https://green-button.github.io/build
-
Libraries
-
https://github.com/peter279k/green-button-converter
-
https://github.com/peter279k/php-green-button
-
Thanks!
Green Button, PHP and JavaScript
By peter279k
Green Button, PHP and JavaScript
Nomad PHP
- 1,175