Skip to content

Commit

Permalink
Merge pull request #1 from hollie/master
Browse files Browse the repository at this point in the history
Sync to hollie:master
  • Loading branch information
rudybrian committed Aug 31, 2014
2 parents 8307d23 + 49add01 commit f7940dc
Show file tree
Hide file tree
Showing 39 changed files with 6,845 additions and 891 deletions.
4 changes: 3 additions & 1 deletion bin/get_email
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/perl
#!/usr/bin/env perl
# -*- Perl -*-
#---------------------------------------------------------------------------
# File:
Expand All @@ -11,6 +11,8 @@
# http://misterhouse.net/mh/bin/get_email
# Change log:
# 03/26/99 Created.
# Notes:
# check required modules in lib/imap_utils.pl
#
# This software is licensed under the terms of the GNU public license.
# Copyright 1999 Bruce Winter
Expand Down
13 changes: 13 additions & 0 deletions bin/mh
Original file line number Diff line number Diff line change
Expand Up @@ -5702,6 +5702,19 @@ sub serial_port_open {
# print "np=@serial_parms\n";
}

sub serial_port_close {
my ($name) = @_;
my $port = $Serial_Ports{$name}{port};

# Recommended Steps to Close a Serial Port from CPAN
$Serial_Ports{$name}{object}->close() if (defined $Serial_Ports{$name}{object});
undef $Serial_Ports{$name}{object};

# Remove all references in Global Vars
delete $Serial_Ports{object_by_port}{$port};
delete $Serial_Ports{$name};
}


