I started with the example in the webapp guide from polycom and ended up just 
hacking up perl scripts. I attached the idlewx for the 650 CGI. I really should 
run this under jetty or abyss and cache the results from wxunderground rather 
than having each phone's query go out and hit them (this is a simple apache run 
perl CGI right now). I have it set to update every 5 minutes so for 10 phones 
its not that much traffic.

I've been (slowly) working up some fancier stuff that runs in the non-idle 
microbrowser (shows open doors in the building, lets you turn on/off outside 
lighting via Insteon, etc) but I got stuck trying to get the 'softkeys' to 
display the way I wanted and haven't gotten back to it in a few weeks. I have a 
simple app that lets you schedule a "wakeup" or reminder call on a 650 that 
needs some work too.

-Eric

#!/usr/bin/perl

use XML::Parser;

use strict;
use warnings;
use WWW::Curl::Easy;

# Setting the options
my $curl = new WWW::Curl::Easy;

$curl->setopt(CURLOPT_HEADER,0);
$curl->setopt(CURLOPT_URL, 'http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=KMIC');
my $response_body;

# NOTE - do not use a typeglob here. A reference to a typeglob is okay though.
open (my $fileb, ">", \$response_body);
$curl->setopt(CURLOPT_WRITEDATA,$fileb);

# Starts the actual request
my $retcode;
$retcode = $curl->perform;

# Looking at the results...
if ($retcode != 0) {
    print("An error happened: ".$curl->strerror($retcode)." ($retcode)\n");
}
#print("Transfer went ok\n");
my $response_code = $curl->getinfo(CURLINFO_HTTP_CODE);
# judge result and next action based on $response_code
# print("Received response: $response_body\n");

$curl->setopt(CURLOPT_URL, 'http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=Minneapolis,MN');
$retcode = $curl->perform;
if ($retcode != 0) {
    print("An error happened: ".$curl->strerror($retcode)." ($retcode)\n");
}

$response_body =~ s/<\?xml version="1.0" \?>//;
#$response_body =~ s/<!-- .*? -->//;

my $pme = "<outer>$response_body</outer>\n";

my @modes;
my $mode = "";
my %d;
my @fcasts;

my $parser = new XML::Parser;
$parser->setHandlers(      Start => \&startElement,
                           End => \&endElement,
                           Char => \&cdata,
                           Default => \&default);
$parser->parse($pme);

sub startElement {
    my ($pi, $element, %attrs) = @_;
    $mode = $element;
    unshift @modes, $mode;
    $d{$mode} = "";
}

sub cdata {
    my ($pi, $data) = @_;
    $data =~ s/^\s*(\S*(?:\s+\S+)*)\s*$/$1/;
    $d{$mode} .= $data;
    if (defined($modes[2]) &&
        $modes[1] eq "forecastday" &&
        $modes[2] eq "txt_forecast") {
        if ($mode eq "fcttext") {
            push @fcasts, "<i>$d{title}</i>: $data";
        }
    }
}

sub endElement {
    my ($pi, $element) = @_;
    $mode = shift @modes;
}

sub default {
    my ($pi, $data) = @_;
}

# strip leading/trailing whitespace
foreach my $e (keys %d) {
    $d{$e} =~ s/^\s*(\S*(?:\s+\S+)*)\s*$/$1/;
}

print <<EOF ;
Content-Type: text/html

<html>
<body>
EOF

print "$d{temp_f}F Dew:$d{dewpoint_f}F Chill:$d{windchill_f}F";
print " Wind:$d{wind_degrees} \@ $d{wind_mph}";
if ($d{wind_gust_mph} ne "") {
    print "G$d{wind_gust_mph}";
}
print "<br/>$d{weather}<br/>\n";
foreach my $fc (@fcasts) {
    print "$fc<br/>\n";
}

print <<EOF ;
</body>
</html>
EOF


On Mar 11, 2010, at 3:17 PM, Nathaniel Watkins wrote:

