Skip to main content

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 actionstreamer Python package installed (e.g., via pip 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.txt
  • SecretKey.txt

These should be placed in a known folder on the file system, such as:

  • C:\temp\config\ (Windows)
  • /tmp/config/ (Linux/macOS)

Example Code

# Install the actionstreamer Python library:
# pip install actionstreamer

import actionstreamer.Model
import actionstreamer.WebService
import actionstreamer.CommonFunctions
import actionstreamer.WebService.EventPreset

# Save your access key and secret key to AccessKey.txt and SecretKey.txt somewhere on the file system.
if actionstreamer.Config.is_windows():
config_folder_path = 'C:\\temp\\config\\'
else:
config_folder_path = '/tmp/config/'

access_key = actionstreamer.Config.get_config_value(config_folder_path, "AccessKey")
secret_key = actionstreamer.Config.get_config_value(config_folder_path, "SecretKey")
web_service_base_url = 'https://api.actionstreamer.com/'

ws_config = actionstreamer.Config.WebServiceConfig(access_key, secret_key, web_service_base_url, 10)
ws_result = actionstreamer.WebService.API.WebServiceResult(0, '', 0, '', '')

event_preset_id = 68

ws_result = actionstreamer.WebService.EventPreset.run_event_preset(ws_config, event_preset_id)

print(ws_result.http_response_code)
print(ws_result.http_response_string)