mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
95_Babble.pm: Neue Version 1.2
95_PostMe.pm: Neue Version mit minimalen Änderungen 95_YAAHM.pm: Neue Version mit ein paar minimalen Fixes 00_OWX.pm: Neue Version, optionales IODev Attribut eingebaut git-svn-id: https://svn.fhem.de/fhem/trunk@16217 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
2324c38d82
commit
e9e32a4e84
@ -85,11 +85,11 @@ use vars qw{%owg_family %gets %sets $owx_version $owx_debug};
|
||||
"qstatus" => "P"
|
||||
);
|
||||
|
||||
#-- These occur in a pulldown menu as settable values for the bus master
|
||||
#-- These occur in a pulldown menu as settable values for the bus master
|
||||
# (expert mode: all, standard mode: only reopen)
|
||||
%sets = (
|
||||
"close" => "c",
|
||||
"open" => "o",
|
||||
"closeopen" => "co" ,
|
||||
"open" => "O",
|
||||
"reopen" => "R",
|
||||
"discover" => "C",
|
||||
"detect" => "T",
|
||||
@ -98,7 +98,7 @@ use vars qw{%owg_family %gets %sets $owx_version $owx_debug};
|
||||
);
|
||||
|
||||
#-- some globals needed for the 1-Wire module
|
||||
$owx_version="7.06";
|
||||
$owx_version="7.08";
|
||||
|
||||
#-- debugging now verbosity, this is just for backward compatibility
|
||||
$owx_debug=0;
|
||||
@ -130,6 +130,7 @@ sub OWX_Initialize ($) {
|
||||
$hash->{AttrFn} = "OWX_Attr";
|
||||
$hash->{AttrList}= "asynchronous:0,1 dokick:0,1 ".
|
||||
"interval timeout opendelay expert:0_def,1_detail ".
|
||||
"IODev ".
|
||||
$readingFnAttributes;
|
||||
}
|
||||
|
||||
@ -1045,41 +1046,30 @@ sub OWX_Set($@) {
|
||||
my $name = shift @a;
|
||||
my $res = 0;
|
||||
|
||||
#-- for the selector: which values are possible
|
||||
#-- for the selector: all values are possible for expert, otherwise only reopen
|
||||
return ( (AttrVal($name,"expert","") eq "1_detail") ? join(":noArg ", sort keys %sets).":noArg" : "reopen:noArg")
|
||||
if(!defined($sets{$a[0]}));
|
||||
return "OWX_Set: With unknown argument $a[0], choose one of " .
|
||||
( (AttrVal($name,"expert","") eq "1_detail") ? join(" ", sort keys %sets) : "reopen")
|
||||
if(!defined($sets{$a[0]}));
|
||||
|
||||
#-- Set reopen
|
||||
if( $a[0] eq "reopen" ){
|
||||
DevIo_OpenDev($hash, 1, undef);
|
||||
$res = 0;
|
||||
}
|
||||
|
||||
#-- expert mode
|
||||
#-- Set closedev
|
||||
if( $a[0] eq "close" ){
|
||||
OWX_WDBGL($name,1,"====> CLOSING DEVICE",main::DevIo_CloseDev($hash));
|
||||
$res = 0;
|
||||
}
|
||||
|
||||
#-- Set opendev
|
||||
|
||||
my $owx = $hash->{OWX};
|
||||
|
||||
#-- Set open
|
||||
if( $a[0] eq "open" ){
|
||||
OWX_WDBGL($name,1,"====> OPENING DEVICE",main::DevIo_OpenDev($hash,0,undef));
|
||||
$owx->Open();
|
||||
$res = 0;
|
||||
}
|
||||
|
||||
#-- Set close
|
||||
if( $a[0] eq "close" ){
|
||||
$owx->Close();
|
||||
$res = 0;
|
||||
}
|
||||
|
||||
#-- Set closeopendev
|
||||
if( $a[0] eq "closeopen" ){
|
||||
OWX_WDBGL($name,1,"====> CLOSING DEVICE",main::DevIo_CloseDev($hash));
|
||||
OWX_WDBGL($name,1," OPENING DEVICE",main::DevIo_OpenDev($hash, 0, undef));
|
||||
}
|
||||
|
||||
#-- Set reopen
|
||||
if( $a[0] eq "reopen" ){
|
||||
OWX_WDBGL($name,1,"====> REOPENING DEVICE",main::DevIo_OpenDev($hash, 1, undef));
|
||||
$owx->Reopen();
|
||||
$res = 0;
|
||||
}
|
||||
|
||||
@ -1697,7 +1687,7 @@ sub OWX_WDBGL($$$$) {
|
||||
<li><a name="owx_reopen">
|
||||
<code>set <name> reopen</code>
|
||||
</a>
|
||||
<br />re-opens the interface ans re-initializes the 1-Wire bus.
|
||||
<br />re-opens the interface and re-initializes the 1-Wire bus.
|
||||
</li>
|
||||
</ul>
|
||||
<br />
|
||||
|
@ -53,7 +53,7 @@ if (eval {require RiveScript;1;} ne 1) {
|
||||
my $babblelinkname = "babbles"; # link text
|
||||
my $babblehiddenroom = "babbleRoom"; # hidden room
|
||||
my $babblepublicroom = "babble"; # public room
|
||||
my $babbleversion = "1.1";
|
||||
my $babbleversion = "1.2";
|
||||
|
||||
my %babble_transtable_EN = (
|
||||
"ok" => "OK",
|
||||
@ -83,10 +83,11 @@ my %babble_transtable_EN = (
|
||||
"verb" => "Verb",
|
||||
"target" => "Target",
|
||||
"result" => "Result",
|
||||
"unknown" => "unknown",
|
||||
"infinitive" => "Infinitive",
|
||||
"conjugations" => "Conjugations and Variations",
|
||||
"helptext" => "Help Text",
|
||||
"speak" => "Speak",
|
||||
"speak" => "Please speak",
|
||||
"followedby" => "followed by",
|
||||
"placespec" => "a place specification",
|
||||
"dnu" => "Sorry, I did not understand this",
|
||||
@ -136,10 +137,11 @@ my %babble_transtable_EN = (
|
||||
"verb" => "Verb",
|
||||
"target" => "Ziel",
|
||||
"result" => "Ergebnis",
|
||||
"unknown" => "unbekannt",
|
||||
"infinitive" => "Infinitiv",
|
||||
"conjugations" => "Konjugationen und Variationen",
|
||||
"helptext" => "Hilfetext",
|
||||
"speak" => "Sprich",
|
||||
"speak" => "Bitte sprich",
|
||||
"followedby" => "gefolgt von",
|
||||
"placespec" => "einer Ortsangabe",
|
||||
"dnu" => "Es tut mir leid, das habe ich nicht verstanden",
|
||||
@ -181,7 +183,7 @@ sub Babble_Initialize ($) {
|
||||
#$hash->{AttrFn} = "Babble_Attr";
|
||||
my $attst = "lockstate:locked,unlocked helpFunc noChatBot:0,1 testParm0 testParm1 testParm2 testParm3 ".
|
||||
"remoteFHEM0 remoteFHEM1 remoteFHEM2 remoteFHEM3 remoteFunc0 remoteFunc1 remoteFunc2 remoteFunc3 remoteToken0 remoteToken1 remoteToken2 remoteToken3 ".
|
||||
"babbleIds babbleDevices babblePlaces babbleNotPlaces babbleVerbs babbleVerbParts babblePrepos babbleQuests babbleArticles babbleStatus babbleWrites babbleTimes";
|
||||
"babbleIds babblePreSubs babbleDevices babblePlaces babbleNotPlaces babbleVerbs babbleVerbParts babblePrepos babbleQuests babbleArticles babbleStatus babbleWrites babbleTimes";
|
||||
$hash->{AttrList} = $attst;
|
||||
|
||||
if( !defined($babble_tt) ){
|
||||
@ -443,6 +445,7 @@ sub Babble_save($) {
|
||||
my $jhash0 = eval{ $json->encode( $hash->{DATA} ) };
|
||||
if( ReadingsVal($name,"lockstate","locked") ne "locked" ){
|
||||
my $error = FileWrite("babbleFILE",$jhash0);
|
||||
Log3 $name, 1, " ".Dumper($jhash0);
|
||||
#Log3 $name,1,"[Babble_save] error=$error";
|
||||
}else{
|
||||
Log3 $name, 1, "[Babble] attempt to save data failed due to lockstate";
|
||||
@ -623,17 +626,16 @@ sub Babble_Normalize($$){
|
||||
|
||||
#-- normalize special phrases
|
||||
my $sentmod = $sentence;
|
||||
$sentmod =~ s/we((ck)|g) ?zeit/wecker/;
|
||||
$sentmod =~ s/wecken um/stelle den wecker auf/;
|
||||
$sentmod =~ s/^wecker/den wecker/;
|
||||
$sentmod =~ s/beleuchtung/licht/;
|
||||
$sentmod =~ s/\szimmer/_zimmer/;
|
||||
$sentmod =~ s/(((zur?)|(von))\s)?(\w+)\sliste/$5_liste/;
|
||||
$sentmod =~ s/\ssichern/ zusichern/;
|
||||
$sentmod =~ s/unscharf\s?/aus/;
|
||||
$sentmod =~ s/scharf\s?/ein/;
|
||||
$sentmod =~ s/wider\s/wider/;
|
||||
|
||||
my $pairs = AttrVal($name,"babblePreSubs",undef);
|
||||
if( $pairs ){
|
||||
my @subs=split(' ',$pairs);
|
||||
for( my $i=0; $i<int(@subs); $i++ ){
|
||||
my ($t,$r) = split( ':',$subs[$i],2 );
|
||||
$t =~ s/\\s/ /g;
|
||||
$r =~ s/\\s/ /g;
|
||||
$sentmod =~ s/$t/$r/;
|
||||
}
|
||||
}
|
||||
my @word = split(' ',$sentmod,15);
|
||||
my $len = int(@word);
|
||||
|
||||
@ -922,13 +924,8 @@ sub Babble_Normalize($$){
|
||||
$verb = $word[1];
|
||||
shift(@xord);
|
||||
$reading = join(" ",@xord);
|
||||
#-- (device) [prepo] öffnen
|
||||
#}elsif( $reserve =~ /^öffne.*/ ){
|
||||
# $subsubcat = 6;
|
||||
# $reading = "";
|
||||
# $verb = "öffnen";
|
||||
#-- (arti) (device) [prepo] verb
|
||||
}elsif( $reserve =~ s/^$hash->{DATA}{"re_verbsi"}\s// ){
|
||||
}elsif( $reserve =~ s/^$hash->{DATA}{"re_verbsi"}\s?// ){
|
||||
$subsubcat = 6;
|
||||
$verb = $1;
|
||||
$reading = $reserve;
|
||||
@ -949,16 +946,10 @@ sub Babble_Normalize($$){
|
||||
}
|
||||
}
|
||||
#-- normalize devices
|
||||
$device = "golf"
|
||||
if( $device =~/golfplatz/);
|
||||
$device = "haus"
|
||||
if( $device =~/hauses/);
|
||||
$device = "haustür"
|
||||
if( $device =~/hauseingangstür/);
|
||||
$device = "wecker"
|
||||
if( $device =~/we((ck)|g).*/);
|
||||
$device = "alarm"
|
||||
if( $device =~/alarm.*/);
|
||||
$place = "wohnzimmer"
|
||||
if( ($device eq "licht") && ($place eq ""));
|
||||
if( $device eq "außenlicht" ){
|
||||
@ -985,6 +976,14 @@ sub Babble_Normalize($$){
|
||||
$value=substr($sentmod,index($sentmod,"auf")+4)
|
||||
if( ($reading && $reading eq "auf") || ($reserve && $reserve eq "auf") );
|
||||
|
||||
$value=substr($sentmod,index($sentmod,"hinzufügen")+11)
|
||||
if( $reserve && $reserve =~ /hinzufügen (.*)/ );
|
||||
|
||||
if( $verb && $verb eq "entfernen" ){
|
||||
$value = $reading;
|
||||
$reading = "ent";
|
||||
}
|
||||
|
||||
if( $value =~ /.*uhr.*/ ){
|
||||
$value = Babble_timecorrector($value);
|
||||
}
|
||||
@ -1083,9 +1082,9 @@ sub Babble_TestIt{
|
||||
my $hash = $defs{$name};
|
||||
|
||||
my ($device,$verb,$reading,$value,$article,$reserve,$place,$cat) = Babble_Normalize($name,$sentence);
|
||||
$verb = ""
|
||||
$verb = "none"
|
||||
if( !$verb );
|
||||
$reading = ""
|
||||
$reading = "none"
|
||||
if( !$reading );
|
||||
|
||||
my $str="[Babble_Normalize] ".$babble_tt->{"input"}.": $sentence\n".
|
||||
@ -1093,13 +1092,16 @@ sub Babble_TestIt{
|
||||
$babble_tt->{"device"}."=$device ".$babble_tt->{"place"}."=$place ".
|
||||
$babble_tt->{"verb"}."=$verb ".$babble_tt->{"target"}."=$reading / $value";
|
||||
|
||||
my $cmd = $hash->{DATA}{"command"}{$device}{$place}{$verb}{$reading};
|
||||
my $res = "";
|
||||
my $cmd = $hash->{DATA}{"command"}{$device}{$place}{$verb}{$reading};
|
||||
my $res = "";
|
||||
my $star = "";
|
||||
|
||||
#-- no - but maybe we have an alias device ?
|
||||
#-- not directly - but maybe we have an alias device ?
|
||||
if( (!defined($cmd) || $cmd eq "") && defined($device) ){
|
||||
my $alidev = $device;
|
||||
#-- remove trailing numbers
|
||||
$alidev =~s/_\d+$//g;
|
||||
#-- number of real devices for this alias device
|
||||
my $numalias = (defined($hash->{DATA}{"devsalias"}{$alidev})) ? int(@{$hash->{DATA}{"devsalias"}{$alidev}}) : 0;
|
||||
for (my $i=0;$i<$numalias ;$i++){
|
||||
my $ig = $hash->{DATA}{"devsalias"}{$alidev}[$i];
|
||||
@ -1114,10 +1116,31 @@ sub Babble_TestIt{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#-- not directly - but maybe we have a device which is an extension of an alias device
|
||||
if( (!defined($cmd) || $cmd eq "") && defined($device) ){
|
||||
my $realdev = $device;
|
||||
foreach my $stardev (keys $hash->{DATA}{"devsalias"}){
|
||||
if(index($stardev,'*')!=-1){
|
||||
my $starrexp = $stardev;
|
||||
$starrexp =~ s/\*/\(\.\*\)/;
|
||||
if( $realdev =~ /$starrexp/ ){
|
||||
$star = $1;
|
||||
$cmd = $hash->{DATA}{"command"}{$stardev}{$place}{$verb}{$reading};
|
||||
if( defined($cmd) && $cmd ne "" ){
|
||||
$device = $stardev;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#-- command found, execute if permitted
|
||||
if( defined($cmd) && $cmd ne "" ){
|
||||
#-- substitution
|
||||
$cmd =~ s/\$DEV/$device/g;
|
||||
$cmd =~ s/\$STAR/$star/g;
|
||||
$cmd =~ s/\$VALUE/$value/g;
|
||||
for( my $i=0;$i<4;$i++){
|
||||
$parms[$i] = AttrVal($name,"testParm".$i,undef)
|
||||
@ -1224,10 +1247,15 @@ sub Babble_DoIt{
|
||||
my $hash = $defs{$name};
|
||||
|
||||
my ($device,$verb,$reading,$value,$article,$reserve,$place,$cat) = Babble_Normalize($name,$sentence);
|
||||
$verb = "none"
|
||||
if( !$verb );
|
||||
$reading = "none"
|
||||
if( !$reading );
|
||||
my $cmd = $hash->{DATA}{"command"}{$device}{$place}{$verb}{$reading};
|
||||
my $res = "";
|
||||
my $star= "";
|
||||
|
||||
#-- no - but maybe we have an alias device ?
|
||||
#-- not directly - but maybe we have an alias device ?
|
||||
if( !defined($cmd) || $cmd eq "" ){
|
||||
my $alidev = $device;
|
||||
$alidev =~s/_\d+$//g;
|
||||
@ -1246,6 +1274,25 @@ sub Babble_DoIt{
|
||||
}
|
||||
}
|
||||
|
||||
#-- not directly - but maybe we have a device which is an extension of an alias device
|
||||
if( (!defined($cmd) || $cmd eq "") && defined($device) ){
|
||||
my $realdev = $device;
|
||||
foreach my $stardev (keys $hash->{DATA}{"devsalias"}){
|
||||
if(index($stardev,'*')!=-1){
|
||||
my $starrexp = $stardev;
|
||||
$starrexp =~ s/\*/\(\.\*\)/;
|
||||
if( $realdev =~ /$starrexp/ ){
|
||||
$star = $1;
|
||||
$cmd = $hash->{DATA}{"command"}{$stardev}{$place}{$verb}{$reading};
|
||||
if( defined($cmd) && $cmd ne "" ){
|
||||
$device = $stardev;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( defined($cmd) && $cmd ne "" ){
|
||||
#-- substitution
|
||||
$cmd =~ s/\$DEV/$device/g;
|
||||
@ -1509,9 +1556,8 @@ sub Babble_RemCmd($$$$$){
|
||||
$target="none"
|
||||
if( $target eq "");
|
||||
|
||||
Log 1,"[Babble_RemCmd] Deleting from hash: $bdev.$place.$verb.$target";
|
||||
Log3 $name, 1,"[Babble_RemCmd] Deleting from hash: $bdev.$place.$verb.$target => ".$hash->{DATA}{"command"}{$bdev}{$place}{$verb}{$target};
|
||||
delete($hash->{DATA}{"command"}{$bdev}{$place}{$verb}{$target});
|
||||
|
||||
}
|
||||
|
||||
#########################################################################################
|
||||
@ -1811,6 +1857,7 @@ sub Babble_getverbs($$$) {
|
||||
#-- just do something with the current list
|
||||
}elsif( $type eq "html" ){
|
||||
my @verbsi=@{$hash->{DATA}{"verbsi"}};
|
||||
my $fnd = 0;
|
||||
#-- output
|
||||
if( !defined($sel) ){
|
||||
return "<option></option><option>".join("</option><option>",@verbsi)."</option>";
|
||||
@ -1818,9 +1865,17 @@ sub Babble_getverbs($$$) {
|
||||
my $ret = ($sel eq "none") ? '<option selected="selected">' : '<option>';
|
||||
$ret .= '</option>';
|
||||
for( my $i=0;$i<int(@verbsi);$i++){
|
||||
$ret .= (lc($sel) eq lc($verbsi[$i]) ) ? '<option selected="selected">' : '<option>';
|
||||
if( lc($sel) eq lc($verbsi[$i]) ) {
|
||||
$ret .= '<option selected="selected">';
|
||||
$fnd = 1;
|
||||
}else{
|
||||
$ret .= '<option>';
|
||||
}
|
||||
$ret .= $verbsi[$i].'</option>';
|
||||
}
|
||||
#if( $fnd==0 ){
|
||||
# $ret .= '<option selected="selected" value="unknown">'.$babble_tt->{"unknown"}.'</option>';
|
||||
#}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@ -2081,7 +2136,11 @@ sub Babble_Html($)
|
||||
$rot .= "<input type=\"text\" name=\"d_help\" size=\"51\" maxlength=\"1024\" value=\"".$hlp."\"/></td>";
|
||||
$rot .= "<td style=\"text-align:left;padding-right:10px; border-top:1px solid gray\">".
|
||||
"<input type=\"button\" id=\"d_addrow\" onclick=\"babble_addrow('".$name."',$devcount,$tblrow)\" value=\"".$babble_tt->{"add"}."\" style=\"width:100px;\"/></td></tr>\n";#$tblrow-$devcount.$devrow
|
||||
|
||||
|
||||
#my $json = JSON->new->utf8;
|
||||
#my $jhash0 = eval{ $json->encode( $hash->{DATA}{"command"}{$lbdev} ) };
|
||||
#Log3 $name, 1, "\n\n\n\n $lbdev ========>".Dumper($jhash0);
|
||||
|
||||
foreach my $place (keys %{$hash->{DATA}{"command"}{$lbdev}}){
|
||||
foreach my $verb (keys %{$hash->{DATA}{"command"}{$lbdev}{$place}}){
|
||||
foreach my $target (keys %{$hash->{DATA}{"command"}{$lbdev}{$place}{$verb}}){
|
||||
@ -2201,13 +2260,16 @@ sub Babble_Html($)
|
||||
<li>a FHEM Device name</li>
|
||||
<li>an integer 1..3, indication which of the <i>remoteFHEM</i> functions to be called</li>
|
||||
</ul>
|
||||
The Babble device name may contain a <b>*</b>-character. If this is the case, it will be considered a regular expression, with the star replaced by <b>(.*)</b>.
|
||||
When using Babble with a natural language sentence whose device part matches this regular expression, the character group addressed by the star sequence is placed in the variable
|
||||
<code>$STAR</code>, and used to replace this value in the command sequence.
|
||||
</li>
|
||||
<li><a name="helpFunc"><code>attr <name> helpFunc <function name&rt;</code></a>
|
||||
<br/>name of a help function which is used in case no command is found for a certain device. When this function is called, the strings $DEV, $HELP, $PARM[0|1|2...]
|
||||
will be replaced by the devicename identified by Babble, the help text for this device and parameters passed to the Babble_DoIt function</li>
|
||||
<li><a name="testParm"><code>attr <name> testParm(0|1|2|3) <string&rt;</code></a>
|
||||
<br/>if a command is not really excuted, but only tested, the values of these attributes will be used to substitute the strings $PARM[0|1|2...]
|
||||
in the tested command</li>
|
||||
in the tested command</li>
|
||||
<li><a name="noChatBot"><code>attr <name> noChatBot 0|1</code></a>
|
||||
<br/>if this attribute is set to 1, a local RiveScript interpreter will be ignored even though it is present in the system</li>
|
||||
<li><a name="remoteFHEM"><code>attr <name> remoteFHEM(0|1|2|3) <IP address:port&rt;</code></a>
|
||||
@ -2218,6 +2280,9 @@ sub Babble_Html($)
|
||||
<br/>csrfToken for addressing a certain remote FHEM device</li>
|
||||
<li><a name="babbleIds"><code>attr <name> babbleIds <id_1> <id_2> ...</code></a>
|
||||
<br />space separated list of identities by which babble may be addressed</li>
|
||||
<li><a name="babblePreSubs"><code>attr <name> babbleSubs <regexp1>:<replacement1>,<regexp2>:<replacement2>, ...</code></a>
|
||||
<br/>space separated list of regular expressions and their replacements - this will be used on the initial sentence submitted to Babble
|
||||
(Note: a space in the regexp must be replaced by \s). </li>
|
||||
<li><a name="babblePlaces"><code>attr <name> babblePlaces <place_1> <place_2> ...</code></a>
|
||||
<br />space separated list of special places to be identified in speech</li>
|
||||
<li><a name="babbleNotPlaces"><code>attr <name> babbleNoPlaces <place_1> <place_2> ...</code></a>
|
||||
|
@ -185,10 +185,10 @@ sub PostMe_Check($$) {
|
||||
for( $loop=1;$loop<=$cnop;$loop++){
|
||||
$res = ReadingsVal($devname, sprintf("postme%02dName",$loop), undef);
|
||||
last
|
||||
if($res eq $listname);
|
||||
if(lc($res) eq lc($listname));
|
||||
}
|
||||
#-- no PostMe with this name
|
||||
if( $res ne $listname ){
|
||||
if( lc($res) ne lc($listname) ){
|
||||
return undef;
|
||||
}else{
|
||||
return $loop;
|
||||
|
@ -47,7 +47,7 @@ my $yaahmname;
|
||||
my $yaahmlinkname = "Profile"; # link text
|
||||
my $yaahmhiddenroom = "ProfileRoom"; # hidden room
|
||||
my $yaahmpublicroom = "Unsorted"; # public room
|
||||
my $yaahmversion = "1.47";
|
||||
my $yaahmversion = "1.48";
|
||||
my $firstcall = 1;
|
||||
|
||||
my %yaahm_transtable_EN = (
|
||||
@ -731,6 +731,10 @@ sub YAAHM_Set($@) {
|
||||
}elsif ( $cmd =~ /^checkstate.*/ ) {
|
||||
YAAHM_InternalTimer("check",time()+ $args[0], "YAAHM_checkstate", $hash, 0);
|
||||
|
||||
#-----------------------------------------------------------
|
||||
}elsif ( $cmd =~ /^correctstate.*/ ) {
|
||||
YAAHM_correctstate($hash);
|
||||
|
||||
#-----------------------------------------------------------
|
||||
}elsif ( $cmd =~ /^time.*/ ) {
|
||||
return YAAHM_time($name,$args[0],$exec);
|
||||
@ -839,7 +843,7 @@ sub YAAHM_Set($@) {
|
||||
my $str = "";
|
||||
return "[YAAHM] Unknown argument " . $cmd . ", choose one of".
|
||||
" manualnext time:".join(',',@times)." mode:".join(',',@modes).
|
||||
" state:".join(',',@states)." locked:noArg unlocked:noArg save:noArg checkstate:0,5,10 restore:noArg initialize:noArg createWeekly deleteWeekly";
|
||||
" state:".join(',',@states)." locked:noArg unlocked:noArg save:noArg correctstate:noArg checkstate:0,5,10 restore:noArg initialize:noArg createWeekly deleteWeekly";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1091,6 +1095,8 @@ sub YAAHM_setParm($@) {
|
||||
#
|
||||
# Parameter name = name of the YAAHM device
|
||||
#
|
||||
# Careful: $exec=0 is needed in case we want to prevent execution of helper here
|
||||
#
|
||||
#########################################################################################
|
||||
|
||||
sub YAAHM_time {
|
||||
@ -1178,7 +1184,7 @@ sub YAAHM_time {
|
||||
|
||||
#-- helper function not executed, e.g. by call from external timer
|
||||
return
|
||||
if( !defined($exec) );
|
||||
if( !defined($exec) || $exec==0);
|
||||
|
||||
#-- execute the helper function
|
||||
my $xval;
|
||||
@ -1205,6 +1211,7 @@ sub YAAHM_time {
|
||||
$msg .= "Simulation ".$xval;
|
||||
}
|
||||
if( $exec==1 ){
|
||||
Log3 $name,1,"[YAAHM_time] ecxecuting $xval";
|
||||
fhem($xval);
|
||||
}elsif( $exec==0 ){
|
||||
Log3 $name,1,"[YAAHM_time] ".$msg;
|
||||
@ -1460,6 +1467,65 @@ sub YAAHM_checkstate($) {
|
||||
return undef
|
||||
}
|
||||
|
||||
#########################################################################################
|
||||
#
|
||||
# YAAHM_correctstate - correct state devices
|
||||
#
|
||||
# Parameter someHash = either internal hash of timer
|
||||
# => need to dereference it for getting device hash
|
||||
# or device hash
|
||||
#
|
||||
#########################################################################################
|
||||
|
||||
sub YAAHM_correctstate($) {
|
||||
my ($someHash) = @_;
|
||||
|
||||
my $hash;
|
||||
if( defined($someHash->{HASH}) ){
|
||||
$hash = $someHash->{HASH};
|
||||
}else{
|
||||
$hash = $someHash;
|
||||
}
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
Log3 $name, 1,"[YAAHM_correctstate] on device ".$hash->{NAME}." called";
|
||||
|
||||
my $istate;
|
||||
my $cstate = defined($hash->{DATA}{"HSM"}{"state"}) ? $hash->{DATA}{"HSM"}{"state"} : "";
|
||||
|
||||
return undef
|
||||
if( !defined($attr{$name}{"stateDevices"}) );
|
||||
|
||||
for($istate=0;$istate<int(@states);$istate++){
|
||||
last
|
||||
if($states[$istate] eq $cstate);
|
||||
}
|
||||
|
||||
my (@devlist,@devl);
|
||||
my ($dev,$devs,$devh,);
|
||||
my @devf = ();
|
||||
my $isf = 0;
|
||||
|
||||
@devlist = split(',',$attr{$name}{"stateDevices"});
|
||||
foreach my $devc (@devlist) {
|
||||
@devl = split(':',$devc);
|
||||
$dev = $devl[0];
|
||||
$devs = $devl[$istate+1];
|
||||
if( defined($devs) && ($devs ne "") ){
|
||||
$devh = Value($dev);
|
||||
if( $devs ne $devh ){
|
||||
Log3 $name, 1,"[YAAHM_correctstate] calling set ".$dev." ".$devs;
|
||||
fhem("set ".$dev." ".$devs);
|
||||
$isf = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
YAAHM_checkstate($hash)
|
||||
if($isf == 1);
|
||||
return undef
|
||||
}
|
||||
|
||||
#########################################################################################
|
||||
#
|
||||
# YAAHM_informer - Tell FHEMWEB to inform this page
|
||||
@ -1576,7 +1642,9 @@ sub YAAHM_startDayTimer($) {
|
||||
my $f2 = defined($defaultdailytable{$key}[1]);
|
||||
my $f3 = defined($hash->{DATA}{"DT"}{$key}[2]) && $hash->{DATA}{"DT"}{$key}[2] ne "";
|
||||
|
||||
my $xval = "{YAAHM_time('".$name."','".$key."')},".$hash->{DATA}{"DT"}{$key}[2];
|
||||
#-- uh oh, double execution of functions !!! Do this in YAAHM_time, NOT in timer
|
||||
#my $xval = "{YAAHM_time('".$name."','".$key."')},".$hash->{DATA}{"DT"}{$key}[2];
|
||||
my $xval = "{YAAHM_time('".$name."','".$key."',1)}";
|
||||
|
||||
#-- entries in the default table with no entry are single-timers
|
||||
if( !$f1 and !$f2 ){
|
||||
@ -1651,12 +1719,12 @@ sub YAAHM_startWeeklyTimer($) {
|
||||
$res .= "\nand ([" .$name. ":housemode] =~ \"".$v4a."\")";
|
||||
$res .= "\nand ([" .$name. ":todayType] =~ \"".$v4b."\")";
|
||||
|
||||
#-- action
|
||||
#-- action - explicitly in timer, not in YAAHM_time
|
||||
my $xval = "";
|
||||
if( $i==0 ){
|
||||
$xval = "{YAAHM_time('".$name."','wakeup')},".$hash->{DATA}{"WT"}[$i]{"action"};
|
||||
$xval = "{YAAHM_time('".$name."','wakeup',0)},".$hash->{DATA}{"WT"}[$i]{"action"};
|
||||
}elsif( $i==1 ){
|
||||
$xval = "{YAAHM_time('".$name."','sleep')},".$hash->{DATA}{"WT"}[$i]{"action"};
|
||||
$xval = "{YAAHM_time('".$name."','sleep',0)},".$hash->{DATA}{"WT"}[$i]{"action"};
|
||||
}else{
|
||||
$xval = $hash->{DATA}{"WT"}[$i]{"action"};
|
||||
}
|
||||
@ -3664,6 +3732,15 @@ sub YAAHM_Longtable($){
|
||||
The actual changes to certain devices are made by an external <a href="#yaahm_statehelper">stateHelper function</a>. If these external devices are in their proper state
|
||||
for a particular house (security) state can be checked automatically, see the attribute <a href="#yaahm_statedevices">stateDevices</a>
|
||||
</li>
|
||||
<li><a name="yaahm_checkstate">
|
||||
<code>set <name> checkstate 0|5|10</code>
|
||||
</a>
|
||||
<br/>Check the house (security) state for each of the devices defined in the stateDevices attribute in 0, 5 or 10 seconds from now</li>
|
||||
<li><a name="yaahm_correctstate">
|
||||
<code>set <name> correctstate</code>
|
||||
</a>
|
||||
<br/>Try to correct the house (security) state, by issueing a FHEM command <i>set <device> <targetstate></i>
|
||||
for each of the devices defined in the stateDevices attribute and not in the proper state for the given house (security) state</li>
|
||||
<li><a name="yaahm_createweekly">
|
||||
<code>set <name> createWeekly <string></code>
|
||||
</a>
|
||||
|
@ -1,6 +1,6 @@
|
||||
//########################################################################################
|
||||
// general.rive
|
||||
// Version 0.1
|
||||
// Version 0.2
|
||||
// See 95_Babble.pm for licensing
|
||||
//########################################################################################
|
||||
//# Prof. Dr. Peter A. Henning
|
||||
@ -39,6 +39,15 @@
|
||||
+ wie kannst du * (steuern|schalten)
|
||||
- <call>devhelp <star></call>
|
||||
|
||||
+ wie kannst du (den|das|die) * (steuern|schalten)
|
||||
- <call>devhelp <star2></call>
|
||||
|
||||
+ was kannst du (mit|bei) * (machen|steuern|schalten)
|
||||
- <call>devhelp <star2></call>
|
||||
|
||||
+ was kannst du (mit|bei) (dem|der|den) * (machen|steuern|schalten)
|
||||
- <call>devhelp <star3></call>
|
||||
|
||||
+ was ist *
|
||||
- <call>devhelp <star></call>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user