index.rst 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. .. OpenLEADR documentation master file, created by
  2. sphinx-quickstart on Thu Jul 9 14:09:27 2020.
  3. You can adapt this file completely to your liking, but it should at least
  4. contain the root `toctree` directive.
  5. ====================
  6. Welcome to OpenLEADR
  7. ====================
  8. A friendly and compliant OpenADR implementation for Python 3.
  9. Key Features
  10. ============
  11. - Fully compliant OpenADR 2.0b implementation for both servers (Virtual Top Node) and clients (Virtual End Node)
  12. - Fully asyncio: you set up the coroutines that can handle certain events, and they get called when needed.
  13. - Fully pythonic: all messages are represented as simple Python dictionaries. All XML parsing and generation is done for you.
  14. Take a :ref:`feature_tour`!
  15. Project Status
  16. ==============
  17. The current version is |release|.
  18. This project is still a work in progress. Please see our :ref:`roadmap` for information.
  19. License
  20. =======
  21. This project is licensed under the Apache 2.0 license.
  22. Development and contributing
  23. ============================
  24. The source code of this project can be found on `GitHub <https://github.com/openleadr>`_. Feature requests, bug reports and pull requests are most welcome and can be posted there.
  25. Library Installation
  26. ====================
  27. .. code-block:: bash
  28. $ pip install openleadr
  29. OpenLEADR is compatible with Python 3.6+
  30. Getting Started
  31. ===============
  32. Client example::
  33. from openleadr import OpenADRClient
  34. import asyncio
  35. async def main():
  36. client = OpenADRClient(ven_name="Device001",
  37. vtn_url="http://localhost:8080/OpenADR2/Simple/2.0b")
  38. client.add_handler('on_event', handle_event)
  39. await client.run()
  40. async def handle_event(event):
  41. """
  42. This coroutine will be called
  43. when there is an event to be handled.
  44. """
  45. print("There is an event!")
  46. print(event)
  47. # Do something to determine whether to Opt In or Opt Out
  48. return 'optIn'
  49. loop = asyncio.get_event_loop()
  50. loop.create_task(main())
  51. loop.run_forever()
  52. This will connect to an OpenADR server (indicated by the vtn_url parameter), handle registration, start polling for events and reports, and will call your coroutines whenever an event or report is created for you.
  53. Table of Contents
  54. =================
  55. .. toctree::
  56. :name: mastertoc
  57. :maxdepth: 2
  58. features
  59. client
  60. server
  61. reporting
  62. logging
  63. message_signing
  64. roadmap
  65. API Reference <api/modules>
  66. representations
  67. Representations of OpenADR payloads
  68. ===================================
  69. OpenLEADR uses Python dictionaries and vanilla Python types (like datetime and timedelta) to represent the OpenADR payloads. These pages serve as a reference to these representations.
  70. For example, this XML payload:
  71. .. code-block:: xml
  72. <?xml version="1.0" encoding="utf-8"?>
  73. <oadrPayload xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://openadr.org/oadr-2.0b/2012/07" xsi:schemaLocation="http://openadr.org/oadr-2.0b/2012/07 oadr_20b.xsd">
  74. <oadrSignedObject>
  75. <oadrResponse ei:schemaVersion="2.0b" xmlns:ei="http://docs.oasis-open.org/ns/energyinterop/201110">
  76. <ei:eiResponse>
  77. <ei:responseCode>200</ei:responseCode>
  78. <ei:responseDescription>OK</ei:responseDescription>
  79. <requestID xmlns="http://docs.oasis-open.org/ns/energyinterop/201110/payloads" />
  80. </ei:eiResponse>
  81. <ei:venID>o57b65be83</ei:venID>
  82. </oadrResponse>
  83. </oadrSignedObject>
  84. </oadrPayload>
  85. is represented in OpenLEADR as:
  86. .. code-block:: python3
  87. {'response': {'response_code': 200,
  88. 'response_description': 'OK'},
  89. 'ven_id': 'o57b65be83'}
  90. Read more about the representations at :ref:`representations`
  91. Indices and tables
  92. ==================
  93. * :ref:`genindex`
  94. * :ref:`modindex`
  95. * :ref:`search`