Ambient Orb Newbie Help!

Hello all,

I am completly new to programming and scripting... so my needs are very basic. I have a Ambient orb made by Ambient devices and I am hoping to get it connected to my own data.

I found this site through ambient411.com and a post that makes mention of using your software to scrape a number/value from a website and push out a http string that changes the color of the orb. This is all fairly simple, but when you are lost at the first sign of code all you can do is call out for a bit of help.

If anyone here could help me get started I would be very appreciative!

Here is a page that describes how to change the color of the orb:
https://myambient.com/java/my_devices/developer_guide.jsp

Appreciative,
Nathan

Ambient Orb Newbie Help!

Hi, I'll look at this in the morning.. I do knot have the session here.. I had this error for a while as well.. I wonder what step or setting I forgot to pass along .. oh well good luck, talk soon.
Fred

Fred Rocks!

Fred,

This was a really enjoyable "crash course"

Your walk through is very well written. Everything worked up till the "pushToDevice" part. The last response tab contained this:

HTTP/1.1 200 OK
Date: Wed, 05 Apr 2006 22:19:12 GMT
Server: Apache Coyote/1.0
Set-Cookie: JSESSIONID=EAAFD47BC1BA94D7D44BACE2A9553948; Path=/
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 521

<?xml version="1.0"?>


'color' term not defined. Must be number between 0 - 36.
red
none

69.8.131.180
Apr 5, 2006 6:19:12 PM
Apr 5, 2006 6:40:00 PM

It looks like the DEVID failed since it is labled "null"

Also to our intrest of 3 minute update there are two values submittedAt and maxNextUpdate that relate to the 3 minute update frequency.

Let me know if it looks like I muffed up along the way following your instructions. In the meantime I will keep playing around with this example to see if I can stumble into what the hangup is.

To let you know the ticket system we use is Cerberus Helpdesk, here is a link to a demonstration install http://www.webgroupmedia.com/tts2 the username and password is superuser. I am intrested in taking the ticket numbers from one queue and mapping it onto the orb

Very Appreciative,
Nathan

Ambient Orb Newbie Help!

Nathan, to answer your last question first... no it's not hard to make something like this. Usually the only stumbling blocks are syntax when you are working with a language you are not familiar with. Luckily Screen-Scraper supports a number of languages, and you can usually find an example of what you are trying to do, someplace on the Internet.

OK, since I am not privy to your exact application, I'll make an example of something similar.
The Homeland security Threat Advisory, usually a steady yellow, but as we near elections it's sure to start changing regularly.
The main page is here
http://www.dhs.gov/dhspublic/
And my first thought was to just scrape the main page and determine what graphic was being displayed. As I read a little further it turns out they have a much more stable and accurate XML feed for this purpose.
http://www.dhs.gov/dhspublic/getAdvisoryCondition

So that I don't need to go into too much detail, let's assume you have run through at least the first couple the tutorials on the site (These teach you how to set up the proxy and see what kind of data is flowing back and forth)

Step 1. Create a new scraping session called "threat"
Step 2. "Add a Scriptable File" to the threat session, either use the page generated by the proxy or just click the add button from the scraping session.
Step 3. rename your new file to "getThreatLevel" and make sure the URL is "http://www.dhs.gov/dhspublic/getAdvisoryCondition".
Step 4. At this point we can run the scrape and see what are Response is, we will use the response to determine our extractions. So, click on threat and then click on "Start Scraper" button.
Step 5. If all went well you can select the getThreatLevel scrapable file from the menu, and then click the tab for Last Response. you should see the following.
HTTP/1.1 200 OK
Date: Tue, 04 Apr 2006 12:45:04 GMT
Connection: keep-alive
Content-Length: 82
Cache-Control: private, max-age=600
Server: Oracle-Application-Server-10g OracleAS-Web-Cache-10g/10.1.2.0.0 (H;max-age=300+0;age=221;ecid=24857964453,0)
Content-Type: application/octet-stream

<?xml version="1.0" encoding="UTF-8"?>

The part we are concerned with is the XML Node "THREAT_ADVISORY CONDITION", we will use that as our extractor pattern.
Step 6. Click on the Extractor Patterns tab. Then the button "add extractor pattern".
Step 7. in the pattern text add the following


we are creating a variable called THREATLEVEL in place of the returned threat level. select the word THREATLEVEL and right click. select edit token. in the pop up check the box for save in session variable. We will be referencing this in our next script.

Review, so far we have sent a page request to the Homeland security page and received an XML file, we have searched the response for the pattern "" and replaced the value with a variable THREATLEVEL and saved that value as a session variable. moving on.

8. Create a new Script and Call it "pushThreat"
9. in the Script add the following line of code
session.log("So far so good...");

10. go back the the scraping session "threat" and select the scrapable file get threat level, click on the extractor patterns tab. and at the bottom of the page select "add script"
11. in script name, select "pushThreat" and in the when to run, select "after each pattern application".

Now, save and let's run it. select "threat" from the menu on the left, click the log tab and select clear log. Click general and select Start Scraper.
Look back at the log tab, you should see our line "So far so good..." if you do not.. then something went wrong. Assuming all is fine let's continue.

Step 12. go back to the Script "pushThreat". replace or session.log code with the following.
// possible levels
// LOW
// Green Solid
// GUARDED
// blue solid
// ELEVATED
// yellow pulse

// HIGH
// orange fast pulse
// SEVERE
// red fast flashing

// animation settings
// 0 none
// 1 very slow
// 2 slow
// 3 medium slow
// 4 medium
// 5 medium fast
// 6 fast
// 7 very fast
// 8 crescendo
// 9 heartbeat

