When you are done, you will be able to create an action that will call up an image of a control page. You could have triggers that bring out different control pages.
My usage: I have one main home control page. It is a white on black floor plan of my home with all the lights, outlets, etc all over it.
For security, I have triggers that go off when motion is detected that capture a camera image and save in a desktop folder with the name “R.jpg” <- for rotation image.
When motion is detected, a 1 minute timer starts (or restarts), a camera snapshot is taken and saved as “R.jpg”. When the timer expires, another action fires to take a screenshot of my main control page and save it as “R.jpg” and restart the timer. If not motion is detected within that minute, the page is refreshed with an updated screenshot of the main control page.
Because there is a bunch of applescript making this happen, it’s a little slow… about 5 seconds between capturing the image and saving as “R.jpg.” (for the control page, the camera images are quicker) If I need a more “updated” view, the client action for the Refreshing Image URL takes me to the main control page where I can see it all live and turn on/off lights.
How I did it:
Step 1: Download / Install webkit2png www.paulhammond.org/webkit2png
This will allow you to grab a screen shot of whatever without messing with opening a browser window.
some variables you will need to be familiar with:
-T = thumbnail (you will probably want a smaller files size version of your control page to speed up the process. Default size is a little to small for my taste… so,
-s = scale. I used .3 = 30%
-D = destination (where to save the image)
-o = filename to save as. Note, it adds “Thumb” or “Full” to the end of it.
Step 2: I used script editor to make the following applescript and save as “Grab.scpt”
- Code: Select all
do shell script “/usr/local/bin/webkit2png -T -s .3 -o ISL -D ~/Desktop http://10.0.6.10/controlpage?name=ISLFloorPlanLS”
(Substitute variables where you need to in above)
Step 3: Create an action command
first part: Execute Script File (select the one you just wrote in Step 2)
second part: Execute Script (Embeded Applescript) with a 6 second delay
- Code: Select all
property outputPNGFN : "Users:williammoore:Desktop:IPCamRotate:R.jpg"
property noMotionFN : "Users:williammoore:Desktop:ISL-thumb.png"
property targetSize : 256
on run
my outputPlaceholderImage(noMotionFN)
end run
to outputPlaceholderImage(filename)
set outputFileHandle to (open for access (outputPNGFN as alias) with write permission)
try
write (read (filename as alias)) to outputFileHandle starting at 0
close access outputFileHandle
on error err_msg
close access outputFileHandle
end try
end outputPlaceholderImage
substitute variables in the first two lines to work with your file’s locations and names.
Done. Now use triggers or whatever to change out the “R.jpg” image whenever you want to and
Step 4: Set your refreshing image to:
File:///Users/williammoore/Desktop/IPCamRotate/R.jpg
I’m working with a couple folks to see if I can come up with a solution that is less applescript and more python to see I have better results. That will take me some time because I have never written a python script that has worked. If I get a working python version or something similar, I'll post it as a different working solution.