Site updated at 2016-08-22 08:21:42 UTC
This commit is contained in:
parent
f9d65cbe57
commit
4acb07bf8e
559 changed files with 18878 additions and 21688 deletions
|
@ -91,20 +91,18 @@
|
|||
|
||||
<p>A switch platform that issues specific commands when it is turned on and off. This might very well become our most powerful platform as it allows anyone to integrate any type of switch into Home Assistant that can be controlled from the command line, including calling other scripts!</p>
|
||||
|
||||
<p>To enable it, add the following lines to your <code>configuration.yaml</code>:</p>
|
||||
<p>To enable it, add the following lines to your <code class="highlighter-rouge">configuration.yaml</code>:</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="comment"># Example configuration.yaml entry</span>
|
||||
<span class="key">switch</span>:
|
||||
<span class="key">platform</span>: <span class="string"><span class="content">command_line</span></span>
|
||||
<span class="key">switches</span>:
|
||||
<span class="key">kitchen_light</span>:
|
||||
<span class="key">oncmd</span>: <span class="string"><span class="content">switch_command on kitchen</span></span>
|
||||
<span class="key">offcmd</span>: <span class="string"><span class="content">switch_command off kitchen</span></span>
|
||||
<span class="key">statecmd</span>: <span class="string"><span class="content">query_command kitchen</span></span>
|
||||
<span class="key">value_template</span>: <span class="string"><span class="content">'{{ value == "online" }}'</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="c1"># Example configuration.yaml entry</span>
|
||||
<span class="s">switch</span><span class="pi">:</span>
|
||||
<span class="s">platform</span><span class="pi">:</span> <span class="s">command_line</span>
|
||||
<span class="s">switches</span><span class="pi">:</span>
|
||||
<span class="s">kitchen_light</span><span class="pi">:</span>
|
||||
<span class="s">oncmd</span><span class="pi">:</span> <span class="s">switch_command on kitchen</span>
|
||||
<span class="s">offcmd</span><span class="pi">:</span> <span class="s">switch_command off kitchen</span>
|
||||
<span class="s">statecmd</span><span class="pi">:</span> <span class="s">query_command kitchen</span>
|
||||
<span class="s">value_template</span><span class="pi">:</span> <span class="s1">'</span><span class="s">{{</span><span class="nv"> </span><span class="s">value</span><span class="nv"> </span><span class="s">==</span><span class="nv"> </span><span class="s">"online"</span><span class="nv"> </span><span class="s">}}'</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>Configuration variables:</p>
|
||||
|
@ -116,8 +114,8 @@
|
|||
<ul>
|
||||
<li><strong>oncmd</strong> (<em>Required</em>): The action to take for on.</li>
|
||||
<li><strong>offcmd</strong> (<em>Required</em>): The action to take for off.</li>
|
||||
<li><strong>statecmd</strong> (<em>Optional</em>): If given, this command will be run. Returning a result code <code>0</code> will indicate that the switch is on.</li>
|
||||
<li><strong>value_template</strong> (<em>Optional</em>): If specified, statecmd will ignore the result code of the command but the template evaluating to <code>true</code> will indicate the switch is on.</li>
|
||||
<li><strong>statecmd</strong> (<em>Optional</em>): If given, this command will be run. Returning a result code <code class="highlighter-rouge">0</code> will indicate that the switch is on.</li>
|
||||
<li><strong>value_template</strong> (<em>Optional</em>): If specified, statecmd will ignore the result code of the command but the template evaluating to <code class="highlighter-rouge">true</code> will indicate the switch is on.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -130,18 +128,16 @@
|
|||
|
||||
<h3><a class="title-link" name="arest-device" href="#arest-device"></a> aREST device</h3>
|
||||
|
||||
<p>The example below is doing the same as the <a href="/components/switch.arest/">aREST switch</a>. The commandline tool <a href="http://curl.haxx.se/"><code>curl</code></a> is used to toogle a pin which is controllable through REST.</p>
|
||||
<p>The example below is doing the same as the <a href="/components/switch.arest/">aREST switch</a>. The commandline tool <a href="http://curl.haxx.se/"><code class="highlighter-rouge">curl</code></a> is used to toogle a pin which is controllable through REST.</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="comment"># Example configuration.yaml entry</span>
|
||||
<span class="key">switch</span>:
|
||||
<span class="key">platform</span>: <span class="string"><span class="content">command_line</span></span>
|
||||
<span class="key">switches</span>:
|
||||
<span class="key">arest_pin4</span>:
|
||||
<span class="key">oncmd</span>: <span class="string"><span class="delimiter">"</span><span class="content">/usr/bin/curl -X GET http://192.168.1.10/digital/4/1</span><span class="delimiter">"</span></span>
|
||||
<span class="key">offcmd</span>: <span class="string"><span class="delimiter">"</span><span class="content">/usr/bin/curl -X GET http://192.168.1.10/digital/4/0</span><span class="delimiter">"</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="c1"># Example configuration.yaml entry</span>
|
||||
<span class="s">switch</span><span class="pi">:</span>
|
||||
<span class="s">platform</span><span class="pi">:</span> <span class="s">command_line</span>
|
||||
<span class="s">switches</span><span class="pi">:</span>
|
||||
<span class="s">arest_pin4</span><span class="pi">:</span>
|
||||
<span class="s">oncmd</span><span class="pi">:</span> <span class="s2">"</span><span class="s">/usr/bin/curl</span><span class="nv"> </span><span class="s">-X</span><span class="nv"> </span><span class="s">GET</span><span class="nv"> </span><span class="s">http://192.168.1.10/digital/4/1"</span>
|
||||
<span class="s">offcmd</span><span class="pi">:</span> <span class="s2">"</span><span class="s">/usr/bin/curl</span><span class="nv"> </span><span class="s">-X</span><span class="nv"> </span><span class="s">GET</span><span class="nv"> </span><span class="s">http://192.168.1.10/digital/4/0"</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<h3><a class="title-link" name="shutdown-your-local-host" href="#shutdown-your-local-host"></a> Shutdown your local host</h3>
|
||||
|
@ -152,49 +148,43 @@
|
|||
This switch will shutdown your host immediately, there will be no confirmation.
|
||||
</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="comment"># Example configuration.yaml entry</span>
|
||||
<span class="key">switch</span>:
|
||||
<span class="key">platform</span>: <span class="string"><span class="content">command_line</span></span>
|
||||
<span class="key">switches</span>:
|
||||
<span class="key">Home Assistant system shutdown</span>:
|
||||
<span class="key">offcmd</span>: <span class="string"><span class="delimiter">"</span><span class="content">/usr/sbin/poweroff</span><span class="delimiter">"</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="c1"># Example configuration.yaml entry</span>
|
||||
<span class="s">switch</span><span class="pi">:</span>
|
||||
<span class="s">platform</span><span class="pi">:</span> <span class="s">command_line</span>
|
||||
<span class="s">switches</span><span class="pi">:</span>
|
||||
<span class="s">Home Assistant system shutdown</span><span class="pi">:</span>
|
||||
<span class="s">offcmd</span><span class="pi">:</span> <span class="s2">"</span><span class="s">/usr/sbin/poweroff"</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<h3><a class="title-link" name="control-your-vlc-player" href="#control-your-vlc-player"></a> Control your VLC player</h3>
|
||||
|
||||
<p>This switch will control a local VLC media player (<a href="https://community.home-assistant.io/t/vlc-player/106">Source</a>).</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="comment"># Example configuration.yaml entry</span>
|
||||
<span class="key">switch</span>:
|
||||
<span class="key">platform</span>: <span class="string"><span class="content">command_line</span></span>
|
||||
<span class="key">switches</span>:
|
||||
<span class="key">VLC</span>:
|
||||
<span class="key">oncmd</span>: <span class="string"><span class="delimiter">"</span><span class="content">cvlc 1.mp3 vlc://quit &</span><span class="delimiter">"</span></span>
|
||||
<span class="key">offcmd</span>: <span class="string"><span class="delimiter">"</span><span class="content">pkill vlc</span><span class="delimiter">"</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="c1"># Example configuration.yaml entry</span>
|
||||
<span class="s">switch</span><span class="pi">:</span>
|
||||
<span class="s">platform</span><span class="pi">:</span> <span class="s">command_line</span>
|
||||
<span class="s">switches</span><span class="pi">:</span>
|
||||
<span class="s">VLC</span><span class="pi">:</span>
|
||||
<span class="s">oncmd</span><span class="pi">:</span> <span class="s2">"</span><span class="s">cvlc</span><span class="nv"> </span><span class="s">1.mp3</span><span class="nv"> </span><span class="s">vlc://quit</span><span class="nv"> </span><span class="s">&"</span>
|
||||
<span class="s">offcmd</span><span class="pi">:</span> <span class="s2">"</span><span class="s">pkill</span><span class="nv"> </span><span class="s">vlc"</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<h3><a class="title-link" name="control-foscam-motion-sensor" href="#control-foscam-motion-sensor"></a> Control Foscam Motion Sensor</h3>
|
||||
|
||||
<p>This switch will control the motion sensor of Foscam Webcams which Support CGI Commands (<a href="http://www.ipcamcontrol.net/files/Foscam%20IPCamera%20CGI%20User%20Guide-V1.0.4.pdf">Source</a>). This switch supports statecmd, which checks the current state of motion detection.</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="comment"># Example configuration.yaml entry</span>
|
||||
<span class="key">switch</span>:
|
||||
<span class="key">platform</span>: <span class="string"><span class="content">command_line</span></span>
|
||||
<span class="key">switches</span>:
|
||||
<span class="key">foscam_motion</span>:
|
||||
<span class="key">oncmd</span>: <span class="string"><span class="content">'curl -k "https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=1&usr=admin&pwd=password"'</span></span>
|
||||
<span class="key">offcmd</span>: <span class="string"><span class="content">'curl -k "https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=0&usr=admin&pwd=password"'</span></span>
|
||||
<span class="key">statecmd</span>: <span class="string"><span class="content">'curl -k --silent "https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=getMotionDetectConfig&usr=admin&pwd=password" | grep -oP "(?<=isEnable>).*?(?=</isEnable>)"'</span></span>
|
||||
<span class="key">value_template</span>: <span class="string"><span class="content">'{{ value == "1" }}'</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="c1"># Example configuration.yaml entry</span>
|
||||
<span class="s">switch</span><span class="pi">:</span>
|
||||
<span class="s">platform</span><span class="pi">:</span> <span class="s">command_line</span>
|
||||
<span class="s">switches</span><span class="pi">:</span>
|
||||
<span class="s">foscam_motion</span><span class="pi">:</span>
|
||||
<span class="s">oncmd</span><span class="pi">:</span> <span class="s1">'</span><span class="s">curl</span><span class="nv"> </span><span class="s">-k</span><span class="nv"> </span><span class="s">"https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=1&usr=admin&pwd=password"'</span>
|
||||
<span class="s">offcmd</span><span class="pi">:</span> <span class="s1">'</span><span class="s">curl</span><span class="nv"> </span><span class="s">-k</span><span class="nv"> </span><span class="s">"https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=0&usr=admin&pwd=password"'</span>
|
||||
<span class="s">statecmd</span><span class="pi">:</span> <span class="s1">'</span><span class="s">curl</span><span class="nv"> </span><span class="s">-k</span><span class="nv"> </span><span class="s">--silent</span><span class="nv"> </span><span class="s">"https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=getMotionDetectConfig&usr=admin&pwd=password"</span><span class="nv"> </span><span class="s">|</span><span class="nv"> </span><span class="s">grep</span><span class="nv"> </span><span class="s">-oP</span><span class="nv"> </span><span class="s">"(?<=isEnable>).*?(?=</isEnable>)"'</span>
|
||||
<span class="s">value_template</span><span class="pi">:</span> <span class="s1">'</span><span class="s">{{</span><span class="nv"> </span><span class="s">value</span><span class="nv"> </span><span class="s">==</span><span class="nv"> </span><span class="s">"1"</span><span class="nv"> </span><span class="s">}}'</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<ul>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue