<?xml version="1.0"?>
<rss version="2.0"><channel><title>PreShow Experience Guides: Actions</title><link>https://preshowexperience.com/preshow-experience-guides/actions/?d=1</link><description>PreShow Experience Guides: Actions</description><language>en</language><item><title>Creating Action Files</title><link>https://preshowexperience.com/preshow-experience-guides/actions/creating-action-files-r19/</link><description><![CDATA[<p>
	To create an Action File, follow these steps:
</p>

<ol>
	<li>
		Create a new text document.
	</li>
	<li>
		Input the command that you want to use.
	</li>
	<li>
		Save the file as &lt;file_name&gt;.action in the Actions directory of your PreShow Experience content folder.
	</li>
	<li>
		You can also find pre-built Actions for different home automation solutions in the Downloads section of our website.
	</li>
	<li>
		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.
	</li>
</ol>

<p>
	Action Files use the following Syntax, Methods, and Protocols:
</p>

<ul>
	<li>
		<p>
			<strong>Syntax:</strong>
		</p>

		<ul>
			<li>
				Use "#" at the beginning of a line to ignore the contents of that line.
			</li>
			<li>
				Use "&lt;protocol&gt;://" at the beginning of a line to specify the protocol for that command.
			</li>
			<li>
				Use "&lt;method&gt;:" at the beginning of a line to specify the method for that command.
			</li>
		</ul>
	</li>
	<li>
		<p>
			<strong>Protocols:</strong>
		</p>

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

		<ul>
			<li>
				Currently supported methods to communicate with the target device or application:
				<ul>
					<li>
						<strong>"HEADERS:":</strong> Sends header information.
					</li>
					<li>
						<strong>"POST:":</strong> Sends a POST command to create information.
					</li>
					<li>
						<strong>"PUT:": </strong>Sends a PUT command update information.
					</li>
					<li>
						<strong>"DELETE:":</strong> Sends a DELETE command to delete information.
					</li>
				</ul>
			</li>
		</ul>
	</li>
</ul>

<p>
	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.
</p>

<ul>
	<li>
		<strong>Headers Line:</strong> Specifies the content type or any other headers. Prefix the line with "HEADERS:".
	</li>
	<li>
		<strong>Data Line:</strong> 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.
	</li>
</ul>

<p>
	<span style="font-size:16px;"><strong>Examples</strong></span>
</p>

<p>
	<strong>Example 1: </strong>Sending a JSON command via URL
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted" id="ips_uid_1387_6" style=""><span class="pln"># This is a comment
http://api.example.com/endpoint?param1=value1&amp;param2=value2</span></pre>

<p>
	 
</p>

<p>
	<strong>Example 2: </strong>Running a script or add-on by add-on ID with arguments
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted" id="ips_uid_1387_8" style=""><span class="pln">addon://1234567890?arg1=value1&amp;arg2=value2</span></pre>

<p>
	 
</p>

<p>
	<strong>Example 3: </strong>Running a command or application at the OS level with arguments
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted" id="ips_uid_1387_10" style=""><span class="pln">command://path/to/executable --option1 value1 --option2 value2</span></pre>

<p>
	<strong>Example 4: </strong>Running a Python script with a main() method that is imported and called
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted" id="ips_uid_1387_12" style=""><span class="pln">module://path/to/script.py</span></pre>

<p>
	 
</p>

<p>
	<strong>Example 5: </strong>Calling a normal Python script via the operating system
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted" id="ips_uid_1387_14" style=""><span class="pln">python://path/to/script.py</span></pre>

<p>
	 
</p>

<p>
	<strong>Example 6: </strong>Adding a sleep (pause) of 500 milliseconds before moving to the next action
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted" id="ips_uid_1387_16" style=""><span class="pln">sleep://500</span></pre>

<p>
	 
</p>

<p>
	<strong>Example 7: </strong>Sending a POST command with data and headers to activate a Home Assistant Webhook
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted" id="ips_uid_6043_13" style=""><span class="pln">https://YOUR_DNS_HOSTNAME.com/api/services/scene/turn_on
HEADERS: {"Authorization": "Bearer LLATStringOfRandomCharacters", "Content-Type": "application/json"}
POST: {"entity_id": "scene.movie_start"}</span></pre>

<p>
	 
</p>

<p>
	<strong>Example 8: </strong>Sending a PUT command to change Hue brightness
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted" id="ips_uid_6043_6" style=""><span class="pln">http://</span><span class="tag">&lt;hue-bridge-ip&gt;</span><span class="pln">/api/</span><span class="tag">&lt;hue-bridge-user&gt;</span><span class="pln">/groups/</span><span class="tag">&lt;hue-light-group&gt;</span><span class="pln">/action
PUT:{"on":true,"bri":40,"transitiontime":10}</span></pre>

<p>
	 
</p>

<p>
	<strong>Example 9: </strong>Sending a PUT command to turn off Hue light
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted" id="ips_uid_6043_8" style=""><span class="pln">http://</span><span class="tag">&lt;hue-bridge-ip&gt;</span><span class="pln">/api/</span><span class="tag">&lt;hue-bridge-user&gt;</span><span class="pln">/groups/</span><span class="tag">&lt;hue-light-group&gt;</span><span class="pln">/action
PUT:{"on":false,"transitiontime":30}</span></pre>

<p>
	 
</p>

<p>
	These examples demonstrate various use cases and combinations of syntax, methods, and protocols in Action Files.
</p>
]]></description><guid isPermaLink="false">19</guid><pubDate>Tue, 06 Jun 2023 17:01:48 +0000</pubDate></item></channel></rss>