// Set your device id here
session.setVariable("DEVID","unknown");

switch(session.getVariable("THREATLEVEL")){
case "LOW":
session.log("you are at LOW");
session.setVariable("ANIM","0");
session.setVariable("COLOR","12");
session.setVariable("COMMENT","Threat+Level+is+LOW");
break;
case "GUARDED":
session.log("you are at GUARDED");
session.setVariable("ANIM","1");
session.setVariable("COLOR","21");
session.setVariable("COMMENT","Threat+Level+is+GUARDED");
break;
case "ELEVATED":
session.log("you are at ELEVATED");
session.setVariable("ANIM","4");
session.setVariable("COLOR","6");
session.setVariable("COMMENT","Threat+Level+is+ELEVATED");
break;
case "HIGH":
session.log("you are at HIGH");
session.setVariable("ANIM","5");
session.setVariable("COLOR","4");
session.setVariable("COMMENT","Threat+Level+is+HIGH");
break;
case "SEVERE":
session.log("you are at SEVERE");
session.setVariable("ANIM","7");
session.setVariable("COLOR","0");
session.setVariable("COMMENT","Threat+Level+is+SEVERE");
break;
default:
session.log("there was a problem with the script");
session.setVariable("ANIM","0");
session.setVariable("COLOR","36");
session.setVariable("COMMENT","there+was+a+problem+with+the+script");
break;
}

// after variables are set run the pushToDevice Page
session.scrapeFile( "pushToDevice" );

a little explanation is in order... forget disregard the comments at the top.. that is just a little key of what to expect from homeland security and what the orb might be expecting..
the first real line of code sets a session variable for the device id.
session.setVariable("DEVID","unknown");

next, using a switch/case statement, we evaluate what is stored in the THREATLEVEL returned from the site.
switch(session.getVariable("THREATLEVEL")){

then based on what is there LOW,HIGH,ELEVATED etc.. we set the parameters that ambient is going to look for.
session.setVariable("ANIM","0");
session.setVariable("COLOR","12");
session.setVariable("COMMENT","Threat+Level+is+LOW");

the last line of code directs us to a second scraping file, we have not created this yet, but let's call it "pushToDevice".
session.scrapeFile( "pushToDevice" );

Step 13. Go back to the general tab under "Threat" and add a new scrapable file, this is the file that will send our variables out to the ambient device. Call the new file "pushToThreat" and set the url to http://myambient.com:8080/java/my_devices/submitdata.jsp
make sure you select the checkbox "This scrapable file will be invoked manually from script" this basically tells the script not to run in succession.
Step 14. Select the parameters tab and 4 parameters
devid
anim
color
comment

now in the value column add these to the corresponding keys.
~#DEVID#~
~#ANIM#~
~#COLOR#~
~#COMMENT#~

Notice the "~##~ instead of "~@@~" around the variables this means read a var rather than set a var.

That's it. lets clear the log and run again. if all goes well you should see the comment "you are at ELEVATED" in your log.. and if you actually entered your device id.. it should be a slow pulse yellow right now... if it is flashing red.. stop reading and run for the hills.

ok.. so I hope that helps, it took far longer to actually write this message than it took to write the code...

There are a few parts we didn't cover like how to make this fire every 3 minutes... You could put it in a command line or BAT file and have the windows scheduler fire it off, or you could make it part of a web page that gets scheduled.. additionally there are lots ways to do the part of pushing your params back out to the device.. I chose the scrapable file option to keep it within screen-srcaper.

ok.. so give it a try and ask me any question s you may have.. if you decide to go with Screen scraper as your solution, let me know and I will help you out with your specific request.

Thanks, Fred

Fred is the man!

Fred I appreciate your willingness to help. Thanks!

I am looking for a flexible setup that could scrape for a number, letter and/or specific phrase from a website then convey it to the submit data ambient system.

I work a helpdesk for technical support and would love to use my orb to show ticket levels and have it pulse if there is a ticket that has not been replied to in the last 24 hours. All this information is in a php based web app.

I would like to use Screen Scraper to: login to the ticket system, look at two values on the page after logging in, pass them on to the orb, refresh the page every 3 minutes, and pass the status to the orb.

If also possible it would be nice to make it easy to customize... how easy would it be to switch to scraping a different page for different information, possibily without a login.

How hard is it to make somthing like this? As far as what kind of code/language to use... I have no idea. The more english the better, since some of these languages are pretty cryptic :shock: unless you are in the know.

Thanks again for your willingness to help! Somthing like this would allow many more people to take advantage of the developer channel

Ambient Orb Newbie Help!

Hi Nathan, having only seen these devices in passing (while surfing) I have never really looked into how they work.
It looks to be rather straight forward.

I do have a couple of questions, it will help to give more specific answers.

1) can you tell me the page you want to scrape the data from? I understand if you can't, maybe you could give an example that is similar and you would know enough to make the needed changes in the code.
2) what method, or framework, will you use to create a reoccurring process. Like windows scheduler? some sort of linux cron job?

An example for a task like this would be:
a) Fire off a scrape command, this can be done from any of the scripting options; command line, php, asp, etc..
b) process returned data, basically evaluate the info scraped from the site and assign a color and animation to it, storing those values in session variables.
c) post a query string to your device through the given url: http://www.myambient.com:8080/java/my_devices/submitdata.jsp

So, as I was saying earlier, this is all subjective to the site you want to scrape and the "framework" you plan on using to instantiate the process.

Thanks, Fred