|
4 | 4 | from __future__ import absolute_import |
5 | 5 |
|
6 | 6 | from reposit.data.api import ApiRequest |
7 | | -from reposit.data.utils import api_response, device_summary |
8 | 7 |
|
9 | 8 |
|
10 | 9 | class Controller(object): |
@@ -39,147 +38,167 @@ def battery_min_state_of_charge(self): |
39 | 38 | Return the minimum state of charge of the battery |
40 | 39 | :return: |
41 | 40 | """ |
42 | | - return api_response( |
43 | | - url='https://{}/v2/deployments/{}/battery/min_soc', |
| 41 | + request = ApiRequest( |
| 42 | + path='v2/deployments/{}/battery/min_soc'.format(self.user_key), |
44 | 43 | controller=self, |
45 | | - field='min_soc' |
| 44 | + schema={'min_soc': {}} |
46 | 45 | ) |
47 | 46 |
|
| 47 | + return request.get() |
| 48 | + |
48 | 49 | @property |
49 | 50 | def has_battery(self): |
50 | 51 | """ |
51 | 52 | If the system has a battery installed |
52 | 53 | :return: |
53 | 54 | """ |
54 | | - return api_response( |
55 | | - url='https://{}/v2/deployments/{}/components', |
| 55 | + request = ApiRequest( |
| 56 | + path='v2/deployments/{}/components'.format(self.user_key), |
56 | 57 | controller=self, |
57 | | - field='data', |
58 | | - subfield='battery', |
| 58 | + schema={ |
| 59 | + 'data': { |
| 60 | + 'battery': {} |
| 61 | + } |
| 62 | + } |
59 | 63 | ) |
| 64 | + return request.get() |
60 | 65 |
|
61 | 66 | @property |
62 | 67 | def has_inverter(self): |
63 | 68 | """ |
64 | 69 | If the system has an inverter installed |
65 | 70 | :return: |
66 | 71 | """ |
67 | | - return api_response( |
68 | | - url='https://{}/v2/deployments/{}/components', |
| 72 | + request = ApiRequest( |
| 73 | + path='v2/deployments/{}/components'.format(self.user_key), |
69 | 74 | controller=self, |
70 | | - field='data', |
71 | | - subfield='inverter', |
| 75 | + schema={ |
| 76 | + 'data': { |
| 77 | + 'inverter': {} |
| 78 | + } |
| 79 | + } |
72 | 80 | ) |
| 81 | + return request.get() |
73 | 82 |
|
74 | 83 | @property |
75 | 84 | def latest_historical_generation(self): |
76 | 85 | """ |
77 | 86 | Return a list of data points as lists. Time are in GMT |
78 | 87 | :return: |
79 | 88 | """ |
80 | | - |
81 | | - return api_response( |
82 | | - url='https://{}/v2/deployments/{}/generation/historical/p', |
| 89 | + request = ApiRequest( |
| 90 | + path='v2/deployments/{}/generation/historical/p'.format(self.user_key), |
83 | 91 | controller=self, |
84 | | - field='solarP', |
85 | | - format_list=True |
| 92 | + schema={ |
| 93 | + 'solarP': {} |
| 94 | + } |
86 | 95 | ) |
| 96 | + return request.get() |
87 | 97 |
|
88 | 98 | @property |
89 | 99 | def latest_historical_house(self): |
90 | 100 | """ |
91 | 101 | Return a list of data points as lists. Time are in GMT |
92 | 102 | :return: |
93 | 103 | """ |
94 | | - |
95 | | - return api_response( |
96 | | - url='https://{}/v2/deployments/{}/house/historical', |
| 104 | + request = ApiRequest( |
| 105 | + path='v2/deployments/{}/house/historical'.format(self.user_key), |
97 | 106 | controller=self, |
98 | | - field='data', |
99 | | - subfield='houseP', |
100 | | - format_list=True |
| 107 | + schema={ |
| 108 | + 'data': { |
| 109 | + 'houseP': {} |
| 110 | + } |
| 111 | + } |
101 | 112 | ) |
| 113 | + return request.get() |
102 | 114 |
|
103 | 115 | @property |
104 | 116 | def latest_historical_grid_credits(self): |
105 | 117 | """ |
106 | 118 | Return a list of data points as lists. Times are in GMT |
107 | 119 | :return: |
108 | 120 | """ |
109 | | - return api_response( |
110 | | - url='https://{}/v2/deployments/{}/gridcredits/historical', |
| 121 | + |
| 122 | + request = ApiRequest( |
| 123 | + path='v2/deployments/{}/gridcredits/historical'.format(self.user_key), |
111 | 124 | controller=self, |
112 | | - field='gridcredits', |
113 | | - format_list=True |
| 125 | + schema={ |
| 126 | + 'gridcredits': {} |
| 127 | + } |
114 | 128 | ) |
| 129 | + return request.get() |
115 | 130 |
|
116 | 131 | @property |
117 | 132 | def latest_historical_inverter(self): |
118 | 133 | """ |
119 | 134 | Return a list of data points as lists. Times are in GMT |
120 | 135 | :return: |
121 | 136 | """ |
122 | | - return api_response( |
123 | | - url='https://{}/v2/deployments/{}/inverter/historical/p', |
| 137 | + request = ApiRequest( |
| 138 | + path='v2/deployments/{}/inverter/historical/p'.format(self.user_key), |
124 | 139 | controller=self, |
125 | | - field='inverterP', |
126 | | - format_list=True |
| 140 | + schema={ |
| 141 | + 'inverterP': {} |
| 142 | + } |
127 | 143 | ) |
| 144 | + return request.get() |
128 | 145 |
|
129 | 146 | @property |
130 | 147 | def latest_historical_meter(self): |
131 | 148 | """ |
132 | 149 | Return a list of data points as lists. Times are in GMT |
133 | 150 | :return: |
134 | 151 | """ |
135 | | - return api_response( |
136 | | - url='https://{}/v2/deployments/{}/meter/historical/p', |
| 152 | + request = ApiRequest( |
| 153 | + path='v2/deployments/{}/meter/historical/p'.format(self.user_key), |
137 | 154 | controller=self, |
138 | | - field='meterP', |
139 | | - format_list=True |
| 155 | + schema={ |
| 156 | + 'meterP': {} |
| 157 | + } |
140 | 158 | ) |
141 | | - |
| 159 | + return request.get() |
142 | 160 |
|
143 | 161 | @property |
144 | 162 | def weekday_tou_tariff(self): |
145 | 163 | """ |
146 | 164 | Returns a list of dicts of weekday time of use tariff information |
147 | 165 | :return: |
148 | 166 | """ |
149 | | - return api_response( |
150 | | - url='https://{}/v2/deployments/{}/tariff/tou', |
| 167 | + request = ApiRequest( |
| 168 | + path='v2/deployments/{}/tariff/tou'.format(self.user_key), |
151 | 169 | controller=self, |
152 | | - field='weekday' |
| 170 | + schema={ |
| 171 | + 'weekday': {} |
| 172 | + } |
153 | 173 | ) |
| 174 | + return request.get() |
154 | 175 |
|
155 | 176 | @property |
156 | 177 | def weekend_tou_tariff(self): |
157 | 178 | """ |
158 | 179 | Returns a list of dicts of weekend time of use tariff information |
159 | 180 | :return: |
160 | 181 | """ |
161 | | - return api_response( |
162 | | - url='https://{}/v2/deployments/{}/tariff/tou', |
| 182 | + request = ApiRequest( |
| 183 | + path='v2/deployments/{}/tariff/tou'.format(self.user_key), |
163 | 184 | controller=self, |
164 | | - field='weekend' |
| 185 | + schema={ |
| 186 | + 'weekend': {} |
| 187 | + } |
165 | 188 | ) |
| 189 | + return request.get() |
166 | 190 |
|
167 | 191 | @property |
168 | 192 | def feed_in_tariff(self): |
169 | 193 | """ |
170 | 194 | The feed in tariff cost as a float |
171 | 195 | :return: |
172 | 196 | """ |
173 | | - return api_response( |
174 | | - url='https://{}/v2/deployments/{}/tariff/tou', |
| 197 | + request = ApiRequest( |
| 198 | + path='v2/deployments/{}/tariff/tou'.format(self.user_key), |
175 | 199 | controller=self, |
176 | | - field='fit' |
| 200 | + schema={ |
| 201 | + 'fit': {} |
| 202 | + } |
177 | 203 | ) |
178 | | - |
179 | | - @property |
180 | | - def summary(self): |
181 | | - """ |
182 | | - Return current system information as a dict |
183 | | - :return: |
184 | | - """ |
185 | | - return device_summary(self) |
| 204 | + return request.get() |
0 commit comments