How To Smart Home: A Step by Step Guide to Your Personal Internet of Things
Author:Othmar Kyas
Language: eng
Format: mobi
Tags: Computers & Technology
Publisher: Key Concept Press
Published: 2015-03-28T22:00:00+00:00
Later, we will add the above scripts as commands to OpenRemote Designer, using the shell execution protocol. Since we will also display the track iTunes is currently playing, we need one more AppleScript based shell script, which determines if iTunes is playing, and, if this is the case, writes the result to the variable state:
state=`osascript -e 'tell application "iTunes" to player state as string'`;
If the variable state is set to playing we write current artist and track to the variables artist and track:
artist=`osascript -e 'tell application "iTunes" to artist of current track as string'`;
track=`osascript -e 'tell application "iTunes" to name of current track as string'`;
We design the script with the log file for the result to be provided as an argument. So if iTunes is playing, track and artist are written to the file specified as shell argument. Since we plan to use an html file as log, which shall be displayed by the OpenRemote web server, the files location shall again be in the web server root directory:
/ORC/webapps/controller
With that our script iTunesPlaying.sh reads to:
#!/bin/sh
#Retrieves currently played title from iTunes and writes to logfile - last entry will be overwritten
if [[ $# -lt 1 || $# -gt 1 ]];then
echo "$0: Argument error: playing.sh [log file]"
exit 2
fi
state=`osascript -e 'tell application "iTunes" to player state as string'`;
echo "iTunes is currently $state.";
if [ $state = "playing" ]; then
artist=`osascript -e 'tell application "iTunes" to artist of current track as string'`;
track=`osascript -e 'tell application "iTunes" to name of current track as string'`;
echo "Current track $artist: $track" > /Users/smarthome/shProject/ORC/webapps/controller/$1;
else
echo "iTunes is currently $state." > /Users/smarthome/shProject/ORC/webapps/controller/$1;
fi
To test we start an iTunes playlist and type
iTunesPlaying.sh playing.html
in the terminal window. If we now open the URL
http://localhost:8080/controller/playing.html
in a web browser, we should see a display of the playlist. We now can configure all scripts as commands in OpenRemote Designer. (Section 8.3)
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
AI & Machine Learning | Bioinformatics |
Computer Simulation | Cybernetics |
Human-Computer Interaction | Information Theory |
Robotics | Systems Analysis & Design |
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8303)
Test-Driven Development with Java by Alan Mellor(6739)
Data Augmentation with Python by Duc Haba(6657)
Principles of Data Fabric by Sonia Mezzetta(6408)
Learn Blender Simulations the Right Way by Stephen Pearson(6303)
Microservices with Spring Boot 3 and Spring Cloud by Magnus Larsson(6177)
Hadoop in Practice by Alex Holmes(5961)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5809)
RPA Solution Architect's Handbook by Sachin Sahgal(5573)
Big Data Analysis with Python by Ivan Marin(5372)
The Infinite Retina by Robert Scoble Irena Cronin(5264)
Life 3.0: Being Human in the Age of Artificial Intelligence by Tegmark Max(5152)
Pretrain Vision and Large Language Models in Python by Emily Webber(4337)
Infrastructure as Code for Beginners by Russ McKendrick(4099)
Functional Programming in JavaScript by Mantyla Dan(4040)
The Age of Surveillance Capitalism by Shoshana Zuboff(3959)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3812)
Embracing Microservices Design by Ovais Mehboob Ahmed Khan Nabil Siddiqui and Timothy Oleson(3615)
Applied Machine Learning for Healthcare and Life Sciences Using AWS by Ujjwal Ratan(3589)
