Skip to content

Commit

Permalink
Merge pull request #10 from hplato/ia7
Browse files Browse the repository at this point in the history
Merge from hplato
  • Loading branch information
Wayne Gatlin authored Aug 12, 2017
2 parents d998b8a + 49aa421 commit c3d0791
Show file tree
Hide file tree
Showing 37 changed files with 5,123 additions and 2,240 deletions.
2 changes: 1 addition & 1 deletion bin/mh
Original file line number Diff line number Diff line change
Expand Up @@ -4730,7 +4730,7 @@ sub print_speaklog_current_time {
# Return the time of most recent speak phrase

#print "db/mh/curr: time=" . &get_tickcount . " plt=$Print_Log_Time[0] slt=$Speak_Log_Time[0]\n";
return $Print_Log_Time[0]
return $Speak_Log_Time[0]
unless ( scalar @Speak_Log_Time <= 0 ); #TODO HP should return $Speak_Log_Time
#return $Speak_Log_Time[0] unless (scalar @Speak_Log_Time <= 0); #TODO HP should return $Speak_Log_Time
return 0;
Expand Down
2 changes: 2 additions & 0 deletions code/common/homebridge.pl
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ sub hb_thermo_set_state {
else {
print_log "Unsupported Thermostat type";
}
return "";
}

sub hb_thermo_get_setpoint {
Expand Down Expand Up @@ -414,6 +415,7 @@ sub hb_thermo_set_setpoint {
else {
print_log "Unsupported Thermostat type";
}
return "";
}

sub calc_auto_mode {
Expand Down
55 changes: 33 additions & 22 deletions code/common/ia7_notifications.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
#@ IA7 v1.1 : Enables speech notifications to browsers.
#@ also includes some sample code of how to use other notifications

if ( $Startup or $Reload ) {
if ( !defined $Info{IPAddress_local} ) {
print_log "json_server.pl: \$Info{IPAddress_local} not defined. Json speech disabled";
}
else {
print_log "IA7 Speech Notifications enabled";
&Speak_parms_add_hook( \&json_speech_enable );
}
}
#if ( $Startup or $Reload ) {
# if ( !defined $Info{IPAddress_local} ) {
# print_log "json_server.pl: \$Info{IPAddress_local} not defined. Json speech disabled";
# }
# else {
# print_log "IA7 Speech Notifications enabled";
# #&Speak_parms_add_hook( \&json_speech_enable );
# }
#}

$v_ia7_test_sound = new Voice_Cmd("Test playing a sound");
$v_ia7_test_banner = new Voice_Cmd("Test [blue,green,yellow,red] Banner Notification");
Expand All @@ -29,18 +29,29 @@
&json_notification( "sound", {%data} );
}

sub json_speech_enable {
my ($parms) = @_;
push @{ $parms->{web_hook} }, \&file_ready_for_ia7;
}

sub file_ready_for_ia7 {
my (%parms) = @_;
my %data;
$data{mode} = $parms{mode};
$data{url} = "http://" . $Info{IPAddress_local} . ":" . $config_parms{http_port} . "/" . $parms{web_file};
$data{text} = $parms{raw_text};
$data{client} = $parms{requestor};
&json_notification( "speech", {%data} );
}

#sub json_speech_enable {
# my ($parms) = @_;
# push( @{ $parms->{web_hook} }, \&file_ready_for_ia7);
#}

#sub file_ready_for_ia7 {
# my (%parms) = @_;
# my %data;
# $data{mode} = $parms{mode};
# $data{url} = "http://" . $Info{IPAddress_local} . ":" . $config_parms{http_port} . "/" . $parms{web_file};
# $data{text} = $parms{raw_text};
# $data{client} = $parms{requestor};
# if (defined $Info{IPAddress_local}) {
# if ((defined $parms{forked}) and $parms{forked} ) {
# #if it's a child process we can't access the global @json_notifications array, so send a webservice call to the master process
# my $MHParent = $Info{IPAddress_local} . ":" . $config_parms{http_port};
# my $cmd = "get_url -quiet \"http://$MHParent/SUB?ia7_notify(\'speech',$data{mode},'$data{text}',$data{url})\" /dev/null";
# run "$cmd" unless (defined $config_parms{disable_json_speech} and $config_parms{disable_json_speech});
# } else {
# &json_notification( "speech", {%data} );
# }
# }
#}

Loading

0 comments on commit c3d0791

Please sign in to comment.