You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SDK allows you to create custom event listeners and events by extending the `EventListener` and `EventBase` classes. This is useful when you need to monitor data from external applications and perform specific actions in response to changes or alerts.
290
+
291
+
### Creating a Custom Event Listener
292
+
293
+
To create a custom event listener:
294
+
295
+
1. Create new event model that inherits from `EventBase`.
296
+
2. Create a new class that inherits from `EventListener`.
297
+
a. Implement the required `listen` and `stop` methods. The `listen` method should yield results as a json string that matches the new event model.
298
+
b. List the new event classes in the `event_models` class variable of the new `EventListener` class.
299
+
3. Configure your plugin in its `pyproject.toml` file to use your custom listener.
300
+
301
+
```python
302
+
# custom_listener.py
303
+
from collections.abc import Generator
304
+
from typing import ClassVar, Literal
305
+
306
+
from streamdeck.event_listener import EventListener
# Stop the loop or blocking call in the listen method.
329
+
# Ex:
330
+
# self._running = False
331
+
```
332
+
333
+
### Configuring Your Custom Listener
334
+
335
+
To use your custom event listener, add it to your `pyproject.toml` file:
336
+
337
+
```toml
338
+
[tools.streamdeck]
339
+
action_scripts = [
340
+
"main.py",
341
+
]
342
+
event_listener_modules = [
343
+
"myplugin.custom_listener",
344
+
]
345
+
```
346
+
347
+
The `event_listeners` list should contain strings in module format for each module you want to use.
348
+
349
+
287
350
## Creating and Packaging Plugins
288
351
289
352
To create a new plugin with all of the necessary files to start from and package it for use on your Stream Deck, use [the Python SDK CLI tool](https://github.com/strohganoff/python-streamdeck-plugin-sdk-cli).
0 commit comments