Run Event Preset
This example demonstrates how to enqueue an event for a device with the ActionStreamer API using the official Python library.
Prerequisites
- Python 3.7+
- The
actionstreamerPython package installed (e.g., viapip install actionstreamer) - Access and secret keys saved to the local file system
File Setup
Save your access key and secret key in text files:
AccessKey.txtSecretKey.txt
Store these files in a local configuration folder, for example:
C:\temp\config\(Windows)/tmp/config/(Linux/macOS)
Example Code
# Install the actionstreamer Python library:
# pip install actionstreamer
from actionstreamer import Config
from actionstreamer import WebService
# Save your access key and secret key to AccessKey.txt and SecretKey.txt somewhere on the file system.
if Config.is_windows():
config_folder_path = 'C:\\temp\\config\\'
else:
config_folder_path = '/tmp/config/'
access_key = Config.get_config_value(config_folder_path, "AccessKey")
secret_key = Config.get_config_value(config_folder_path, "SecretKey")
base_url = 'https://api.actionstreamer.com/'
ws_config = Config.WebServiceConfig(access_key, secret_key, base_url, 10, False)
preset_id = 382
result = WebService.EventPreset.run_event_preset(ws_config, preset_id)
print(result.code)
print(result.description)