Skip to content

Commit 5d38bfc

Browse files
Merge pull request robertogallea#20 from pimhofman/savingsreport
Get energy savings report
2 parents fae2b29 + 0c58f0d commit 5d38bfc

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ Currently these methods are supported:
125125
- isAnyoneAtHome($access_token);
126126
- getPresenceLock($access_token);
127127
- setPresenceLock($access_token, $settings);
128+
- getEnergySavingsReport($access_token, $year, $month, $country_code);
128129
- deleteEnergyIQMeterReading($access_token, $reading_id);
129130
- addEnergyIQMeterReading($access_token, $settings);
130131
- updateEnergyIQTariff($access_token, $settings);
@@ -133,6 +134,9 @@ Currently these methods are supported:
133134
- getEnergyIQ($access_token);
134135
- getAppUsersRelativePositions($token)
135136

137+
# Country code format for getEnergySavingsReport
138+
To request an energy savings report via getEnergySavingsReport, you're required to pass a three-letter country code in accordance with [ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3)
139+
136140
## 6. Issues, Questions and Pull Requests
137141

138142
You can report issues and ask questions in the [issues section](https://github.com/robertogallea/restado/issues). Please start your issue with `ISSUE: ` and your question with `QUESTION: `

src/Restado.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,27 @@ public function deleteEnergyIQMeterReading($access_token, $reading_id) {
896896
return json_decode($response->getBody());
897897
}
898898

899+
/**
900+
* @param $access_token
901+
* @param $year
902+
* @param $month
903+
* @param $country_code
904+
* @return mixed
905+
*/
906+
public function getEnergySavingsReport($access_token, $year, $month, $country_code) {
907+
$provider = $this->getProvider();
908+
$home_id = $this->getHomeId();
909+
910+
$request = $provider->getAuthenticatedRequest(
911+
'GET',
912+
'https://energy-bob.tado.com/' . $home_id . '/' . $year . '-' . $month . '?country=' . $country_code,
913+
$access_token
914+
);
915+
$client = new \GuzzleHttp\Client();
916+
$response = $client->send($request);
917+
return json_decode($response->getBody());
918+
}
919+
899920
/**
900921
* @return GenericProvider
901922
*/

0 commit comments

Comments
 (0)