From f1ba9a3d036bc5952592a5a0c71e28f8fcdf891a Mon Sep 17 00:00:00 2001 From: SimonAtEida Date: Mon, 15 Apr 2024 10:49:55 +0200 Subject: [PATCH 1/5] add status_type as optional param --- elhub_sdk/acknolwedgment.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/elhub_sdk/acknolwedgment.py b/elhub_sdk/acknolwedgment.py index 30462df..ab8b56a 100644 --- a/elhub_sdk/acknolwedgment.py +++ b/elhub_sdk/acknolwedgment.py @@ -13,9 +13,11 @@ request have been acknowledged. """ + import logging import uuid from datetime import datetime +from typing import Optional, Literal import zeep from zeep.plugins import HistoryPlugin @@ -38,6 +40,7 @@ def acknowledge_poll( history: HistoryPlugin, sender_gsn: str, original_business_document_reference: str, + status_type: Optional[Literal[39, 41]], process_role: ROLES = ROLES.THIRD_PARTY, ) -> bool: """ @@ -48,6 +51,7 @@ def acknowledge_poll( meter_identificator: sender_gsn: original_business_document_reference: + status_type: process_role: Returns: @@ -55,6 +59,7 @@ def acknowledge_poll( """ factory = client.type_factory('ns4') + status = STATUS_TYPE.ACCEPTED.value if status_type is None else status_type eh_request = factory.Acknowledgement( Header={ 'Identification': uuid.uuid4(), @@ -92,7 +97,7 @@ def acknowledge_poll( }, PayloadResponseEvent={ 'StatusType': { - '_value_1': STATUS_TYPE.ACCEPTED.value, + '_value_1': status, 'listAgencyIdentifier': LIST_AGENCY_IDENTIFIER.UN_CEFACT.value, }, 'OriginalBusinessDocumentReference': original_business_document_reference, From 66251264f32acdc2c24378c0862e8f535299b701 Mon Sep 17 00:00:00 2001 From: SimonAtEida Date: Wed, 17 Apr 2024 16:41:13 +0200 Subject: [PATCH 2/5] fix namespace --- elhub_sdk/acknolwedgment.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/elhub_sdk/acknolwedgment.py b/elhub_sdk/acknolwedgment.py index ab8b56a..e7af468 100644 --- a/elhub_sdk/acknolwedgment.py +++ b/elhub_sdk/acknolwedgment.py @@ -40,7 +40,6 @@ def acknowledge_poll( history: HistoryPlugin, sender_gsn: str, original_business_document_reference: str, - status_type: Optional[Literal[39, 41]], process_role: ROLES = ROLES.THIRD_PARTY, ) -> bool: """ @@ -51,15 +50,13 @@ def acknowledge_poll( meter_identificator: sender_gsn: original_business_document_reference: - status_type: process_role: Returns: """ - factory = client.type_factory('ns4') - status = STATUS_TYPE.ACCEPTED.value if status_type is None else status_type + factory = client.type_factory('ns7') eh_request = factory.Acknowledgement( Header={ 'Identification': uuid.uuid4(), @@ -86,7 +83,7 @@ def acknowledge_poll( }, ProcessEnergyContext={ # https://dok.elhub.no/ediel2/general#General-Process 'EnergyBusinessProcess': { - '_value_1': BSR_IDS.METERING_VALUES.value, + '_value_1': BSR_IDS.POLL.value, 'listAgencyIdentifier': LIST_AGENCY_IDENTIFIER.ELHUB.value, }, 'EnergyBusinessProcessRole': { @@ -97,7 +94,7 @@ def acknowledge_poll( }, PayloadResponseEvent={ 'StatusType': { - '_value_1': status, + '_value_1': STATUS_TYPE.ACCEPTED.value, 'listAgencyIdentifier': LIST_AGENCY_IDENTIFIER.UN_CEFACT.value, }, 'OriginalBusinessDocumentReference': original_business_document_reference, @@ -105,7 +102,7 @@ def acknowledge_poll( ) try: - response = client.service.Acknowledge(eh_request) + response = client.service.AcknowledgePoll(eh_request) if history.last_received: return True logger.error(f"Unknown error: {response}") From 9154ddfcff4b30112bec33348caddda626e9d5a2 Mon Sep 17 00:00:00 2001 From: SimonAtEida Date: Wed, 17 Apr 2024 16:41:32 +0200 Subject: [PATCH 3/5] add POLL to BRS_IDS Enum --- elhub_sdk/enums.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elhub_sdk/enums.py b/elhub_sdk/enums.py index 16e569f..8782236 100644 --- a/elhub_sdk/enums.py +++ b/elhub_sdk/enums.py @@ -51,6 +51,7 @@ class BSR_IDS(Enum): METERING_VALUES = "BRS-NO-315" THIRD_PARTY = "BRS-NO-622" METERING_POINT_CHARACTERISTICS = "BRS-NO-611" + POLL = "POLL" class ROLES(Enum): @@ -90,7 +91,6 @@ class THIRD_PARTY_ACTION(Enum): UPDATE = "Update" - class STATUS_TYPE(Enum): """ Status Type From 82ea525d81e6d0578642cd546294f83ff4a39434 Mon Sep 17 00:00:00 2001 From: SimonAtEida Date: Wed, 17 Apr 2024 16:41:51 +0200 Subject: [PATCH 4/5] Use Poll_metering_values client --- tests/test_integration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_integration.py b/tests/test_integration.py index 5029a72..7c6a996 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -131,7 +131,7 @@ def test_acknowledge_poll_metering_values(): client, history = APIClient.get_client( environment=ElHubEnvironment.TEST, - service=ElHubService.METERING_VALUES, + service=ElHubService.POOL_METERING_VALUES, key_file=KEY_FILE, cert_file=CERT_FILE, ) From 0cb7d44495164be06742e2b3d47e15451c06f96b Mon Sep 17 00:00:00 2001 From: SimonAtEida Date: Wed, 17 Apr 2024 17:02:07 +0200 Subject: [PATCH 5/5] remove unused import --- elhub_sdk/acknolwedgment.py | 1 - 1 file changed, 1 deletion(-) diff --git a/elhub_sdk/acknolwedgment.py b/elhub_sdk/acknolwedgment.py index e7af468..5ae4785 100644 --- a/elhub_sdk/acknolwedgment.py +++ b/elhub_sdk/acknolwedgment.py @@ -17,7 +17,6 @@ import logging import uuid from datetime import datetime -from typing import Optional, Literal import zeep from zeep.plugins import HistoryPlugin