> Off topic here - how are you getting the weather/news to display correctly?  
> I've played with this functionality - but gave up quickly.  I wasn't sure if 
> it was a firewall issue or not - I just haven't re-visited - any guidance 
> would be appreciated.
> 
> 
> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Eric Varsanyi
> Sent: Thursday, March 11, 2010 4:00 PM
> To: Paul Mossman
> Cc: [email protected]
> Subject: Re: [sipx-users] Configuration via Phone Groups?
> 
> In my smallish pilot (10 polycoms, handful of FXS interfaced devices) I use a 
> new group for every Polycom feature I might want to set different than the 
> polycom plugin default, then I put each phone I want to have that feature in 
> in that group. I went to this because you can't tell in any sane way what 
> settings are overridden in each group. So I have a 24Hr display group, a 
> 'show weather on idle' group, a 'show news when idle' group (and similar 
> 'show weather on 335' and 'show news on 335' since they have a smaller 
> display), a 'use dynamic RTP 101 for dtmf' group, a 'use background 3,1' 
> group (based on some private change I've made to the polycom plugin), and a 
> group that loads a specific set of custom ringtones (also a local extension 
> I've made) to the phones, etc.
> 
> I also group the phones by their model# (650 or 335) and location (floor1 and 
> floor2).
> 
> With this setup I can see at a glance how features are set for a specific 
> phone or class of phones.
> 
> Maybe this is OT, but the 'user group' stuff WRT phonebooks is pretty painful 
> to work with. It would be a little better if the speed dials for each group 
> that applied as well as each user were merged on each phone (rather than it 
> picking one of the groups speed dials).
> 
> -Eric
> 
> On Mar 11, 2010, at 1:20 PM, Paul Mossman wrote:
> 
>> Hi all,
>> 
>> I'd like to better understand how Phone Groups are actually used.  It
>> seems to me that Phone Groups can do two things:
>> 
>>  1. "Filter by..." when listing Phones.  i.e. If you frequently "Send
>> Profiles" or "Restart" certain sub-groups of phones, then you can
>> group them and save a little time.
>> 
>>  2. Configuration.  i.e. You want your Polycoms to display time in 24
>> hour format.
>> 
>> 
>> Can I have some real world examples of #2?  Do you typically have
>> phone from different vendors in the same group?
>> 
>> Thanks.
>> 
>> 
>> 
>> -Paul
>> [email protected]
>> 
>> 
>> _______________________________________________
>> sipx-users mailing list [email protected] List Archive:
>> http://list.sipfoundry.org/archive/sipx-users
>> Unsubscribe: http://list.sipfoundry.org/mailman/listinfo/sipx-users
>> sipXecs IP PBX -- http://www.sipfoundry.org/
> 
> _______________________________________________
> sipx-users mailing list [email protected] List Archive: 
> http://list.sipfoundry.org/archive/sipx-users
> Unsubscribe: http://list.sipfoundry.org/mailman/listinfo/sipx-users
> sipXecs IP PBX -- http://www.sipfoundry.org/
> 
> This message and any files transmitted with it are intended only for the 
> individual(s) or entity named. If you are not the intended individual(s) or 
> entity named you are hereby notified that any disclosure, copying, 
> distribution or reliance upon its contents is strictly prohibited. If you 
> have received this in error, please notify the sender, delete the original, 
> and destroy all copies. Email transmissions cannot be guaranteed to be secure 
> or error-free as information could be intercepted, corrupted, lost, 
> destroyed, arrive late or incomplete, or contain viruses. Garrett County 
> Government therefore does not accept any liability for any errors or 
> omissions in the contents of this message, which arise as a result of email 
> transmission.
> 
> 
> Garrett County Government,
> 203 South Fourth Street, Courthouse, Oakland, Maryland 21550 
> www.garrettcounty.org

_______________________________________________
sipx-users mailing list [email protected]
List Archive: http://list.sipfoundry.org/archive/sipx-users
Unsubscribe: http://list.sipfoundry.org/mailman/listinfo/sipx-users
sipXecs IP PBX -- http://www.sipfoundry.org/

Reply via email to