Site updated at 2016-03-12 12:36:59 UTC
This commit is contained in:
parent
cea1a5f0bf
commit
768e6db7e2
13 changed files with 237 additions and 223 deletions
|
@ -118,67 +118,81 @@
|
|||
<p>Foscam Cameras can be controlled by Home Assistant through a number of CGI commands. <br />
|
||||
The following outlines examples of the switch, services, and scripts required to move between 2 preset destinations while controlling motion detection, but many other options of movement are provided in the Foscam CGI User Guide linked above.</p>
|
||||
|
||||
<p>The <code>switch.foscam_motion</code> will control whether the motion detection is on or off. This switch supports <code>statecmd</code>, which checks the current state of motion detection.<br />
|
||||
<code>yaml
|
||||
# Replace admin and password with an "Admin" priviledged Foscam user
|
||||
# Replace ipaddress with the local IP address of your Foscam
|
||||
switch:
|
||||
platform: command_line
|
||||
switches:
|
||||
#Switch for Foscam Motion Detection
|
||||
foscam_motion:
|
||||
oncmd: 'curl -k "https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=1&usr=admin&pwd=password"'
|
||||
offcmd: 'curl -k "https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=0&usr=admin&pwd=password"'
|
||||
statecmd: 'curl -k --silent "https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=getMotionDetectConfig&usr=admin&pwd=password" | grep -oP "(?<=isEnable>).*?(?=</isEnable>)"'
|
||||
value_template: ''
|
||||
</code></p>
|
||||
<p>The <code>switch.foscam_motion</code> will control whether the motion detection is on or off. This switch supports <code>statecmd</code>, which checks the current state of motion detection.</p>
|
||||
|
||||
<p>The service <code>shell_command.foscam_turn_off</code> sets the camera to point down and away to indicate it is not recording, and <code>shell_command.foscam_turn_on</code> sets the camera to point where I’d like to record. h of these services require preset points to be added to your camera. See source above for additional information.<br />
|
||||
<code>yaml
|
||||
shell_command:
|
||||
#Created a preset point in Foscam Web Interface named Off which essentially points the camera down and away
|
||||
foscam_turn_off: 'curl -k "https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=Off&usr=admin&pwd=password"'
|
||||
#Created a preset point in Foscam Web Interface named Main which points in the direction I would like to record
|
||||
foscam_turn_on: 'curl -k "https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=Main&usr=admin&pwd=password"'
|
||||
</code><br />
|
||||
The <code>script.foscam_off</code> and <code>script.foscam_on</code> can be used to set the motion detection appropriately, and then move the camera. These scripts can be called as part of an automation with <code>device_tracker</code> triggers to set <code>home</code> and <code>not_home</code> modes for your Foscam and disable motion detection recording while <code>home</code>.<br />
|
||||
<code>yaml
|
||||
script:
|
||||
foscam_off:
|
||||
sequence:
|
||||
- execute_service: switch.turn_off
|
||||
service_data:
|
||||
entity_id: switch.foscam_motion
|
||||
- service: shell_command.foscam_turn_off
|
||||
foscam_on:
|
||||
sequence:
|
||||
- execute_service: switch.turn_off
|
||||
service_data:
|
||||
entity_id: switch.foscam_motion
|
||||
- service: shell_command.foscam_turn_on
|
||||
- execute_service: switch.turn_on
|
||||
service_data:
|
||||
entity_id: switch.foscam_motion
|
||||
</code></p>
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="comment"># Replace admin and password with an "Admin" priviledged Foscam user</span>
|
||||
<span class="comment"># Replace ipaddress with the local IP address of your Foscam</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="comment">#Switch for Foscam Motion Detection</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">''</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>The service <code>shell_command.foscam_turn_off</code> sets the camera to point down and away to indicate it is not recording, and <code>shell_command.foscam_turn_on</code> sets the camera to point where I’d like to record. h of these services require preset points to be added to your camera. See source above for additional information.</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">shell_command</span>:
|
||||
<span class="comment">#Created a preset point in Foscam Web Interface named Off which essentially points the camera down and away</span>
|
||||
<span class="key">foscam_turn_off</span>: <span class="string"><span class="content">'curl -k "https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=Off&usr=admin&pwd=password"'</span></span>
|
||||
<span class="comment">#Created a preset point in Foscam Web Interface named Main which points in the direction I would like to record</span>
|
||||
<span class="key">foscam_turn_on</span>: <span class="string"><span class="content">'curl -k "https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=Main&usr=admin&pwd=password"'</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>The <code>script.foscam_off</code> and <code>script.foscam_on</code> can be used to set the motion detection appropriately, and then move the camera. These scripts can be called as part of an automation with <code>device_tracker</code> triggers to set <code>home</code> and <code>not_home</code> modes for your Foscam and disable motion detection recording while <code>home</code>.</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">script</span>:
|
||||
<span class="key">foscam_off</span>:
|
||||
<span class="key">sequence</span>:
|
||||
- <span class="string"><span class="content">execute_service: switch.turn_off</span></span>
|
||||
<span class="key">service_data</span>:
|
||||
<span class="key">entity_id</span>: <span class="string"><span class="content">switch.foscam_motion</span></span>
|
||||
- <span class="string"><span class="content">service: shell_command.foscam_turn_off</span></span>
|
||||
<span class="key">foscam_on</span>:
|
||||
<span class="key">sequence</span>:
|
||||
- <span class="string"><span class="content">execute_service: switch.turn_off</span></span>
|
||||
<span class="key">service_data</span>:
|
||||
<span class="key">entity_id</span>: <span class="string"><span class="content">switch.foscam_motion</span></span>
|
||||
- <span class="string"><span class="content">service: shell_command.foscam_turn_on</span></span>
|
||||
- <span class="string"><span class="content">execute_service: switch.turn_on</span></span>
|
||||
<span class="key">service_data</span>:
|
||||
<span class="key">entity_id</span>: <span class="string"><span class="content">switch.foscam_motion</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>To automate Foscam being set to “on” (facing the correct way with motion sensor on), I used the following simple automation:</p>
|
||||
|
||||
<p>```yaml<br />
|
||||
automation:<br />
|
||||
- alias: Set Foscam to Away Mode when I leave home<br />
|
||||
trigger:<br />
|
||||
platform: state<br />
|
||||
entity_id: group.family<br />
|
||||
from: ‘home’<br />
|
||||
action:<br />
|
||||
service: script.foscam_on<br />
|
||||
- alias: Set Foscam to Home Mode when I arrive Home<br />
|
||||
trigger:<br />
|
||||
platform: state<br />
|
||||
entity_id: group.family<br />
|
||||
to: ‘home’<br />
|
||||
action:<br />
|
||||
service: script.foscam_off</p>
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">automation</span>:
|
||||
- <span class="string"><span class="content">alias: Set Foscam to Away Mode when I leave home</span></span>
|
||||
<span class="key">trigger</span>:
|
||||
<span class="key">platform</span>: <span class="string"><span class="content">state</span></span>
|
||||
<span class="key">entity_id</span>: <span class="string"><span class="content">group.family</span></span>
|
||||
<span class="key">from</span>: <span class="string"><span class="content">'home'</span></span>
|
||||
<span class="key">action</span>:
|
||||
<span class="key">service</span>: <span class="string"><span class="content">script.foscam_on</span></span>
|
||||
- <span class="string"><span class="content">alias: Set Foscam to Home Mode when I arrive Home</span></span>
|
||||
<span class="key">trigger</span>:
|
||||
<span class="key">platform</span>: <span class="string"><span class="content">state</span></span>
|
||||
<span class="key">entity_id</span>: <span class="string"><span class="content">group.family</span></span>
|
||||
<span class="key">to</span>: <span class="string"><span class="content">'home'</span></span>
|
||||
<span class="key">action</span>:
|
||||
<span class="key">service</span>: <span class="string"><span class="content">script.foscam_off</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue