Skip to content

Commit

Permalink
Params for SCDevice and postprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
oscgonfer committed Apr 30, 2024
1 parent 78d4d25 commit ead5614
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions smartcitizen_connector/device/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,14 @@ def check_postprocessing(postprocessing):

class SCDevice:

def __init__(self, id, check_postprocessing=True):
self.id = id
def __init__(self, id = None, params = None, check_postprocessing=True):
if id is not None:
self.id = id
elif params is not None:
self.id = params.id
else:
raise ValueError("Need at least id or params.id")
self.params = params
self.url = f'{config.DEVICES_URL}{self.id}'
self.page = f'{config.FRONTEND_URL}{self.id}'
self.method = 'async'
Expand Down Expand Up @@ -573,10 +579,13 @@ def postprocessing(self):

@property
def latest_postprocessing(self):
return self.json.postprocessing.latest_postprocessing
if self.json.postprocessing is not None:
return self.json.postprocessing.latest_postprocessing
else:
return None

def update_latest_postprocessing(self, date):
if self.json.postprocessing.id is not None:
if self.json.postprocessing is not None:
# Add latest postprocessing rounded up with
# frequency so that we don't end up in
# and endless loop processing only the latest data line
Expand Down

0 comments on commit ead5614

Please sign in to comment.