sub set_sun_time {
my @parms = (latitude => $config_parms{latitude}, longitude => $config_parms{longitude},
Expand Down
98 changes: 97 additions & 1 deletion bin/mh.ini
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ organizer_email = fred => fred@flintstone.org, bambi => bambi => flinstone.com
sound_program=play
@ Set this to the program used to convert sound files from mp3 to wav. Currently
@ only used by the Google TTS engine. The default is ffmpeg, but this is unavailable
@ on some platforms, Ubuntu for example, which requires the use of avconv instead.
sound_converter=
@ Set this to 1 to use fork, rather than system calls, when calling sound_program
sound_fork=
Expand Down Expand Up @@ -2054,9 +2060,99 @@ eib_errata=2
# Category = Insteon

@ These are the states displayed on the tk and web menus
@ French: insteon_menu_states=on,off,normal,eco,plus,moins,plus2,moins2,plus3,moins3,+40,-40,5%,30%,60%,100%
@ French: insteon_menu_states=on,off,normal,eco,plus,moins,plus2,moins2,plus3,moins3,+40,-40,5%,30%,60%,100%
@ The default is off,20%,40%,50%,60%,80%,on
insteon_menu_states=off,20%,40%,50%,60%,80%,on

@ This is a deprecated parameter that no longer does anything.
@ It is kept around on the off chance that it may be revived in the future.
@ The default is 10.
Insteon_PLM_max_queue_time=10

@ If set to 1, MisterHouse will request the status of all Insteon devices on startup.
@ This is useful for making sure that no devices changed their state while MisterHouse was off.
@ The routine will also check the engine version of each device to ensure that the proper ALDB object is created for them.
@ The default is enabled. Set to 0 to disable.
Insteon_PLM_scan_at_startup=1

@ Sets the number of times that MisterHouse will try to resend a failed message.
@ The Insteon specification calls for at least 3, MisterHouse defaults to 5.
Insteon_retry_count=5

@ Identifies the port on which the PLM is attached.
@ For example: Insteon_PLM_serial_port=/dev/ttyS4
Insteon_PLM_serial_port=

@ Setting this to 1, will enable MisterHouse to use a networked PLM such as the
@ Insteon Hub. This functionality seems fairly stable, but has not been
@ extensively tested.
@
@ You will also need to set values for Insteon_PLM_TCP_host and Insteon_PLM_TCP_port
@
@ There are a few quirks when using a networked PLM, they include:
@
@ The communication may be slightly slower with the network PLM. In order to
@ prevent MisterHouse from clobbering the device it is recommended that you
@ set the Insteon_PLM_xmit_delay to 1 second. Testing may reveal that slightly
@ lower delays are also acceptable.
@
@ Changes made using the hub's web interface will not be understood by MisterHouse.
@ Device states may become out of sync. (It is possible that future coding may
@ be able to overcome this limiation)
Insteon_PLM_use_TCP=
@ If using a network PLM, set this to the IP address of the PLM. See Insteon_PLM_use_TCP
Insteon_PLM_TCP_host=
@ If using a network PLM, set this to the port address of the PLM. Generally, the
@ port number is 9761. See Insteon_PLM_use_TCP
Insteon_PLM_TCP_port=
@ Sets the minimum amount of seconds that must elapse between sending Insteon messages
@ to the PLM. Defaults to 0.25.
Insteon_PLM_xmit_delay=.25
@ Sets the minimum amount of seconds that must elapse between sending X10 messages
@ to the PLM. Defaults to 0.50.
Insteon_PLM_xmit_x10_delay=.50
@ Periodically, the PLM will report that it is too busy to accept a message from
@ MisterHouse. When this happens, MisterHouse will wait 1 second before trying
@ to send a message to the PLM. If this is set to 1, downgrades the delay to only
@ .3 seconds. Most of the issues which caused the PLM to overload have been handled
@ it is unlikely that you would need to set this.
Insteon_PLM_disable_throttling=0
@ The PLM acknowledges the receipt of a command from MisterHouse with an ACK
@ message. It is very rare for a well functioning PLM to fail to send the ACK
@ message. In many cases, the failure to receive an ACK message from the PLM
@ is a sign that the connection between MisterHouse and the PLM (Serial or USB)
@ has died.
@
@ This setting defines the number of missed ACK messages that must occur for
@ MisterHouse to deem the PLM connection lost. The number of missed ACK messages
@ must all occur while sending a single Insteon command. So if you want this
@ to do anything, this number needs to be less than or equal to the
@ Insteon_retry_count. Once the number of missed ACK messages occurs, MisterHouse
@ will attempt to reconnect the PLM. For some people, the reconnect routine
@ causes errors, so you may want to test this out by manually pulling the
@ connection cable to the PLM to see how your system will react.
@
@ By default, this is set to 99, essentially disabling an automatic restart.
@
@ Note the ACK messages discussed here refer to PLM ACK messages not the ACK
@ messages received from an Insteon device in response to a command.
Insteon_PLM_reconnect_count=99
# ******************************************************************************
# Category = Weather
@ Used by the common code file weather_tides.pl to specify the nearest coastal region
@ from which to obtain tide data. Enter a location from the list at <a href="http://tbone.biol.sc.edu/tide/">http://tbone.biol.sc.edu/tide</a>,
@ for example, weather_tide_site=San Diego, San Diego Bay, California
weather_tide_site=
******************************************************************************
# Category = Misc
Expand Down
12 changes: 8 additions & 4 deletions bin/mhl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ while [ 1 = 1 ]; do

echo
echo Deleting startup file
# rm -f mh.started
touch mh.startup

# Avoid a memory leak problem in Red Hat 8
Expand All @@ -29,13 +28,18 @@ while [ 1 = 1 ]; do
exit
fi

# if [ ! -f mh.started ]; then
if [ -f mh.startup ]; then
if [ -f mh.startup ]; then
echo mh failed on startup ... will not restart
exit
fi

echo mh had an unexpected exit ... sleep a bit, then restarting
if [ $rc = 99 ]; then
echo -n restart requested
else
echo -n mh had an unexpected exit
fi

echo " ... sleep a bit, then restarting"
date >> mh_restart.log
sleep 5

Expand Down
4 changes: 3 additions & 1 deletion bin/update_docs
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,11 @@ else {
foreach my $doc ( keys %podfiles ) {
my $podfile = "$docdir/$doc";
my $ind = "";
my $docdir2 = $docdir;
if ( $doc eq "items.pod" or $doc eq "modules.pod" ) {
$podfile = "$outdir/$doc";
$ind = "--noindex";
$docdir2 = '..';
}
$doc =~ s/\.pod$//i;
my $htmlfile = "$outdir/$doc.html";
Expand All @@ -297,7 +299,7 @@ foreach my $doc ( keys %podfiles ) {
pod2html(
"--infile=$podfile", "--outfile=$htmlfile",
"--noheader",
"--htmldir=$outdir", "--podroot=$docdir",
"--htmldir=$outdir", "--podroot=$docdir2",
"--podpath=.", "--css=/lib/pod.css",
$ind
);
Expand Down
4 changes: 3 additions & 1 deletion code/common/stocks.pl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# More info on how this magic url was derived can be found here:
# http://www.padz.net/~djpadz/YahooQuote/
my $stock_url = 'http://quote.yahoo.com/d?f=snl1d1t1c1p2va2bapomwerr1dyj1x\&s=' . join('%20', @stock_symbols);
my $stock_url = 'http://download.finance.yahoo.com/d?f=snl1d1t1c1p2va2bapomwerr1dyj1x\&s=' . join('%20', @stock_symbols);
my @stock_keys = ('SName', 'LName', 'Last', 'Date', 'Time', 'Change', 'PChange',
'Volume', 'Avg Volume', 'Bid', 'Ask', 'Prev Close', 'Open',
'Day Range', '52-Week Range', 'EPS', 'P/E Ratio', 'Div Pay Date',
Expand Down Expand Up @@ -198,6 +198,8 @@
unless &trigger_get('get stocks');
}

# 07 Jul 14, Jared J. Fernandez
# Updated stocks URL due to change by Yahoo.

# 27 Dec 05, David Norwood
# Someone else also added back the stock alerts in the last release. I removed the duplicate code.
Expand Down
73 changes: 48 additions & 25 deletions code/common/weather_pollen.pl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#Category=Weather

#@ This module gets the pollen forecast from www.pollen.com and puts the pollen
#@ This module gets the pollen forecast from Claritin.com and puts the predominant pollen
#@ type and pollen count into the %Weather hash.
#@
#@ Uses mh.ini parameter zip_code

# get pollen count forecast from www.pollen.com and put it and the pollen
# Get pollen count forecast from Claritin.com and put it and the predominant pollen
# type into the %Weather hash.
# Technically there is a 4 day forecast, but I have seen it vary so widely
# from day 2 and what day 1 will say tomorrow that I don't count on it for
Expand All @@ -14,36 +14,61 @@
#uses mh.ini parameter zip_code=
#
#info from:
#http://www.pollen.com/forecast.asp?PostalCode=64119
#http://www.claritin.com/weatherpollenservice/weatherpollenservice.svc/getforecast/64119
#

# weather_pollen.pl
# Original Author: Kent Noonan
# Revision: 1.3
# Date: 07/14/2014

=begin comment
1.0 Initial Release
Kent Noonan - ca. 12/16/2001
1.1 Revisions
David J. Mark - 06/12/2006
1.2 Updated to use new Trigger design.
Bruce Winter - 06/25/2006
1.3 Updated to use the JSON WeatherPollenService from Claratin.com
since Pollen.com has added countermeasures to prevent screenscraping
that would take much more code to parse. The WeatherPollenService
has a better API that seems to provide the same data as most other
online pollen forecasting services. In addition to switching service
providers, I've also done some general cleanup & improvements.
Jared J. Fernandez - 07/14/2014
=cut

use JSON qw( decode_json );

my $pollen_file = "$config_parms{data_dir}/web/pollen_forecast.json";

$v_get_pollen_forecast = new Voice_Cmd('[Get,Check] pollen forecast');
# *** set info
$v_get_pollen_forecast->set_info("Downloads and parses the pollen forecast data. The 'check' option reads out the result after parsing is complete.");

$v_read_pollen_forecast = new Voice_Cmd('Read pollen forecast');
$v_read_pollen_forecast->set_info("Reads out the previously fetched pollen forecast.");

$p_pollen_forecast = new Process_Item("get_url http://www.pollen.com/forecast.asp?postalcode=$config_parms{zip_code} $config_parms{data_dir}/web/pollen_forecast.html");
$p_pollen_forecast = new Process_Item("get_url http://www.claritin.com/weatherpollenservice/weatherpollenservice.svc/getforecast/$config_parms{zip_code} $pollen_file");

&parse_pollen_forecast if $Reload;
&parse_pollen_forecast if (($Reload) && (-e $pollen_file));

sub parse_pollen_forecast {

my $count1;
open(FILE,"$config_parms{data_dir}/web/pollen_forecast.html");
while (<FILE>) {
if (/Predominant pollen:\s+(.+)\.<\/A>/i) {
$main::Weather{TodayPollenType}=$1;
} elsif ((/fimages\/std\/(\d+\.\d).gif/i) and (!defined($count1))) {
$count1="r";
$main::Weather{TodayPollenCount}=$1;
}

my @pollen_data = file_read($pollen_file) || warn "Unable to open pollen data file.";
# The JSON file that is retuned by the service is malformed; these substitutions clean it up so that the perl JSON module can parse it.
for (@pollen_data) {
s/\"\{/\{/;
s/\\//g;
s/\}\"/\}/;
}
close(FILE);

my $json = decode_json(@pollen_data) || warn "Error parsing pollen info from file.";
$main::Weather{TodayPollenCount} = $json->{pollenForecast}{forecast}[0];
$main::Weather{TomorrowPollenCount} = $json->{pollenForecast}{forecast}[1];
$main::Weather{TodayPollenType} = $json->{pollenForecast}{pp};
$main::Weather{TodayPollenType} =~ s/\.//;
}


if ($state = said $v_get_pollen_forecast) {
$v_get_pollen_forecast->respond("app=pollen Retrieving pollen forecast...");
start $p_pollen_forecast;
Expand All @@ -52,18 +77,16 @@ sub parse_pollen_forecast {
if (done_now $p_pollen_forecast){
&parse_pollen_forecast();
if ($v_get_pollen_forecast->{state} eq 'Check') {
$v_get_pollen_forecast->respond("app=pollen Today's pollen count is $main::Weather{TodayPollenCount}. The predominant pollens are " . lc($main::Weather{TodayPollenType}));
$v_get_pollen_forecast->respond("app=pollen Today's pollen count is $main::Weather{TodayPollenCount}. The predominant pollens are from " . lc($main::Weather{TodayPollenType} . "."));
}
else {
$v_get_pollen_forecast->respond("app=pollen Pollen forecast retrieved");
$v_get_pollen_forecast->respond("app=pollen Pollen forecast retrieved.");
}


}

if (said $v_read_pollen_forecast) {
if ($Weather{TodayPollenCount}) {
$v_read_pollen_forecast->respond("app=pollen Today's pollen count is $main::Weather{TodayPollenCount}. The predominant pollens are " . lc($main::Weather{TodayPollenType}));
$v_read_pollen_forecast->respond("app=pollen Today's pollen count is $main::Weather{TodayPollenCount}. The predominant pollens are from " . lc($main::Weather{TodayPollenType}) . ".");
}
else {
$v_read_pollen_forecast->respond("app=pollen I do not know the pollen count at the moment.");
Expand Down
7 changes: 4 additions & 3 deletions code/common/weather_tides.pl
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Category = Weather

#@ This script collects information about ocean tides, moonrise and moonset from the
#@ <a href=http://tbone.biol.sc.edu/tide>University of Southern Carolina Tide Predictor<a>.
#@ <a href="http://tbone.biol.sc.edu/tide">University of Southern Carolina Tide Predictor</a>.
#@ Set the weather_tide_site ini parameter to the tide site closest to you.

# 12/04/05 created by David Norwood based on idea by Joey French
# Version 1.1 07/29/14 Fixed description and ini parameter reference - Jared J. Fernandez
# Version 1.0 12/04/05 created by David Norwood based on idea by Joey French


#noloop=start
Expand All @@ -15,7 +16,7 @@
$v_read_tides = new Voice_Cmd 'When is the next [High Tide,Low Tide,Moonrise,Moonset]?';
$v_read_tides ->set_info('Show tide, moonrise and moonset information from the Internet');
$p_get_tides = new Process_Item;
$tide_site = $config_parms{'weather_tide_site'} if $config_parms{'weather_tide_site'};
$tide_site = $config_parms{weather_tide_site} if $config_parms{weather_tide_site};
$tide_site = &escape($tide_site);
set $p_get_tides "get_url http://tbone.biol.sc.edu/tide/tideshow.cgi?site=$tide_site $f_tides";
trigger_delete "get tide info";
Expand Down
Loading

0 comments on commit f7940dc

Please sign in to comment.