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

GSYE-803: Add set_live_generation to RestAssetClient #244

Merged
merged 1 commit into from
Oct 30, 2024
Merged
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
10 changes: 10 additions & 0 deletions gsy_e_sdk/clients/rest_asset_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ def set_energy_forecast(self, energy_forecast_kWh: Dict, do_not_wait=False):

return None

@logging_decorator("set-live-generation")
def set_live_generation(self, live_data: Dict, do_not_wait=False):
"""Send live generation data to gsy-web."""
transaction_id, posted = self._post_request(f"{self.endpoint_prefix}/set-live-generation",
{"live_data": live_data})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the endpoint only accept config_uuid and area_uuid as per
set_live_generation(request, config_uuid, area_uuid):
What is the relationship between live_data and these?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not study informatics, so my following explanation might not use the correct nomenclature, but let me try to explain anyway:
There are two streams for data in a REST API: The parameters and the body. The parameters are put in the URL of the request and any additional data can be put in the body.
So for this specific API endpoint a valid URL looks like:

http://localhost:8000/external-connection/api/cc3251d1-320e-4158-818f-e2e49b2bfc04/d1013b2f-bc07-403b-b61e-5f593cb0e749/set-live-generation/

That contains the config_uuid and the area_uuid. The actual data is sent in the body, that is represented by the request.data in the endpoint implementation here:
https://github.com/gridsingularity/gsy-web/pull/2198/files#diff-50bbb55953ee93d276958a5a67f62263471aba048061dfedd78ef488f513988aR92

The additional data is a dictionary that looks like:

{"live_data":"20240101T00:00"}

if posted and do_not_wait is False:
return self.dispatcher.wait_for_command_response("set-live-generation", transaction_id)

return None

# pylint: disable=invalid-name
@logging_decorator("set-energy-measurement")
def set_energy_measurement(self, energy_measurement_kWh: Dict, do_not_wait=False):
Expand Down
Loading