Author Topic: Great Product...hints for Mac Users for remote control  (Read 2302 times)

brandtb

  • Newbie
  • *
  • Posts: 4
    • View Profile
Great Product...hints for Mac Users for remote control
« on: March 30, 2011, 12:51:28 PM »
First, and foremost -- this is a very cool product.  With various tidbits from this forum and around the web, I have been able to do some other cool things that other users may find useful.

There is a way to remotely start and stop iCamSource, and I have found a way to do it from a webpage, email, or my phone.  I have two Macs with iCamSource and can start and stop it on demand.

First, a little background:

I have a Home Automation server running Indigo from Perceptive Automation (http://www.perceptiveautomation.com/).  With this, I can send emails to a certain email address in my home domain that Indigo reads, interprets the subject line, then issues a command.

Up to now, it has been limited to on/off commands for various lights throughout the house.  If I am coming home extra late and want to turn the light over my garage, I send an email with a certain subject and the light is on and waiting for me when I get home.

Required items:

Indigo by Perceptive Automation can do this or Apple Mail should be able to do this with a rule properly set up.

A Mac with Remote Apple Events allowed from the Sharing section of System Preferences.  All Macs receiving commands must have this set up.

A email account created specifically for the purpose.  Easy to do if you have your own domain and can create email accounts on demand.  Many ISP's also allow you to create your own mailboxes with specific addresses.

A little bit of Applescript.

Setup:

Code: [Select]
startCam.scpt

tell application "Finder" of machine "eppc://<your internal ip address>"
    open file "Macintosh HD:Applications:iCamSource.app
end tell
...
(repeat for every Mac running iCamSource using the applicable ip address for that machine).

Code: [Select]
stopCam.scpt

tell application "iCamSource" of machine "eppc://<your internal ip address>"
   quit
end tell
...
(repeat for every Mac running iCamSource using the applicable ip address).

where:  <your internal ip address> is the address given to that machine by your router's DHCP server.

When you run these, you'll likely have to authenticate.  Be sure to save this info in your keychain.

In Indigo, I set up an email trigger that looks for the subject line "StartCams".  When it gets that, it executes the startCams.scpt from whatever folder I saved it in.  A second trigger is set for an email with the subject line "StopCams", executing the other script.  I have Indigo set to fetch email every few minutes from the account in question.

In Apple Mail, you'll set up a Rule (Preferences->Rules).  It would go something like this:

Code: [Select]
If (all) of the following conditions are met:

Subject (is equal to) StartCam

Optionally, you'll want to see if it is coming to a specific address.

Perform the following actions:

(Run Applescript) and use the dialog to point to the script as written above.

Stop evaluating more rules.  Optionally, you can delete the email as well.  

A separate rule is created to stop the cameras using the same formula as above.

Now, you send an email to the address in question with the correct subject line, and voila!  You now can control iCamSource remotely!

Next installment:  How to use the above infrastructure from a webpage.

Good luck!






« Last Edit: March 30, 2011, 03:09:58 PM by brandtb »

brandtb

  • Newbie
  • *
  • Posts: 4
    • View Profile
How to Remotely Control iCamSource from a web page
« Reply #1 on: March 30, 2011, 01:08:43 PM »
Using the setup in the previous post, you can also set up a web page that controls iCamSource.

This is for web and HTML-savvy folks, so noobs beware.  Enterprising Noobs can do it, but you might not have access to the tools necessary.

The further setup:

An HTML form that contains selectors/radio buttons that have the correct subject line text as the value.

The form must point to an action that can take the results from the form and construct an email to the correct address with the subject line that comes over as the value from the submitted form.

I use Active Server Pages (my site has been around for a while and it ain't broke, so I ain't fixin' it).  

The HTML form looks like this:
Code: [Select]
haForm.asp

<html>
<body>
<form action="ha.asp" method="post" name="haForm">
  <h3>Select Action:  </h3>
  <br/>
            <p><input name="HAaction" type="radio" value="FR On" />
        Family Room (Table) On<br/>
  <input name="HAaction" type="radio" value="StartCam"/>
        Start Cameras
  <input name="HAaction" type="radio" value="StopCam" />
        Stop Cameras<br/></p
   <p>
    <input type="submit" name="Submit" value="Execute Action" />
  </p>
</form>
</body>
</html>

The code for the form action looks like this (I have named mine "ha.asp"):

Code: [Select]
ha.asp

<%
response.Buffer = true

'response.write(request.form("HAaction"))
haAction = request.form("HAaction")
'response.End()
'Sending a text email
Set objMessage = Server.CreateObject("CDO.Message")
objMessage.Subject = haAction
objMessage.From = "nobody@<yourdomain.com>"
objMessage.To = "<your email account>@<yourdomain.com>"
objMessage.TextBody = "bogus message text"
objMessage.Send

response.write("Command sent:  " & haAction)
%>

Note that the To: address should be the email account you set up for this purpose in the previous post.  The From: address can be anything you want.  The code is also stripped down to the essentials.  Embellish to your heart's content.

Similar methods are available in your scripting language of choice (PHP, JSP, etc), I'm sure.  Google will reveal all...

Now, call up your webpage with the form, select the radio box in question and click submit.  An email is sent to the correct address and the setup in the previous post should be able to interpret it and execute the desired command.

Next:  Using this form from your Android phone to control iCamSource
« Last Edit: March 30, 2011, 01:36:29 PM by brandtb »

brandtb

  • Newbie
  • *
  • Posts: 4
    • View Profile
Starting/Stopping iCamSource from your Android phone
« Reply #2 on: March 30, 2011, 01:34:13 PM »
Warning:  You must have completed the steps in the prior two posts and they must be working.  This is not totally beyond a noob, but it ain't trivial, either.  Proceed with care.  

Okay, so you've set up the email account and remote commands in the first post.  Then, you set up a webpage to construct and send those emails from an HTML form.  

Both of the previous steps are required in order to do this using my method.  Other methods likely exist, but I'm only going to discuss the one I use.

Requirements:

Setup of items in the first and second posts is complete and working.

An Android phone running Tasker (http://tasker.dinglisch.net/), available from the Android App store for roughly $6.25 to $6.50 depending on the exchange rate.  Tasker does a lot of Very Cool stuff on top of this, but you can go to their site to check it out.

On your Android phone, start Tasker and tap the Tasks button at the bottom.

Create a new task. Tap the New button at the top right and give the task a name like "Control Cams".

At the bottom left, tap the "+" button to create a new item.

Select the Action Category "Net".

Select Net Action "HTTP Post"

In the resulting dialog:

Server/port:  <your domain.com>

(No http:// is required, just the domain name)

Path:  ha.asp

(assuming ha.asp (see previous post) or your form processor of choice resides in the top level folder on your site, otherwise fully-qualify the path)

Data:  HAaction=StartCam

(remember how we set the value for the radio box in the form?  This must match that value.)

Label:  Start Cams

Tap Done to save.

Repeat for stopping the cams, using this for your data field:

Data:  HAaction=StopCam

Label:  Stop Cams

At the bottom right, just above the Test button, tap on the icon and select an icon for this task.

You also need to tap the button with the crossed screwdriver and wrench (Tools).  This brings up the Task Properties dialog.  Select "Menu" for your Task Type and tap Done at the bottom.

Tap Done when you are finished.  

You should now have two commands under a named task.

Leave Tasker and go back to the Android home screen where you want to place the widget to execute the commands.

Long-press the screen.  Select Widgets.  Scroll down and select Task (note the tasker icon next to it).

Select the desired task from the pull-down in Tasker.  Earlier, we called it "Control Cams".

Tap the Make Widget button at the bottom.  If you didn't select an icon before, you will need to do so now before making the widget.

A new widget should appear.  Tap on it and you will be presented with the two tasks you created.  Tap on the desired task and weave your magic!

I know this is kind of sparse, but experienced users should have enough to go on to make this work.  Good luck to all who try this.




« Last Edit: March 30, 2011, 02:11:06 PM by brandtb »

SKJM Support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1917
    • View Profile
Re: Great Product...hints for Mac Users for remote control
« Reply #3 on: March 30, 2011, 04:21:09 PM »
Wow! Thank you for that great (and informative) post.  ;D