{"id":451,"date":"2019-02-11T17:48:14","date_gmt":"2019-02-11T16:48:14","guid":{"rendered":"https:\/\/www.spagnasoft.net\/?p=451"},"modified":"2019-02-12T10:34:12","modified_gmt":"2019-02-12T09:34:12","slug":"synology-surveillance-station-home-mode-when-specific-devices-are-shown","status":"publish","type":"post","link":"https:\/\/www.spagnasoft.net\/?p=451","title":{"rendered":"Synology &#8211; Surveillance Station \/ Home Mode when specific devices are shown"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Script that trigger HOME MODE when a device Arrive in LAN.<br \/><br \/><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With the help of Ricky and a this <a href=\"https:\/\/forum.synology.com\/enu\/viewtopic.php?t=88555\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"link (opens in a new tab)\">link<\/a><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>###to unstall nmap<br \/> ###sudo -s<br \/> ###synogear install<br \/> Functions<br \/> ###Check HTTP Response<br \/> function _cleanupCookies ()<br \/> {<br \/>  rm $COOKIESFILE<br \/> }<br \/> function _checkSynoResponse ()<br \/> {<br \/>   if [ $1 != &#8216;{&#8220;success&#8221;:true}&#8217; ]<br \/>   then<br \/>         echo &#8220;$2 failed: &#8220;$RESPONSE<br \/>         _cleanupCookies<br \/>         exit -1<br \/>   fi<br \/> }<br \/> homemode=false;<br \/> currenttime=$(date +%H)<br \/> currenttime=<code>echo $currenttime|sed 's\/^0*\/\/'<\/code><br \/> echo &#8220;Current time: $currenttime&#8221;;<br \/> if  [[ &#8220;$currenttime&#8221; -lt 6 ]]; then<br \/>      echo &#8220;Never in home mode&#8221;;<br \/> ### in this section is to exit form home mode in the night 00:00 &#8211;> 06:00<br \/> else<br \/> ### in this section is to set or not home mode based on device presence<br \/> <code>echo \"Check Devicies\"; for MAC in `\/var\/packages\/DiagnosisTool\/target\/tool\/nmap -sn 192.168.1.0\/24 2> \/dev\/null | grep MAC | awk '{print $3}'`;  do       echo \"Found $MAC\";      case $MAC in           \"XX:XX:XX:XX:XX:XX\"|\"YY:YY:YY:YY:YY:YY\")         homemode=true;         echo \" Found $MAC Listed, SET home mode to  $homemode\";             esac  done <\/code><br \/> fi<br \/> echo &#8220;End of Tests,  reslt home mode = $homemode&#8221;;<br \/> SYNO_SS_USER=&#8221;APIUSERTEST&#8221;<br \/> SYNO_SS_PASS=&#8221;xxxxxxx&#8221;<br \/> SYNO_URL=&#8221;localhost:5000&#8243;<br \/> SYNO_CAMERAIDS=&#8221;1&#8243;<br \/> ### Internal variables<br \/> COOKIESFILE=&#8221;$0-cookies-$ID&#8221;<br \/> ID=&#8221;$RANDOM&#8221;<br \/> # 1.step login<br \/> VER=&#8221;1&#8243;<br \/> METHOD=&#8221;Login&#8221;<br \/> echo &#8220;http:\/\/${SYNO_URL}\/webapi\/auth.cgi?api=SYNO.API.Auth&amp;method=${METHOD}&amp;version=${VER}&amp;account=${SYNO_SS_USER}&amp;passwd=${SYNO_SS_PASS}&amp;session=SurveillanceStation&#8221; <br \/> RESPONSE=<code>wget -q --keep-session-cookies --save-cookies $COOKIESFILE -O- \"http:\/\/${SYNO_URL}\/webapi\/auth.cgi?api=SYNO.API.Auth&amp;method=${METHOD}&amp;version=${VER}&amp;account=${SYNO_SS_USER}&amp;passwd=${SYNO_SS_PASS}&amp;session=SurveillanceStation\"<\/code><br \/> _checkSynoResponse $RESPONSE $METHOD; <br \/> echo  &#8220;repo= $RESPONSE Meth = $METHOD&#8221;;<br \/> ## 2.Set Home Mode<br \/> echo &#8220;http:\/\/${SYNO_URL}\/webapi\/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&amp;version=1&amp;method=Switch&amp;on=${homemode}&#8221;<br \/> RESPONSE=<code>wget -q --load-cookies $COOKIESFILE -O- \"http:\/\/${SYNO_URL}\/webapi\/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&amp;version=1&amp;method=Switch&amp;on=${homemode}\"<\/code><br \/> _checkSynoResponse $RESPONSE $METHOD;<br \/> echo  &#8220;repo= $RESPONSE&#8221;;<br \/> ## 3.step logout<br \/> VER=1<br \/> METHOD=&#8221;Logout&#8221;<br \/> echo &#8220;http:\/\/${SYNO_URL}\/webapi\/auth.cgi?api=SYNO.API.Auth&amp;method=$METHOD&amp;version=${VER}&#8221;<br \/> RESPONSE=<code>wget -q --load-cookies $COOKIESFILE -O- \"http:\/\/${SYNO_URL}\/webapi\/auth.cgi?api=SYNO.API.Auth&amp;method=$METHOD&amp;version=${VER}\"<\/code><br \/> _checkSynoResponse $RESPONSE $METHOD;<br \/>  echo  &#8220;repo= $RESPONSE Meth = $METHOD&#8221;;<br \/> Cleanup<br \/> _cleanupCookies<br \/> exit<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Script that trigger HOME MODE when a device Arrive in LAN.<\/p>\n","protected":false},"author":1,"featured_media":456,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[60],"class_list":["post-451","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-pensiero","tag-survelliance-station"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.spagnasoft.net\/wp-content\/uploads\/2019\/02\/512px-CCTV_surveillance_camera.svg_.png","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":568,"url":"https:\/\/www.spagnasoft.net\/?p=568","url_meta":{"origin":451,"position":0},"title":"Microsoft vuole fare Apple (Think Different)","author":"Spagna","date":"25 Novembre 2022","format":false,"excerpt":"Il fantomatico WIP (Windows Information Protection) quindi ci saluter\u00e0, almeno su Intune che \u00e8 lo strumento aziendale per la gestione dei device, ed al suo posto arriva PurView. Leggendo, guardando il nuovo prodotto ha molte funzioni ed estensioni interessanti, alcune a pagamento. Analizzando per\u00f2 la questione noto che non c'\u00e8\u2026","rel":"","context":"In &quot;Pensiero&quot;","block_context":{"text":"Pensiero","link":"https:\/\/www.spagnasoft.net\/?cat=1"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.spagnasoft.net\/wp-content\/uploads\/2022\/11\/windows-information-protection-logo.webp?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.spagnasoft.net\/wp-content\/uploads\/2022\/11\/windows-information-protection-logo.webp?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.spagnasoft.net\/wp-content\/uploads\/2022\/11\/windows-information-protection-logo.webp?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.spagnasoft.net\/wp-content\/uploads\/2022\/11\/windows-information-protection-logo.webp?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":383,"url":"https:\/\/www.spagnasoft.net\/?p=383","url_meta":{"origin":451,"position":1},"title":"Good covers","author":"Spagna","date":"2 Maggio 2016","format":false,"excerpt":"Una lista (in aggiornamento continuo) di cover che rendono merito all'originale.. che ogni tanto sono addirittura meglio!","rel":"","context":"In &quot;musica&quot;","block_context":{"text":"musica","link":"https:\/\/www.spagnasoft.net\/?cat=3"},"img":{"alt_text":"vinyl","src":"https:\/\/i0.wp.com\/www.spagnasoft.net\/wp-content\/uploads\/2016\/05\/vinyl-698897_960_7201.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.spagnasoft.net\/wp-content\/uploads\/2016\/05\/vinyl-698897_960_7201.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.spagnasoft.net\/wp-content\/uploads\/2016\/05\/vinyl-698897_960_7201.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.spagnasoft.net\/wp-content\/uploads\/2016\/05\/vinyl-698897_960_7201.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":533,"url":"https:\/\/www.spagnasoft.net\/?p=533","url_meta":{"origin":451,"position":2},"title":"Alexa e le funzioni mancanti","author":"Spagna","date":"3 Marzo 2022","format":false,"excerpt":"Il prodotto di Amazon ha diverse funzioni mancanti in Europa e soprattutto in Italia. Alcune sono legate alla questione \"lingua\", altre invece sono semplicemente mancanti.","rel":"","context":"In &quot;Pensiero&quot;","block_context":{"text":"Pensiero","link":"https:\/\/www.spagnasoft.net\/?cat=1"},"img":{"alt_text":"Alexa Icon","src":"https:\/\/i0.wp.com\/www.spagnasoft.net\/wp-content\/uploads\/2022\/03\/amazon-alexa.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_shortlink":"https:\/\/wp.me\/p6mc1T-7h","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.spagnasoft.net\/index.php?rest_route=\/wp\/v2\/posts\/451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.spagnasoft.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.spagnasoft.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.spagnasoft.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.spagnasoft.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=451"}],"version-history":[{"count":0,"href":"https:\/\/www.spagnasoft.net\/index.php?rest_route=\/wp\/v2\/posts\/451\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.spagnasoft.net\/index.php?rest_route=\/wp\/v2\/media\/456"}],"wp:attachment":[{"href":"https:\/\/www.spagnasoft.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.spagnasoft.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.spagnasoft.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}