tailieunhanh - Smart Home Automation with Linux- P20

Smart Home Automation with Linux- P20:I will end on a note of carefree abandon—learn to steal! Once you’ve learned the pieces of the puzzle and how to combine them, there is very little new to invent. Every new idea you discover is a mere permutation of the old ideas. And ideas are free! Every cool feature discussed on TV shows or presented in the brochures or web sites of commercial HA companies can be taken, adapted, and implemented with the information presented here using very little effort | CHAPTER 5 COMMUNICATION Finally remember that most system commands are blocking. That is they don t return until they ve finished their task. So when the task is being called from inside a web page the user will be at a blank web page with the waiting cursor until the page has completed. Consequently any output or error codes from the command cannot be shown on the page. Instead you will have to write your software so that Your command executes asynchronously using shell_exec cmd or similar. You can update the error or output status through Ajax. You can retrieve error states through a secondary command issued after an asynchronously command invocation. None of these are unsolved problems but it is an extra layer of complexity for those wanting to write their own home automation web applications. Media Access One common piece of functionality is to provide access to your music collection from outside home such as from the office. Several Apache modules are available to handle this one of them is mod_musicindex http projects musicindex . Although capable of being used to list general-purpose directories as it does for its own online documentation it is capable of rendering music-specific icons to let you download and or stream this music anywhere in the world and create playlists interactively for the current folder and all the subdirectories underneath it. To prepare an online portal for your music first create a directory inside your web directory mkdir music Then create an . htaccess file inside granting permissions to whichever users you see fit. These permissions apply to this directory and every one underneath it unless superseded by another .htaccess file. Since your music collection is likely to be stored outside of the web root you must add a symlink to it In -s net media mp3 mp3 This also highlights the reason you created a separate media directory in the root it eliminates the need for web-specific files polluting the directory structure of