{"id":228,"date":"2018-11-16T03:06:03","date_gmt":"2018-11-16T09:06:03","guid":{"rendered":"https:\/\/www.fayearchip.name\/?p=228"},"modified":"2018-11-27T01:16:31","modified_gmt":"2018-11-27T07:16:31","slug":"lighting-system-automation","status":"publish","type":"post","link":"https:\/\/www.fayebell.name\/?p=228","title":{"rendered":"Lighting. System automation."},"content":{"rendered":"\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"311\" src=\"https:\/\/i0.wp.com\/www.fayearchip.name\/wp-content\/uploads\/2018\/11\/20181115_180710-1024x498.jpg?resize=640%2C311&#038;ssl=1\" alt=\"\" class=\"wp-image-262\" srcset=\"https:\/\/i0.wp.com\/www.fayebell.name\/wp-content\/uploads\/2018\/11\/20181115_180710.jpg?resize=1024%2C498&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.fayebell.name\/wp-content\/uploads\/2018\/11\/20181115_180710.jpg?resize=300%2C146&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.fayebell.name\/wp-content\/uploads\/2018\/11\/20181115_180710.jpg?resize=768%2C373&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.fayebell.name\/wp-content\/uploads\/2018\/11\/20181115_180710.jpg?w=1280&amp;ssl=1 1280w, https:\/\/i0.wp.com\/www.fayebell.name\/wp-content\/uploads\/2018\/11\/20181115_180710.jpg?w=1920&amp;ssl=1 1920w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><figcaption>Just playing with lights.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">So how do you tie the following together? turning on non-dim set lights. Sending power to DMX controlled lights that can go in to &#8220;disco mode&#8221;. Controlling a few cues on a light console. Then Of Course&#8230;.. make it easy for anyone to start and stop the system?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The answer is Automation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This Blog Post will be touching on how I solved this problem off a &#8220;simple on\/off switch&#8221; for this complex system.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Part One:<\/strong>&nbsp;What was the scope of this sub-project?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This system Must, make it where the end user can Start Up and Shutdown(safe) the lighting system. this control system shall be accessible from any network.&nbsp; To allow any device to start or safe it via a Website.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The website Must be secured. The only options shall, use two links. &#8220;OFF and ON&#8221;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Part Two:<\/strong>&nbsp; Old Implementation<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.fayearchip.name\/wp-content\/uploads\/2018\/11\/9999-1024x193.png?resize=640%2C120&#038;ssl=1\" alt=\"\" class=\"wp-image-252\" width=\"640\" height=\"120\" srcset=\"https:\/\/i0.wp.com\/www.fayebell.name\/wp-content\/uploads\/2018\/11\/9999.png?resize=1024%2C193&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.fayebell.name\/wp-content\/uploads\/2018\/11\/9999.png?resize=300%2C57&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.fayebell.name\/wp-content\/uploads\/2018\/11\/9999.png?resize=768%2C145&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.fayebell.name\/wp-content\/uploads\/2018\/11\/9999.png?w=1096&amp;ssl=1 1096w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><figcaption>Asterisk dial plan showing opt 9999 and 0000<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Back when I started work on this to be controlled by my PBX, with&nbsp; the 6602 extension. The end user would call the 6602 extension and press a option. then the following would happen. (when turning it on)&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The <a href=\"https:\/\/en.wikipedia.org\/wiki\/Expect\">TCL Expect scripting language<\/a> is used to tell the Network PDUs to turn on and off stuff.<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>Hard coded DMX values being sent via OLA daemon over network to a DMXking eDMX4 to get the DMX to the lights to set the color.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The main issue I had with this setup, I could not dynamically control the system.&nbsp; Also you had to be on my PBX, or white listed to be redirected when you dial in to my home phone line.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Part Three:<\/strong>&nbsp; Current Implementation<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With those known limitations, I decided to do something about it Implement the scope of work in Part on<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Webserver to Austin VMs.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I have a hub and spoke VPN infrastructure all ready in place. Lets look at the Hub.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"326\" src=\"https:\/\/i0.wp.com\/www.fayearchip.name\/wp-content\/uploads\/2018\/11\/OVH-1024x521.png?resize=640%2C326&#038;ssl=1\" alt=\"\" class=\"wp-image-253\" srcset=\"https:\/\/i0.wp.com\/www.fayebell.name\/wp-content\/uploads\/2018\/11\/OVH.png?resize=1024%2C521&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.fayebell.name\/wp-content\/uploads\/2018\/11\/OVH.png?resize=300%2C153&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.fayebell.name\/wp-content\/uploads\/2018\/11\/OVH.png?resize=768%2C391&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.fayebell.name\/wp-content\/uploads\/2018\/11\/OVH.png?w=1298&amp;ssl=1 1298w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><figcaption>Censored key details. (security through obscurity )&nbsp;<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This Pfsense vm links using OpenVPN to a few sites. but most importantly it links to my apartment.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With that link I can remotely call commands over SSH to turn on&nbsp; and off the system, from the web server.&nbsp; then It is just a matter of calling a shell command to kick off a Shell script on the Austin utility VM.<\/p>\n\n\n\n<code>$output = shell_exec(\"\/usr\/bin\/ssh www-server@aus-netbox PROD-GO\");&lt;br&gt;echo $output;&lt;br&gt;<\/code>\n\n\n\n<p class=\"wp-block-paragraph\">Above is the PHP code for turning on the system.&nbsp; the off code is 99% the same.&nbsp; Its secured with a username and password.&nbsp; Looking at the aus-netbox host, the system is running a bunch of different Expect scripts.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Turn on outlets on the PDUs&nbsp;<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>Tell LightFactory to go to a standby cue. over its telnet connection.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Let us look at the integration via expect and and LightFactory&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"502\" src=\"https:\/\/i0.wp.com\/www.fayearchip.name\/wp-content\/uploads\/2018\/11\/lb.png?resize=640%2C502&#038;ssl=1\" alt=\"\" class=\"wp-image-259\" srcset=\"https:\/\/i0.wp.com\/www.fayebell.name\/wp-content\/uploads\/2018\/11\/lb.png?w=664&amp;ssl=1 664w, https:\/\/i0.wp.com\/www.fayebell.name\/wp-content\/uploads\/2018\/11\/lb.png?resize=300%2C235&amp;ssl=1 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><figcaption>Expect script to go in to cue 8888<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;First we say log all output to the shell&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">the &#8220;set timeout 20&#8221; is <strong>Very Important.<\/strong> as it helps keep the telnet session from hanging. all it means is this, &#8220;If I don&#8217;t get input from the I\/\/O stream bail out&#8221;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">spawn says what we are running and redirecting I\/O from.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then its expect &#8220;foo&#8221; and send &#8220;bar&#8221;. its pretty simple&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To touch on the Light Factory commands.&nbsp; sc31 is a shortcut macro (I created) to release all channels. and cue&nbsp; line calls the cue from the cue list serah #8888 .&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then it exits.&nbsp; Now Serah can then control the system via the LightFactory Myinterface app. As long as she is on the right WiFi Network.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Shutdown is similar to what was explained.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So how do you tie the following together? turning on non-dim set lights. Sending power to DMX controlled lights that can go in to &#8220;disco mode&#8221;. Controlling a few cues on a light console. Then Of Course&#8230;.. make it easy &hellip; <a href=\"https:\/\/www.fayebell.name\/?p=228\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":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":[10],"tags":[15,14],"class_list":["post-228","post","type-post","status-publish","format-standard","hentry","category-lighting","tag-automation","tag-lightfactory"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pa1ntP-3G","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.fayebell.name\/index.php?rest_route=\/wp\/v2\/posts\/228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fayebell.name\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fayebell.name\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fayebell.name\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fayebell.name\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=228"}],"version-history":[{"count":19,"href":"https:\/\/www.fayebell.name\/index.php?rest_route=\/wp\/v2\/posts\/228\/revisions"}],"predecessor-version":[{"id":268,"href":"https:\/\/www.fayebell.name\/index.php?rest_route=\/wp\/v2\/posts\/228\/revisions\/268"}],"wp:attachment":[{"href":"https:\/\/www.fayebell.name\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fayebell.name\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fayebell.name\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}