Skip to content
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

Fix meter import and Add property filtering #57

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pyseed/seed_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def create_organization(self, org_name: str) -> dict:
org = self.client.post(endpoint="organizations", json=payload)
return org

def get_buildings(self) -> list[dict]:
def get_buildings(self, filters: Optional[dict] = {}) -> list[dict]:
total_qry = self.client.list(endpoint="properties", data_name="pagination", per_page=100)

# step through each page of the results
Expand All @@ -259,6 +259,7 @@ def get_buildings(self) -> list[dict]:
per_page=100,
page=i,
cycle=self.cycle_id,
**filters,
)
# print(f"number of buildings retrieved: {len(buildings)}")

Expand Down Expand Up @@ -1117,7 +1118,7 @@ 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]]:
"""get or create a meter for a property view.

Args:
Expand All @@ -1139,6 +1140,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)
Expand Down
Loading