.. _representations:
=======================
Payload Representations
=======================
In OpenLEADR, the complex hierarchies of the OpenADR XML-payloads are represented as Python dictionaries. These have been simplified as much as possible, allowing for a more natural and more readable experience.
This means that you don't have to instantiate objects and sub-objects and sub-sub-objects, but that you can define the entire object in a single, declarative statement. This kan keep a simple implementation very compact. The downside is that there is little help from your IDE and there is little discoverability for what contents can be provided in the messages. This page can be used as a reference for that information.
To help you, all outgong messages are validated against the XML schema, and you will receive warnings if your messages don't comply to the schema.
The following general principles have been applied to representing OpenADR objects in OpenLEADR:
- All property names are represented in snake_case instead of CamelCase or mixedCase names. For example: ``requestID`` becomes ``request_id``.
- For all properties, the ``oadr*`` and ``Ei*`` prefixes have been stripped away. For example: ``eiResponse`` becomes ``response`` and ``oadrResponse`` becomes ``response``.
- OpenADR timestamps are converted to Python ``datetime.datetime`` objects.
- OpenADR time intervals are converted to Python ``datetime.timedelta`` objects.
- Properties that might have more than 1 copy in the XML representation are put in a list, even if there is just one. This list will be identified by the pluralized version of the original property name. For example:
.. code-block:: xml
<...>
1234
5678
<...>
Will become:
.. code-block:: python3
...
"signals": [1234, 5678],
...
- The messages are usually used as a ``message_name, message_payload`` tuple. The message name is kept, for instance, ``oadrCanceledOpt``, and the payload is given as a dict.
Below is an alphabetized overview of all payloads with their XML and Python representations.
.. _oadrCanceledOpt:
oadrCanceledOpt
===============
OpenADR payload:
.. code-block:: xml
200
OK
f48e3b7e78
pc1e8ace47
OpenLEADR representation:
.. code-block:: python3
{'opt_id': 'pc1e8ace47',
'response': {'request_id': 'f48e3b7e78',
'response_code': 200,
'response_description': 'OK'}}
.. _oadrCanceledPartyRegistration:
oadrCanceledPartyRegistration
=============================
OpenADR payload:
.. code-block:: xml
200
OK
aba0a805de
zf68abb5c2
123ABC
OpenLEADR representation:
.. code-block:: python3
{'registration_id': 'zf68abb5c2',
'response': {'request_id': 'aba0a805de',
'response_code': 200,
'response_description': 'OK'},
'ven_id': '123ABC'}
.. _oadrCanceledReport:
oadrCanceledReport
==================
OpenADR payload:
.. code-block:: xml
200
OK
e4dfe735ea
v5d42c35e6
e8bf753e31
OpenLEADR representation:
.. code-block:: python3
{'pending_reports': [{'request_id': 'v5d42c35e6'},
{'request_id': 'e8bf753e31'}],
'response': {'request_id': 'e4dfe735ea',
'response_code': 200,
'response_description': 'OK'}}
OpenADR payload:
.. code-block:: xml
200
OK
c36bce5dcb
b04cbfb723
ra6231a650
123ABC
OpenLEADR representation:
.. code-block:: python3
{'pending_reports': [{'request_id': 'b04cbfb723'},
{'request_id': 'ra6231a650'}],
'response': {'request_id': 'c36bce5dcb',
'response_code': 200,
'response_description': 'OK'},
'ven_id': '123ABC'}
.. _oadrCancelOpt:
oadrCancelOpt
=============
OpenADR payload:
.. code-block:: xml
u07a26b1cc
b1ef7afecc
123ABC
OpenLEADR representation:
.. code-block:: python3
{'opt_id': 'b1ef7afecc', 'request_id': 'u07a26b1cc', 'ven_id': '123ABC'}
.. _oadrCancelPartyRegistration:
oadrCancelPartyRegistration
===========================
OpenADR payload:
.. code-block:: xml
z05e4ff0aa
pfe04d8439
123ABC
OpenLEADR representation:
.. code-block:: python3
{'registration_id': 'pfe04d8439',
'request_id': 'z05e4ff0aa',
'ven_id': '123ABC'}
.. _oadrCancelReport:
oadrCancelReport
================
OpenADR payload:
.. code-block:: xml
kcb7b5cf7a
u1ebe92deb
true
123ABC
OpenLEADR representation:
.. code-block:: python3
{'report_request_id': 'u1ebe92deb',
'report_to_follow': True,
'request_id': 'kcb7b5cf7a',
'ven_id': '123ABC'}
.. _oadrCreatedEvent:
oadrCreatedEvent
================
OpenADR payload:
.. code-block:: xml
200
OK
yaa3ee03b1
200
OK
ycab9acb9f
od864b4ea6
1
optIn
200
OK
bf2aad9af8
hc6cf67dab
1
optIn
200
OK
jefb88dcbd
qdff0da955
1
optIn
123ABC
OpenLEADR representation:
.. code-block:: python3
{'event_responses': [{'event_id': 'od864b4ea6',
'modification_number': 1,
'opt_type': 'optIn',
'request_id': 'ycab9acb9f',
'response_code': 200,
'response_description': 'OK'},
{'event_id': 'hc6cf67dab',
'modification_number': 1,
'opt_type': 'optIn',
'request_id': 'bf2aad9af8',
'response_code': 200,
'response_description': 'OK'},
{'event_id': 'qdff0da955',
'modification_number': 1,
'opt_type': 'optIn',
'request_id': 'jefb88dcbd',
'response_code': 200,
'response_description': 'OK'}],
'response': {'request_id': 'yaa3ee03b1',
'response_code': 200,
'response_description': 'OK'},
'ven_id': '123ABC'}
OpenADR payload:
.. code-block:: xml
200
OK
yde9c0369d
200
OK
zc9523b16d
fefaa2b0f2
1
optIn
200
OK
tbeecb7c97
t63a63fea4
1
optOut
123ABC
OpenLEADR representation:
.. code-block:: python3
{'event_responses': [{'event_id': 'fefaa2b0f2',
'modification_number': 1,
'opt_type': 'optIn',
'request_id': 'zc9523b16d',
'response_code': 200,
'response_description': 'OK'},
{'event_id': 't63a63fea4',
'modification_number': 1,
'opt_type': 'optOut',
'request_id': 'tbeecb7c97',
'response_code': 200,
'response_description': 'OK'}],
'response': {'request_id': 'yde9c0369d',
'response_code': 200,
'response_description': 'OK'},
'ven_id': '123ABC'}
.. _oadrCreatedReport:
oadrCreatedReport
=================
OpenADR payload:
.. code-block:: xml
200
OK
ie8ff94fbc
p8c56f9ed9
hab1cced95
123ABC
OpenLEADR representation:
.. code-block:: python3
{'pending_reports': [{'request_id': 'p8c56f9ed9'},
{'request_id': 'hab1cced95'}],
'response': {'request_id': 'ie8ff94fbc',
'response_code': 200,
'response_description': 'OK'},
'ven_id': '123ABC'}
OpenADR payload:
.. code-block:: xml
200
OK
gde557fcae
e1e16137f3
d0f2bcbe89
OpenLEADR representation:
.. code-block:: python3
{'pending_reports': [{'request_id': 'e1e16137f3'},
{'request_id': 'd0f2bcbe89'}],
'response': {'request_id': 'gde557fcae',
'response_code': 200,
'response_description': 'OK'}}
.. _oadrCreatedPartyRegistration:
oadrCreatedPartyRegistration
============================
This message is used by the VTN in two scenarios:
1. The VEN has just sent an :ref:`oadrQueryRegistration` request, and the VTN makes its available profiles and transport mechanisms known to the VEN
2. The VEN has just sent an :ref:`oadrCreatePartyRegistration` request, and the VTN responds by sending the registrationId to the VEN.
OpenADR payload:
.. code-block:: xml
200
OK
k6565d9280
o852fdbac9
123ABC
VTN123
2.0b
simpleHttp
OpenLEADR representation:
.. code-block:: python3
{'profiles': [{'profile_name': '2.0b',
'transports': [{'transport_name': 'simpleHttp'}]}],
'registration_id': 'o852fdbac9',
'response': {'request_id': 'k6565d9280',
'response_code': 200,
'response_description': 'OK'},
'ven_id': '123ABC',
'vtn_id': 'VTN123'}
.. _oadrCreateOpt:
oadrCreateOpt
=============
OpenADR payload:
.. code-block:: xml
l170fb7ea4
optIn
participating
VEN123
2020-07-09T15:54:03.151236Z
k6dc07ece8
sdfe18dd5c
1
123ABC
OpenLEADR representation:
.. code-block:: python3
{'created_date_time': datetime.datetime(2020, 7, 9, 15, 54, 3, 151236, tzinfo=datetime.timezone.utc),
'event_id': 'sdfe18dd5c',
'modification_number': 1,
'opt_id': 'l170fb7ea4',
'opt_reason': 'participating',
'opt_type': 'optIn',
'request_id': 'k6dc07ece8',
'targets': [{'ven_id': '123ABC'}],
'ven_id': 'VEN123'}
.. _oadrCreatePartyRegistration:
oadrCreatePartyRegistration
===========================
OpenADR payload:
.. code-block:: xml
g31f3a2aae
123ABC
2.0b
simpleHttp
http://localhost
false
false
test
true
OpenLEADR representation:
.. code-block:: python3
{'http_pull_model': True,
'profile_name': '2.0b',
'report_only': False,
'request_id': 'g31f3a2aae',
'transport_address': 'http://localhost',
'transport_name': 'simpleHttp',
'ven_id': '123ABC',
'ven_name': 'test',
'xml_signature': False}
.. _oadrCreateReport:
oadrCreateReport
================
OpenADR payload:
.. code-block:: xml
sdbbdefaad
d2b7bade5f
9c8bdc00e7
PT15M
PT15M
2019-11-19T11:00:18.672768Z
PT2H
PT5M
d6e2e07485
Direct Read
123ABC
OpenLEADR representation:
.. code-block:: python3
{'report_requests': [{'report_request_id': 'd2b7bade5f',
'report_specifier': {'granularity': datetime.timedelta(seconds=900),
'report_back_duration': datetime.timedelta(seconds=900),
'report_interval': {'dtstart': datetime.datetime(2019, 11, 19, 11, 0, 18, 672768, tzinfo=datetime.timezone.utc),
'duration': datetime.timedelta(seconds=7200),
'tolerance': {'tolerate': {'startafter': datetime.timedelta(seconds=300)}}},
'report_specifier_id': '9c8bdc00e7',
'specifier_payload': {'r_id': 'd6e2e07485',
'reading_type': 'Direct '
'Read'}}}],
'request_id': 'sdbbdefaad',
'ven_id': '123ABC'}
.. _oadrDistributeEvent:
oadrDistributeEvent
===================
This message is sent by the VTN when it delivers an Event to a VEN. This is the main communication of the Event, and it contains myriad options to precisely define the event.
The VEN responds with either an :ref:`oadrCreatedEvent` message, indicating its 'opt' status ("Opt In" or "Opt Out").
OpenADR payload:
.. code-block:: xml
200
OK
123
i5fea744ae
VTN123
ifdda7aff6
1
2020-07-09T15:54:03.166717Z
1
http://MarketContext1
2020-07-09T15:54:03.166717Z
near
false
This is an event
2020-07-09T15:55:03.166717Z
PT10M
PT1M
1
8
PT1M
2
10
PT1M
3
12
PT1M
4
14
PT1M
5
16
PT1M
6
18
PT1M
7
20
PT1M
8
10
PT1M
9
20
LOAD_CONTROL
x-loadControlCapacity
zccf1b86ee
9.99
VEN001
VEN002
always
OpenLEADR representation:
.. code-block:: python3
{'events': [{'active_period': {'dtstart': datetime.datetime(2020, 7, 9, 15, 55, 3, 166717, tzinfo=datetime.timezone.utc),
'duration': datetime.timedelta(seconds=600)},
'event_descriptor': {'created_date_time': datetime.datetime(2020, 7, 9, 15, 54, 3, 166717, tzinfo=datetime.timezone.utc),
'event_id': 'ifdda7aff6',
'event_status': 'near',
'market_context': 'http://MarketContext1',
'modification_date_time': datetime.datetime(2020, 7, 9, 15, 54, 3, 166717, tzinfo=datetime.timezone.utc),
'modification_number': 1,
'priority': 1,
'test_event': 'false',
'vtn_comment': 'This is an event'},
'event_signals': [{'current_value': 9.99,
'intervals': [{'duration': datetime.timedelta(seconds=60),
'signal_payload': 8,
'uid': 1},
{'duration': datetime.timedelta(seconds=60),
'signal_payload': 10,
'uid': 2},
{'duration': datetime.timedelta(seconds=60),
'signal_payload': 12,
'uid': 3},
{'duration': datetime.timedelta(seconds=60),
'signal_payload': 14,
'uid': 4},
{'duration': datetime.timedelta(seconds=60),
'signal_payload': 16,
'uid': 5},
{'duration': datetime.timedelta(seconds=60),
'signal_payload': 18,
'uid': 6},
{'duration': datetime.timedelta(seconds=60),
'signal_payload': 20,
'uid': 7},
{'duration': datetime.timedelta(seconds=60),
'signal_payload': 10,
'uid': 8},
{'duration': datetime.timedelta(seconds=60),
'signal_payload': 20,
'uid': 9}],
'signal_id': 'zccf1b86ee',
'signal_name': 'LOAD_CONTROL',
'signal_type': 'x-loadControlCapacity'}],
'response_required': 'always',
'targets': [{'ven_id': 'VEN001'}, {'ven_id': 'VEN002'}]}],
'request_id': 'i5fea744ae',
'response': {'request_id': 123,
'response_code': 200,
'response_description': 'OK'},
'vtn_id': 'VTN123'}
.. _oadrPoll:
oadrPoll
========
This message is sent by the VEN to the VTN to poll for new messages. The VTN responds by sending an empty :ref:`oadrResponse`, a :ref:`oadrDistributeEvent` in case there is an Event for the VEN, a :ref:`oadrRequestReregistration` message in case the VTN want the VEN to register again.
In case the VEN wants to hear only about new Events, it can send a :ref:`oadrRequestEvent` message to the VTN.
OpenADR payload:
.. code-block:: xml
123ABC
OpenLEADR representation:
.. code-block:: python3
{'ven_id': '123ABC'}
.. _oadrQueryRegistration:
oadrQueryRegistration
=====================
This message is used by the VEN to request information on the VTN's capabilities before registering. The VTN will respond with a :ref:`oadrCreatedPartyRegistration` message.
OpenADR payload:
.. code-block:: xml
i8cf15d21f
OpenLEADR representation:
.. code-block:: python3
{'request_id': 'i8cf15d21f'}
.. _oadrRegisteredReport:
oadrRegisteredReport
====================
OpenADR payload:
.. code-block:: xml
200
OK
uadb7d5fe5
f5308f6138
se40c348d9
PT15M
PT15M
2020-07-09T15:54:03.184498Z
PT2H
PT5M
PT30M
PT15M
PT5M
u461c6e37e
Direct Read
tc88cf616d
le65d1bd2e
PT15M
PT15M
2020-07-09T15:54:03.184526Z
PT2H
PT5M
PT30M
PT15M
PT5M
caaff64e5a
Direct Read
VEN123
OpenLEADR representation:
.. code-block:: python3
{'report_requests': [{'report_request_id': 'f5308f6138',
'report_specifier': {'granularity': datetime.timedelta(seconds=900),
'report_back_duration': datetime.timedelta(seconds=900),
'report_interval': {'dtstart': datetime.datetime(2020, 7, 9, 15, 54, 3, 184498, tzinfo=datetime.timezone.utc),
'duration': datetime.timedelta(seconds=7200),
'notification': datetime.timedelta(seconds=1800),
'ramp_up': datetime.timedelta(seconds=900),
'recovery': datetime.timedelta(seconds=300),
'tolerance': {'tolerate': {'startafter': datetime.timedelta(seconds=300)}}},
'report_specifier_id': 'se40c348d9',
'specifier_payload': {'r_id': 'u461c6e37e',
'reading_type': 'Direct '
'Read'}}},
{'report_request_id': 'tc88cf616d',
'report_specifier': {'granularity': datetime.timedelta(seconds=900),
'report_back_duration': datetime.timedelta(seconds=900),
'report_interval': {'dtstart': datetime.datetime(2020, 7, 9, 15, 54, 3, 184526, tzinfo=datetime.timezone.utc),
'duration': datetime.timedelta(seconds=7200),
'notification': datetime.timedelta(seconds=1800),
'ramp_up': datetime.timedelta(seconds=900),
'recovery': datetime.timedelta(seconds=300),
'tolerance': {'tolerate': {'startafter': datetime.timedelta(seconds=300)}}},
'report_specifier_id': 'le65d1bd2e',
'specifier_payload': {'r_id': 'caaff64e5a',
'reading_type': 'Direct '
'Read'}}}],
'response': {'request_id': 'uadb7d5fe5',
'response_code': 200,
'response_description': 'OK'},
'ven_id': 'VEN123'}
.. _oadrRequestEvent:
oadrRequestEvent
================
OpenADR payload:
.. code-block:: xml
oa1c52db3f
123ABC
OpenLEADR representation:
.. code-block:: python3
{'request_id': 'oa1c52db3f', 'ven_id': '123ABC'}
.. _oadrRequestReregistration:
oadrRequestReregistration
=========================
This message is sent by the VTN whenever it want the VEN to go through the registration procedure again. Usually sent in reply to a :ref:`oadrPoll` message.
OpenADR payload:
.. code-block:: xml
123ABC
OpenLEADR representation:
.. code-block:: python3
{'ven_id': '123ABC'}
.. _oadrResponse:
oadrResponse
============
This is a generic message that the VTN sends to the VEN if there is no other message for the VEN. Usually sent in response to an :ref:`oadrPoll` or :ref:`oadrRequestEvent` message.
OpenADR payload:
.. code-block:: xml
200
OK
i4a4d03ae5
123ABC
OpenLEADR representation:
.. code-block:: python3
{'response': {'request_id': 'i4a4d03ae5',
'response_code': 200,
'response_description': 'OK'},
'ven_id': '123ABC'}
OpenADR payload:
.. code-block:: xml
200
OK
123ABC
OpenLEADR representation:
.. code-block:: python3
{'response': {'request_id': None,
'response_code': 200,
'response_description': 'OK'},
'ven_id': '123ABC'}
.. _oadrUpdatedReport:
oadrUpdatedReport
=================
OpenADR payload:
.. code-block:: xml
200
OK
icaffaa44f
ra11e4fee3
kbf16facdd
kfbae403c3
k91557da99
false
123ABC
123ABC
OpenLEADR representation:
.. code-block:: python3
{'cancel_report': {'report_request_id': ['kbf16facdd',
'kfbae403c3',
'k91557da99'],
'report_to_follow': False,
'request_id': 'ra11e4fee3',
'ven_id': '123ABC'},
'response': {'request_id': 'icaffaa44f',
'response_code': 200,
'response_description': 'OK'},
'ven_id': '123ABC'}
.. _oadrUpdateReport:
oadrUpdateReport
================
This message contains a report.
OpenADR payload:
.. code-block:: xml
bfbaaa469c
z4edcf6f9d
s1167debd8
123ABC
DEF456
123ABC
x-resourceStatus
x-RMS
http://localhost
PT1M
PT2M
false
m04fa486ef
w5fdcab8d0
TELEMETRY_USAGE
2020-07-10T09:24:38.606626Z
123ABC
OpenLEADR representation:
.. code-block:: python3
{'reports': [{'created_date_time': datetime.datetime(2020, 7, 10, 9, 24, 38, 606626, tzinfo=datetime.timezone.utc),
'report_descriptions': [{'market_context': 'http://localhost',
'r_id': 's1167debd8',
'reading_type': 'x-RMS',
'report_data_sources': [{'ven_id': '123ABC'}],
'report_subjects': [{'ven_id': '123ABC'},
{'ven_id': 'DEF456'}],
'report_type': 'x-resourceStatus',
'sampling_rate': {'max_period': datetime.timedelta(seconds=120),
'min_period': datetime.timedelta(seconds=60),
'on_change': False}}],
'report_id': 'z4edcf6f9d',
'report_name': 'TELEMETRY_USAGE',
'report_request_id': 'm04fa486ef',
'report_specifier_id': 'w5fdcab8d0'}],
'request_id': 'bfbaaa469c',
'ven_id': '123ABC'}