Skip to content

gri-gus/streamdeck-python-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

streamdeck-python-sdk

PyPI PyPI Apache Elgato

streamdeck-python-sdk

Library for creating Stream Deck plugins in Python.

PyPi: https://pypi.org/project/streamdeck-sdk/

Supported operating systems:

  • MacOS: 10.14 or later
  • Windows: 10 or later

Supported Stream Deck application: 6.0, 6.1, 6.2

Supported Python: 3.7 or later

Installation

pip install streamdeck-sdk

or

pip install streamdeck_sdk

Features

  • Easy use. You can quickly create your own plugin without having to understand how websockets and other complicated things work.
  • Fully typed, using pydantic.
  • Includes image to base64 converters for easy installation of icons on keys.
  • Includes a decorator for functions and methods to run on a separate thread.
  • Exception logging and easy logging configuration.

How to use Documentation if it is not written?

🧑‍💻 Documentation under development

To get started, take a look at the Examples of plugins below, then move on to this section.

Let's look at an example of how the self.send_to_property_inspector method works.

Let's look at the documentation from Elgato:

Here is the object sent from the plugin when calling self.send_to_property_inspector: click

Here is the resulting object in the Property inspector when calling self.send_to_property_inspector: click

Here is the method source code for the self.send_to_property_inspector method:

def send_to_property_inspector(
        self,
        action: str,
        context: str,
        payload: dict
):
    message = events_sent_objs.SendToPropertyInspector(
        action=action,
        context=context,
        payload=payload
    )
    self.send(message)

As we can see, it accepts function parameters and transfers them to the object events_sent_objs.SendToPropertyInspector:

class SendToPropertyInspector(BaseModel):
    action: str
    context: str
    payload: dict
    event: str = "sendToPropertyInspector"

Next in the method self.send the pydantic object is converted to json and sent to Property Inspector.

What is payload?

It's any dict you want. But there is a condition, it must be convertible to json.

How Property inspector does receive payload data?

To answer this question, you need to look at the source code streamdeck-javascript-sdk. As I understand, in their sdk there is a method onSendToPropertyInspector and most likely it should be used like this:

$PI.onSendToPropertyInspector("com.ggusev.keyboard.write", jsn => {
    payload = jsn.payload; // I'm not sure about this, you need to test it
...
});

Instead of "com.ggusev.keyboard.write" you need to substitute the name of your action.

Examples

LoremFlickr - Plugin for installing images from LoremFlickr to button. Supports MacOS and Windows.