77if TYPE_CHECKING :
88 from typing import Any , Literal
99
10+ from streamdeck .types import (
11+ ActionInstanceUUIDStr ,
12+ ActionUUIDStr ,
13+ DeviceUUIDStr ,
14+ EventNameStr ,
15+ PluginDefinedData ,
16+ )
1017 from streamdeck .websocket import WebSocketClient
1118
1219
1623
1724class StreamDeckCommandSender :
1825 """Class for sending command event messages to the Stream Deck software through a WebSocket client."""
26+
1927 def __init__ (self , client : WebSocketClient , plugin_registration_uuid : str ):
2028 self ._client = client
2129 self ._plugin_registration_uuid = plugin_registration_uuid
2230
23- def _send_event (self , event : str , ** kwargs : Any ) -> None :
31+ def _send_event (self , event : EventNameStr , ** kwargs : Any ) -> None :
2432 self ._client .send_event ({
2533 "event" : event ,
2634 ** kwargs ,
2735 })
2836
29- def set_settings (self , context : str , payload : dict [ str , Any ] ) -> None :
37+ def set_settings (self , context : ActionInstanceUUIDStr , payload : PluginDefinedData ) -> None :
3038 self ._send_event (
3139 event = "setSettings" ,
3240 context = context ,
3341 payload = payload ,
3442 )
3543
36- def get_settings (self , context : str ) -> None :
44+ def get_settings (self , context : ActionInstanceUUIDStr ) -> None :
3745 self ._send_event (
3846 event = "getSettings" ,
3947 context = context ,
4048 )
4149
42- def set_global_settings (self , payload : dict [ str , Any ] ) -> None :
50+ def set_global_settings (self , payload : PluginDefinedData ) -> None :
4351 self ._send_event (
4452 event = "setGlobalSettings" ,
4553 context = self ._plugin_registration_uuid ,
@@ -52,14 +60,14 @@ def get_global_settings(self) -> None:
5260 context = self ._plugin_registration_uuid ,
5361 )
5462
55- def open_url (self , context : str , url : str ) -> None :
63+ def open_url (self , context : ActionInstanceUUIDStr , url : str ) -> None :
5664 self ._send_event (
5765 event = "openUrl" ,
5866 context = context ,
5967 payload = {"url" : url },
6068 )
6169
62- def log_message (self , context : str , message : str ) -> None :
70+ def log_message (self , context : ActionInstanceUUIDStr , message : str ) -> None :
6371 self ._send_event (
6472 event = "logMessage" ,
6573 context = context ,
@@ -68,10 +76,10 @@ def log_message(self, context: str, message: str) -> None:
6876
6977 def set_title (
7078 self ,
71- context : str ,
79+ context : ActionInstanceUUIDStr ,
7280 state : int | None = None ,
73- target : str | None = None ,
74- title : str | None = None
81+ target : Literal [ "hardware" , "software" , "both" ] | None = None ,
82+ title : str | None = None ,
7583 ) -> None :
7684 payload = {}
7785
@@ -90,10 +98,10 @@ def set_title(
9098
9199 def set_image (
92100 self ,
93- context : str ,
94- image : str , # base64 encoded image,
95- target : Literal ["hardware" , "software" , "both" ], # software, hardware, or both,
96- state : int , # 0-based integer
101+ context : ActionInstanceUUIDStr ,
102+ image : str , # base64 encoded image,
103+ target : Literal ["hardware" , "software" , "both" ],
104+ state : int ,
97105 ) -> None :
98106 """...
99107
@@ -117,14 +125,26 @@ def set_image(
117125 },
118126 )
119127
120- def set_feedback (self , context : str , payload : dict [str , Any ]) -> None :
128+ def set_feedback (self , context : ActionInstanceUUIDStr , payload : PluginDefinedData ) -> None :
129+ """Set's the feedback of an existing layout associated with an action instance.
130+
131+ Args:
132+ context (str): Defines the context of the command, e.g. which action instance the command is intended for.
133+ payload (PluginDefinedData): Additional information supplied as part of the command.
134+ """
121135 self ._send_event (
122136 event = "setFeedback" ,
123137 context = context ,
124138 payload = payload ,
125139 )
126140
127- def set_feedback_layout (self , context : str , layout : str ) -> None :
141+ def set_feedback_layout (self , context : ActionInstanceUUIDStr , layout : str ) -> None :
142+ """Sets the layout associated with an action instance.
143+
144+ Args:
145+ context (str): Defines the context of the command, e.g. which action instance the command is intended for.
146+ layout (str): Name of a pre-defined layout, or relative path to a custom one.
147+ """
128148 self ._send_event (
129149 event = "setFeedbackLayout" ,
130150 context = context ,
@@ -133,7 +153,7 @@ def set_feedback_layout(self, context: str, layout: str) -> None:
133153
134154 def set_trigger_description (
135155 self ,
136- context : str ,
156+ context : ActionInstanceUUIDStr ,
137157 rotate : str | None = None ,
138158 push : str | None = None ,
139159 touch : str | None = None ,
@@ -170,21 +190,21 @@ def set_trigger_description(
170190 },
171191 )
172192
173- def show_alert (self , context : str ) -> None :
193+ def show_alert (self , context : ActionInstanceUUIDStr ) -> None :
174194 """Temporarily show an alert icon on the image displayed by an instance of an action."""
175195 self ._send_event (
176196 event = "showAlert" ,
177197 context = context ,
178198 )
179199
180- def show_ok (self , context : str ) -> None :
200+ def show_ok (self , context : ActionInstanceUUIDStr ) -> None :
181201 """Temporarily show an OK checkmark icon on the image displayed by an instance of an action."""
182202 self ._send_event (
183203 event = "showOk" ,
184204 context = context ,
185205 )
186206
187- def set_state (self , context : str , state : int ) -> None :
207+ def set_state (self , context : ActionInstanceUUIDStr , state : int ) -> None :
188208 self ._send_event (
189209 event = "setState" ,
190210 context = context ,
@@ -193,8 +213,8 @@ def set_state(self, context: str, state: int) -> None:
193213
194214 def switch_to_profile (
195215 self ,
196- context : str ,
197- device : str ,
216+ context : ActionInstanceUUIDStr ,
217+ device : DeviceUUIDStr ,
198218 profile : str | None = None ,
199219 page : int = 0 ,
200220 ) -> None :
@@ -211,7 +231,7 @@ def switch_to_profile(
211231 page (int): Page to show when switching to the profile; indexed from 0.
212232 """
213233 # TODO: Should validation happen that ensures the specified profile is declared in manifest.yaml?
214- payload = {}
234+ payload : dict [ str , str | int | None ] = {}
215235
216236 if profile is not None :
217237 payload = {
@@ -226,18 +246,17 @@ def switch_to_profile(
226246 payload = payload ,
227247 )
228248
229- def send_to_property_inspector (self , context : str , payload : dict [str , Any ]) -> None :
249+ def send_to_property_inspector (
250+ self , context : ActionInstanceUUIDStr , payload : PluginDefinedData
251+ ) -> None :
230252 self ._send_event (
231253 event = "sendToPropertyInspector" ,
232254 context = context ,
233255 payload = payload ,
234256 )
235257
236258 def send_to_plugin (
237- self ,
238- context : str ,
239- action : str ,
240- payload : dict [str , Any ]
259+ self , context : ActionInstanceUUIDStr , action : ActionUUIDStr , payload : PluginDefinedData
241260 ) -> None :
242261 """Send a payload to another plugin.
243262
0 commit comments