-
Notifications
You must be signed in to change notification settings - Fork 2
Add element create #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cf1daea
9765230
95f8d7c
bafa6df
206ed22
4ec7c28
faca64e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -256,7 +256,7 @@ def create_organization(self, org_name: str, allow_exist: bool = False) -> dict: | |
| org = self.client.post(endpoint="organizations", json=payload) | ||
| return org | ||
|
|
||
| def get_buildings(self) -> list[dict]: | ||
| def get_buildings(self, filters: dict = {}) -> list[dict]: | ||
| total_qry = self.client.list(endpoint="properties", data_name="pagination", per_page=100) | ||
|
|
||
| # step through each page of the results | ||
|
|
@@ -268,6 +268,7 @@ def get_buildings(self) -> list[dict]: | |
| per_page=100, | ||
| page=i, | ||
| cycle=self.cycle_id, | ||
| **filters, | ||
|
Comment on lines
260
to
+271
|
||
| ) | ||
| # print(f"number of buildings retrieved: {len(buildings)}") | ||
|
|
||
|
|
@@ -1335,7 +1336,14 @@ def get_meter(self, property_view_id: int, meter_type: str, source: str, source_ | |
| return meter | ||
| return None | ||
|
|
||
| def get_or_create_meter(self, property_view_id: int, meter_type: str, source: str, source_id: str) -> Optional[dict[Any, Any]]: | ||
| def get_or_create_meter( | ||
| self, | ||
| property_view_id: int, | ||
| meter_type: str, | ||
| source: str, | ||
| source_id: str, | ||
| connection_type="Imported", | ||
| ) -> Optional[dict[Any, Any]]: | ||
|
Comment on lines
+1339
to
+1346
|
||
| """get or create a meter for a property view. | ||
|
|
||
| Args: | ||
|
|
@@ -1357,6 +1365,7 @@ def get_or_create_meter(self, property_view_id: int, meter_type: str, source: st | |
| "type": meter_type, | ||
| "source": source, | ||
| "source_id": source_id, | ||
| "connection_type": connection_type, | ||
| } | ||
|
|
||
| meter = self.client.post(endpoint="properties_meters", url_args={"PK": property_view_id}, json=payload) | ||
|
|
@@ -1394,6 +1403,24 @@ def upsert_meter_readings_bulk(self, property_view_id: int, meter_id: int, data: | |
| ) | ||
| return readings | ||
|
|
||
| def create_element(self, property_id: int, data: dict[Any, Any]) -> dict: | ||
| """Upsert an element for a property. | ||
|
|
||
| Args: | ||
| property_id (int): property id | ||
| data (dict[Any, Any]): dictionary of element data | ||
|
|
||
| Returns: | ||
| dict: element object | ||
| """ | ||
| # get the element data for the property | ||
| element = self.client.post( | ||
| endpoint="properties_elements", | ||
| url_args={"PK": property_id}, | ||
| json=data, | ||
| ) | ||
| return element | ||
|
|
||
| def get_meter_data(self, property_id, interval: str = "Exact", excluded_meter_ids: list = []): | ||
| """Return the meter data from the property. | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_buildingsuses a mutable default argument (filters: dict = {}), which can leak state across calls if the dict is mutated. Usefilters: Optional[dict] = Noneand setfilters = filters or {}inside the method.