ソースを参照

Info on accessing event targets in response

Signed-off-by: Stan Janssen <stan.janssen@elaad.nl>
Stan Janssen 4 年 前
コミット
9e5f03a62e
1 ファイル変更18 行追加0 行削除
  1. 18 0
      docs/server.rst

+ 18 - 0
docs/server.rst

@@ -109,6 +109,24 @@ Alternatively, you can use the handy constructors in ``openleadr.objects`` to fo
                      target=[Target(resource_id='Device001')],
                      callback=partial(event_callback, ven_id='ven123', event_id='event123'))
 
+A word on event targets
+~~~~~~~~~~~~~~~~~~~~~~~
+
+The Target of your Event is an indication for the VEN which resources or devices should be affected. You can supply the target of the event in serveral ways:
+
+- Assigning the ``target`` parameter with a single ``objects.Target`` object.
+- Assigning the ``targets`` parameter with a list of ``objects.Target`` objects.
+- Assigning the ``targets_by_type`` parameters with a dict, that lists targets grouped by their type, like this:
+
+.. code-block:: python3
+
+    server.add_event(...
+                     targets_by_type={'resource_id': ['resource01', 'resource02'],
+                                      'group_id': ['group01', 'group02']}
+                     )
+
+If you dont assign any Target, the target will be set to the ``ven_id`` that you specified.
+
 
 .. _server_reports: