Jump to content
  • Creating Action Files

    To create an Action File, follow these steps:

    1. Create a new text document.
    2. Input the command that you want to use.
    3. Save the file as <file_name>.action in the Actions directory of your PreShow Experience content folder.
    4. You can also find pre-built Actions for different home automation solutions in the Downloads section of our website.
    5. If you have any improvements or new Actions that you create, please share them with us. We can host them on the site for others to use.

    Action Files use the following Syntax, Methods, and Protocols:

    • Syntax:

      • Use "#" at the beginning of a line to ignore the contents of that line.
      • Use "<protocol>://" at the beginning of a line to specify the protocol for that command.
      • Use "<method>:" at the beginning of a line to specify the method for that command.
    • Protocols:

      • Currently supported protocols:
        • "http://" or "https://": Passes JSON commands via a URL.
        • "addon://": Runs a script or add-on.
        • "command://": Runs a command or application at the OS level and pass arguments.
        • "module://": Runs a Python script with a main() method that is imported and called.
        • "python://": Run a Python script.
        • "sleep://<milliseconds>": Pauses the Action File for the specified time in milliseconds.
    • Methods:

      • Currently supported methods to communicate with the target device or application:
        • "HEADERS:": Sends header information.
        • "POST:": Sends a POST command to create information.
        • "PUT:": Sends a PUT command update information.
        • "DELETE:": Sends a DELETE command to delete information.

    Actions in Action Files can be single-line or multiple-line commands. Blank lines are used to separate commands. The first line of any Action is the Execution Line. The line following the Execution Line can be a Headers Line or a Data Line.

    • Headers Line: Specifies the content type or any other headers. Prefix the line with "HEADERS:".
    • Data Line: Used to pass arguments or data. Prefix the line with the desired Method ("POST:", "PUT:", or "DELETE:"). If no method is specified, the default method used is POST.

    Examples

    Example 1: Sending a JSON command via URL

    # This is a comment
    http://api.example.com/endpoint?param1=value1&param2=value2

     

    Example 2: Running a script or add-on by add-on ID with arguments

    addon://1234567890?arg1=value1&arg2=value2

     

    Example 3: Running a command or application at the OS level with arguments

    command://path/to/executable --option1 value1 --option2 value2

    Example 4: Running a Python script with a main() method that is imported and called

    module://path/to/script.py

     

    Example 5: Calling a normal Python script via the operating system

    python://path/to/script.py

     

    Example 6: Adding a sleep (pause) of 500 milliseconds before moving to the next action

    sleep://500

     

    Example 7: Sending a POST command with data and headers to activate a Home Assistant Webhook

    https://YOUR_DNS_HOSTNAME.com/api/services/scene/turn_on
    HEADERS: {"Authorization": "Bearer LLATStringOfRandomCharacters", "Content-Type": "application/json"}
    POST: {"entity_id": "scene.movie_start"}

     

    Example 8: Sending a PUT command to change Hue brightness

    http://<hue-bridge-ip>/api/<hue-bridge-user>/groups/<hue-light-group>/action
    PUT:{"on":true,"bri":40,"transitiontime":10}

     

    Example 9: Sending a PUT command to turn off Hue light

    http://<hue-bridge-ip>/api/<hue-bridge-user>/groups/<hue-light-group>/action
    PUT:{"on":false,"transitiontime":30}

     

    These examples demonstrate various use cases and combinations of syntax, methods, and protocols in Action Files.

    • Like 1




×
×
  • Create New...