diff --git a/fhem/FHEM/10_RESIDENTS.pm b/fhem/FHEM/10_RESIDENTS.pm
index c0b1e546a..97c35e40e 100644
--- a/fhem/FHEM/10_RESIDENTS.pm
+++ b/fhem/FHEM/10_RESIDENTS.pm
@@ -212,7 +212,7 @@ sub RESIDENTS_Notify($$) {
return unless ( $devName ne $hashName ); # only foreign events
return if ( IsDisabled($hashName) or IsDisabled($devName) );
return
- unless ( RESIDENTStk_IsDevice( $devName, "ROOMMATE|GUEST|dummy" ) );
+ unless ( IsDevice( $devName, "ROOMMATE|GUEST|dummy" ) );
my @registeredRoommates =
split( /,/, $hash->{ROOMMATES} )
@@ -461,11 +461,11 @@ sub RESIDENTS_Set($@) {
# define roommate
fhem( "define " . $rr_name . " ROOMMATE " . $name )
- unless ( RESIDENTStk_IsDevice($rr_name) );
+ unless ( IsDevice($rr_name) );
- if ( RESIDENTStk_IsDevice($rr_name) ) {
+ if ( IsDevice($rr_name) ) {
return "Can't create, device $rr_name already existing."
- unless ( RESIDENTStk_IsDevice( $rr_name, "ROOMMATE" ) );
+ unless ( IsDevice( $rr_name, "ROOMMATE" ) );
my $lang =
$a[3]
@@ -497,7 +497,7 @@ sub RESIDENTS_Set($@) {
my $rr_name = $a[2];
# delete roommate
- if ( RESIDENTStk_IsDevice($rr_name) ) {
+ if ( IsDevice($rr_name) ) {
Log3 $name, 3, "RESIDENTS $name: deleted device $rr_name"
if fhem( "delete " . $rr_name );
}
@@ -521,11 +521,11 @@ sub RESIDENTS_Set($@) {
# define guest
fhem( "define " . $rg_name . " GUEST " . $name )
- unless ( RESIDENTStk_IsDevice($rg_name) );
+ unless ( IsDevice($rg_name) );
- if ( RESIDENTStk_IsDevice($rg_name) ) {
+ if ( IsDevice($rg_name) ) {
return "Can't create, device $rg_name already existing."
- unless ( RESIDENTStk_IsDevice( $rg_name, "GUEST" ) );
+ unless ( IsDevice( $rg_name, "GUEST" ) );
my $lang =
$a[3]
@@ -557,7 +557,7 @@ sub RESIDENTS_Set($@) {
my $rg_name = $a[2];
# delete guest
- if ( RESIDENTStk_IsDevice($rg_name) ) {
+ if ( IsDevice($rg_name) ) {
Log3 $name, 3, "RESIDENTS $name: deleted device $rg_name"
if fhem( "delete " . $rg_name );
}
@@ -575,7 +575,7 @@ sub RESIDENTS_Set($@) {
my $created = 0;
until ($created) {
- if ( RESIDENTStk_IsDevice($wakeuptimerName) ) {
+ if ( IsDevice($wakeuptimerName) ) {
$i++;
$wakeuptimerName = $name . "_wakeuptimer" . $i;
}
@@ -1414,7 +1414,7 @@ sub RESIDENTS_UpdateReadings (@) {
for my $wakeupDevice ( split /,/, $wakeupDeviceList ) {
next if !$wakeupDevice;
- if ( RESIDENTStk_IsDevice( $wakeupDevice, "dummy" ) ) {
+ if ( IsDevice( $wakeupDevice, "dummy" ) ) {
# forced-stop only if resident is not present anymore
if ( $newpresence eq "present" ) {
diff --git a/fhem/FHEM/20_GUEST.pm b/fhem/FHEM/20_GUEST.pm
index da31b8e8b..e1ba3978d 100644
--- a/fhem/FHEM/20_GUEST.pm
+++ b/fhem/FHEM/20_GUEST.pm
@@ -73,7 +73,7 @@ sub GUEST_Define($$) {
if ( defined( $hash->{RESIDENTGROUPS} ) ) {
foreach ( split( /,/, $hash->{RESIDENTGROUPS} ) ) {
RESIDENTStk_findResidentSlaves( $defs{$_} )
- if ( RESIDENTStk_IsDevice( $_, "RESIDENTS" ) );
+ if ( IsDevice( $_, "RESIDENTS" ) );
}
}
@@ -213,7 +213,7 @@ sub GUEST_Undefine($$) {
delete $hash->{RESIDENTGROUPS};
foreach ( split( /,/, $old ) ) {
RESIDENTStk_findResidentSlaves( $defs{$_} )
- if ( RESIDENTStk_IsDevice( $_, "RESIDENTS" ) );
+ if ( IsDevice( $_, "RESIDENTS" ) );
}
}
@@ -247,7 +247,7 @@ sub GUEST_Notify($$) {
# make sure computeAfterInit is set at at-device
# and re-calculate on our own this time
- if ( RESIDENTStk_IsDevice( $wakeupAtdevice, "at" )
+ if ( IsDevice( $wakeupAtdevice, "at" )
&& AttrVal( $wakeupAtdevice, "computeAfterInit", 0 ) ne
"1" )
{
@@ -578,7 +578,7 @@ sub GUEST_Set($@) {
for my $wakeupDevice ( split /,/, $wakeupDeviceList ) {
next if !$wakeupDevice;
- if ( RESIDENTStk_IsDevice( $wakeupDevice, "dummy" ) ) {
+ if ( IsDevice( $wakeupDevice, "dummy" ) ) {
# forced-stop only if resident is not present anymore
if ( $newpresence eq "present" ) {
@@ -694,7 +694,7 @@ sub GUEST_Set($@) {
split( ' ', $attr{$name}{"rg_passPresenceTo"} );
foreach my $object (@linkedObjects) {
- if ( RESIDENTStk_IsDevice( $object, "ROOMMATE|GUEST" )
+ if ( IsDevice( $object, "ROOMMATE|GUEST" )
&& $defs{$object} ne $name
&& ReadingsVal( $object, "state", "" ) ne "gone"
&& ReadingsVal( $object, "state", "" ) ne "none" )
@@ -867,7 +867,7 @@ sub GUEST_Set($@) {
my $created = 0;
until ($created) {
- if ( RESIDENTStk_IsDevice($wakeuptimerName) ) {
+ if ( IsDevice($wakeuptimerName) ) {
$i++;
$wakeuptimerName = $name . "_wakeuptimer" . $i;
}
@@ -920,7 +920,7 @@ sub GUEST_Set($@) {
elsif ( lc( $a[2] ) eq "locationmap" ) {
my $locationmapName = $name . "_map";
- if ( RESIDENTStk_IsDevice($locationmapName) ) {
+ if ( IsDevice($locationmapName) ) {
return
"Device $locationmapName existing already, delete it first to have it re-created.";
}
diff --git a/fhem/FHEM/20_ROOMMATE.pm b/fhem/FHEM/20_ROOMMATE.pm
index 0ab945735..92e2059ae 100644
--- a/fhem/FHEM/20_ROOMMATE.pm
+++ b/fhem/FHEM/20_ROOMMATE.pm
@@ -74,7 +74,7 @@ sub ROOMMATE_Define($$) {
if ( defined( $hash->{RESIDENTGROUPS} ) ) {
foreach ( split( /,/, $hash->{RESIDENTGROUPS} ) ) {
RESIDENTStk_findResidentSlaves( $defs{$_} )
- if ( RESIDENTStk_IsDevice( $_, "RESIDENTS" ) );
+ if ( IsDevice( $_, "RESIDENTS" ) );
}
}
@@ -216,7 +216,7 @@ sub ROOMMATE_Undefine($$) {
delete $hash->{RESIDENTGROUPS};
foreach ( split( /,/, $old ) ) {
RESIDENTStk_findResidentSlaves( $defs{$_} )
- if ( RESIDENTStk_IsDevice( $_, "RESIDENTS" ) );
+ if ( IsDevice( $_, "RESIDENTS" ) );
}
}
@@ -250,7 +250,7 @@ sub ROOMMATE_Notify($$) {
# make sure computeAfterInit is set at at-device
# and re-calculate on our own this time
- if ( RESIDENTStk_IsDevice( $wakeupAtdevice, "at" )
+ if ( IsDevice( $wakeupAtdevice, "at" )
&& AttrVal( $wakeupAtdevice, "computeAfterInit", 0 ) ne
"1" )
{
@@ -580,7 +580,7 @@ sub ROOMMATE_Set($@) {
for my $wakeupDevice ( split /,/, $wakeupDeviceList ) {
next if !$wakeupDevice;
- if ( RESIDENTStk_IsDevice( $wakeupDevice, "dummy" ) ) {
+ if ( IsDevice( $wakeupDevice, "dummy" ) ) {
# forced-stop only if resident is not present anymore
if ( $newpresence eq "present" ) {
@@ -696,7 +696,7 @@ sub ROOMMATE_Set($@) {
split( ' ', $attr{$name}{"rr_passPresenceTo"} );
foreach my $object (@linkedObjects) {
- if ( RESIDENTStk_IsDevice( $object, "ROOMMATE|GUEST" )
+ if ( IsDevice( $object, "ROOMMATE|GUEST" )
&& $defs{$object} ne $name
&& ReadingsVal( $object, "state", "" ) ne "gone"
&& ReadingsVal( $object, "state", "" ) ne "none" )
@@ -849,7 +849,7 @@ sub ROOMMATE_Set($@) {
my $created = 0;
until ($created) {
- if ( RESIDENTStk_IsDevice($wakeuptimerName) ) {
+ if ( IsDevice($wakeuptimerName) ) {
$i++;
$wakeuptimerName = $name . "_wakeuptimer" . $i;
}
@@ -902,7 +902,7 @@ sub ROOMMATE_Set($@) {
elsif ( lc( $a[2] ) eq "locationmap" ) {
my $locationmapName = $name . "_map";
- if ( RESIDENTStk_IsDevice($locationmapName) ) {
+ if ( IsDevice($locationmapName) ) {
return
"Device $locationmapName existing already, delete it first to have it re-created.";
}
diff --git a/fhem/FHEM/70_ONKYO_AVR.pm b/fhem/FHEM/70_ONKYO_AVR.pm
index ce2042786..e415c5472 100644
--- a/fhem/FHEM/70_ONKYO_AVR.pm
+++ b/fhem/FHEM/70_ONKYO_AVR.pm
@@ -136,7 +136,7 @@ sub ONKYO_AVR_removeExtension($) {
my $url = "?/$link";
my $name = $data{FWEXT}{$url}{deviceName};
Log3 $name, 2,
- "ONKYO_AVR $name: Unregistering ONKYO_AVR for webhook URL $url...";
+ "ONKYO_AVR $name: Unregistering ONKYO_AVR for webhook URI $url...";
delete $data{FWEXT}{$url};
}
diff --git a/fhem/FHEM/70_PHTV.pm b/fhem/FHEM/70_PHTV.pm
index 9bc9f6ffb..aa64522b0 100644
--- a/fhem/FHEM/70_PHTV.pm
+++ b/fhem/FHEM/70_PHTV.pm
@@ -2652,9 +2652,7 @@ m/^\s*(([{\[][\s\S]+[}\]])|(\s*
\s*\s*Ok\s*<\/title>\s*<\/head
Log3 $name, 5, $logtext;
# next for if HUE device is not ready
- if ( !defined( $defs{$dev} )
- || !defined( $defs{$dev}{TYPE} )
- || $defs{$dev}{TYPE} ne "HUEDevice"
+ if ( !IsDevice( $dev, "HUEDevice" )
|| ReadingsVal( $dev, "reachable", 0 ) ne
"1" )
{
diff --git a/fhem/FHEM/74_THINKINGCLEANER.pm b/fhem/FHEM/74_THINKINGCLEANER.pm
index 6f3738c17..a67c16cf4 100644
--- a/fhem/FHEM/74_THINKINGCLEANER.pm
+++ b/fhem/FHEM/74_THINKINGCLEANER.pm
@@ -1030,7 +1030,7 @@ sub THINKINGCLEANER_removeExtension($) {
my $url = "?/$link";
my $name = $data{FWEXT}{$url}{deviceName};
Log3 $name, 2,
-"THINKINGCLEANER $name: Unregistering THINKINGCLEANER for webhook URL $url...";
+"THINKINGCLEANER $name: Unregistering THINKINGCLEANER for webhook URI $url...";
delete $data{FWEXT}{$url};
}
diff --git a/fhem/FHEM/75_msgConfig.pm b/fhem/FHEM/75_msgConfig.pm
index 5965dd1d6..2ed6a2681 100755
--- a/fhem/FHEM/75_msgConfig.pm
+++ b/fhem/FHEM/75_msgConfig.pm
@@ -255,9 +255,10 @@ sub msgConfig_Set($@) {
$device =~ s/[\s\t-]+/_/g;
return "Device $device is already existing but not a dummy device"
- if ( msgConfig_IsDevice($device) && msgConfig_GetType($device) ne "dummy" );
+ if ( IsDevice($device)
+ && GetType($device) ne "dummy" );
- if ( !msgConfig_IsDevice($device) ) {
+ if ( !IsDevice($device) ) {
$return = fhem( "define $device dummy", 1 );
$return .= "Device $device was created"
if ( $return eq "" );
@@ -302,9 +303,10 @@ sub msgConfig_Set($@) {
if ( defined( $a[0] ) && $a[0] eq "de" );
return "Device $device is already existing but not a dummy device"
- if ( msgConfig_IsDevice($device) && msgConfig_GetType($device) ne "dummy" );
+ if ( IsDevice($device)
+ && GetType($device) ne "dummy" );
- if ( !msgConfig_IsDevice($device) ) {
+ if ( !IsDevice($device) ) {
$return = fhem( "define $device dummy", 1 );
$return .= "Device $device was created"
if ( $return eq "" );
@@ -361,19 +363,17 @@ sub msgConfig_Set($@) {
return
"Device $device is already existing but not a RESIDENTS or ROOMMATE device"
- if ( msgConfig_IsDevice($device)
- && !msgConfig_IsDevice( $device, "RESIDENTS|ROOMMATE" ) );
+ if ( IsDevice($device)
+ && !IsDevice( $device, "RESIDENTS|ROOMMATE" ) );
- if ( !msgConfig_IsDevice($device) ) {
+ if ( !IsDevice($device) ) {
$return = fhem( "define $device RESIDENTS", 1 );
$return .= "RESIDENTS device $device was created."
if ( $return eq "" );
}
else {
$return =
- "Existing "
- . msgConfig_GetType($device)
- . " device $device was updated.";
+ "Existing " . GetType($device) . " device $device was updated.";
}
my $txt = fhem("attr $device rgr_lang $lang")
@@ -426,12 +426,12 @@ sub msgConfig_Get($@) {
# Check device
if ( $devicesReq ne "" ) {
foreach my $device ( split( /,/, $devicesReq ) ) {
- if ( msgConfig_IsDevice($device) ) {
- $UserDeviceTypes .= "," . msgConfig_GetType($device)
+ if ( IsDevice($device) ) {
+ $UserDeviceTypes .= "," . GetType($device)
if ( $UserDeviceTypes ne ""
&& $msgType ne "mail"
&& $device ne $name );
- $UserDeviceTypes = msgConfig_GetType($device)
+ $UserDeviceTypes = GetType($device)
if ( $UserDeviceTypes eq ""
&& $msgType ne "mail"
&& $device ne $name );
@@ -470,7 +470,7 @@ sub msgConfig_Get($@) {
if ( $output == 0 );
$return .=
" $device (DEVICE TYPE: "
- . msgConfig_GetType($device) . ")\n"
+ . GetType($device) . ")\n"
if ( $output == 0 );
$output = 1 if ( $output == 0 );
@@ -665,38 +665,62 @@ sub msgConfig_FindReadingsVal($$$$) {
}
########################################
-sub msgConfig_IsDevice($;$) {
- my $devname = shift;
- my $devtype = shift;
- $devtype = ".*" unless ( $devtype && $devtype ne "" );
+sub msgConfig_QueueAdd(@) {
+ my (
+ $msgA, $params, $datetime, $msgID,
+ $minorID, $type, $recipient, $subRecipient,
+ $termRecipient, $priority, $title, $msg
+ ) = @_;
- return 1
- if ( defined($devname)
- && defined( $defs{$devname} )
- && ref( $defs{$devname} ) eq "HASH"
- && defined( $defs{$devname}{NAME} )
- && $defs{$devname}{NAME} eq $devname
- && defined( $defs{$devname}{TYPE} )
- && $defs{$devname}{TYPE} =~ m/^$devtype$/
- && defined( $modules{ $defs{$devname}{TYPE} } )
- && defined( $modules{ $defs{$devname}{TYPE} }{LOADED} )
- && $modules{ $defs{$devname}{TYPE} }{LOADED} );
+ my $name = $modules{msgConfig}{defptr}{NAME};
- delete $defs{$devname}
- if ( defined($devname)
- && defined( $defs{$devname} )
- && $devtype eq ".*" );
+ return 0 if ( $defs{$name}{queue}{$recipient}{"$msgID.$minorID"} );
- return 0;
+ $defs{$name}{queue}{$recipient}{"$msgID.$minorID"} = {
+ msgOrig => $msgA,
+ msgOrigParams => $params,
+ datetime => $datetime,
+ majorId => $msgID,
+ minorId => $minorID,
+ type => $type,
+ recipient => $recipient,
+ subRecipient => $subRecipient,
+ terminalRecipient => $termRecipient,
+ priority => $priority,
+ title => $title,
+ message => $msg,
+ };
+
+ delete $defs{$name}{queue}{$recipient}{"$msgID.$minorID"}{msgOrigParams}
+ {msgQID};
+
+ readingsSingleUpdate(
+ $defs{$name},
+ "Q_" . $recipient,
+ scalar keys %{ $defs{$name}{queue}{$recipient} }, 1
+ );
+
+ return 1;
}
########################################
-sub msgConfig_GetType($;$) {
- my $devname = shift;
- my $default = shift;
+sub msgConfig_QueueReleaseMsgId($$) {
+ my ( $recipient, $msgID ) = @_;
- return $default unless ( msgConfig_IsDevice($devname) );
- return $defs{$devname}{TYPE};
+ my $name = $modules{msgConfig}{defptr}{NAME};
+
+ return 0
+ unless ( $defs{$name}{queue}
+ && $defs{$name}{queue}{$recipient}
+ && $defs{$name}{queue}{$recipient}{$msgID} );
+
+ delete $defs{$name}{queue}{$recipient}{$msgID};
+ my $c = scalar keys %{ $defs{$name}{queue}{$recipient} };
+ delete $defs{$name}{queue}{$recipient} unless ($c);
+
+ readingsSingleUpdate( $defs{$name}, "Q_" . $recipient, $c, 1 );
+
+ return 1;
}
1;
diff --git a/fhem/FHEM/98_powerMap.pm b/fhem/FHEM/98_powerMap.pm
index efaf136a1..f76cf9d03 100644
--- a/fhem/FHEM/98_powerMap.pm
+++ b/fhem/FHEM/98_powerMap.pm
@@ -845,45 +845,45 @@ sub powerMap_AttrVal($$$$) {
# $defs{device}{TYPE}{attribute}
return $defs{$d}{$TYPE}{$n}
if ( $d
- && defined( $defs{$d} )
+ && IsDevice($d)
&& defined( $defs{$d}{$TYPE} )
&& defined( $defs{$d}{$TYPE}{$n} ) );
# $defs{device}{.TYPE}{attribute}
return $defs{$d}{".$TYPE"}{$n}
if ( $d
- && defined( $defs{$d} )
+ && IsDevice($d)
&& defined( $defs{$d}{".$TYPE"} )
&& defined( $defs{$d}{".$TYPE"}{$n} ) );
# $defs{device}{TYPE_attribute}
return $defs{$d}{ $TYPE . "_" . $n }
if ( $d
- && defined( $defs{$d} )
+ && IsDevice($d)
&& defined( $defs{$d}{ $TYPE . "_" . $n } ) );
# $defs{device}{attribute}
return $defs{$d}{$n}
if ( $d
- && defined( $defs{$d} )
+ && IsDevice($d)
&& defined( $defs{$d}{$n} ) );
# $defs{device}{.TYPE_attribute}
return $defs{$d}{ "." . $TYPE . "_" . $n }
if ( $d
- && defined( $defs{$d} )
+ && IsDevice($d)
&& defined( $defs{$d}{ "." . $TYPE . "_" . $n } ) );
# $defs{device}{.attribute}
return $defs{$d}{".$n"}
if ( $d
- && defined( $defs{$d} )
+ && IsDevice($d)
&& defined( $defs{$d}{".$n"} ) );
# module HASH
#
- my $t = $defs{$d}{TYPE};
+ my $t = GetType($d);
# $modules{module}{TYPE}{attribute}
return $modules{$t}{$TYPE}{$n}
@@ -1024,8 +1024,7 @@ sub powerMap_findPowerMaps($;$) {
# directly return any existing device specific definition
if ( $dev && $dev !~ /^:/ ) {
return {}
- unless ( defined( $defs{$dev} )
- && defined( $defs{$dev}{TYPE} ) );
+ unless ( IsDevice($dev) );
return $defs{$dev}{powerMap}{map}
if (
diff --git a/fhem/FHEM/RESIDENTStk.pm b/fhem/FHEM/RESIDENTStk.pm
index 315d9ff7c..c548b485d 100644
--- a/fhem/FHEM/RESIDENTStk.pm
+++ b/fhem/FHEM/RESIDENTStk.pm
@@ -87,7 +87,7 @@ m/^(off|nextrun|trigger|start|stop|end|reset|auto|[\+\-][1-9]*[0-9]*|[\+\-]?[0-9
my $wakeupUserdeviceRealname = "Bewohner";
- if ( RESIDENTStk_IsDevice( $wakeupUserdevice, "ROOMMATE" ) ) {
+ if ( IsDevice( $wakeupUserdevice, "ROOMMATE" ) ) {
$wakeupUserdeviceRealname = AttrVal(
AttrVal( $NAME, "wakeupUserdevice", "" ),
AttrVal(
@@ -97,7 +97,7 @@ m/^(off|nextrun|trigger|start|stop|end|reset|auto|[\+\-][1-9]*[0-9]*|[\+\-]?[0-9
$wakeupUserdeviceRealname
);
}
- elsif ( RESIDENTStk_IsDevice( $wakeupUserdevice, "GUEST" ) ) {
+ elsif ( IsDevice( $wakeupUserdevice, "GUEST" ) ) {
$wakeupUserdeviceRealname = AttrVal(
AttrVal( $NAME, "wakeupUserdevice", "" ),
AttrVal(
@@ -122,13 +122,11 @@ m/^(off|nextrun|trigger|start|stop|end|reset|auto|[\+\-][1-9]*[0-9]*|[\+\-]?[0-9
Log3 $NAME, 3,
"RESIDENTStk $NAME: WARNING - set attribute wakeupUserdevice before running wakeup function!";
}
- elsif ( !RESIDENTStk_IsDevice($wakeupUserdevice) ) {
+ elsif ( !IsDevice($wakeupUserdevice) ) {
Log3 $NAME, 3,
"RESIDENTStk $NAME: WARNING - user device $wakeupUserdevice does not exist!";
}
- elsif (
- !RESIDENTStk_IsDevice( $wakeupUserdevice, "RESIDENTS|ROOMMATE|GUEST" ) )
- {
+ elsif ( !IsDevice( $wakeupUserdevice, "RESIDENTS|ROOMMATE|GUEST" ) ) {
Log3 $NAME, 3,
"RESIDENTStk $NAME: WARNING - defined user device '$wakeupUserdevice' is not a RESIDENTS, ROOMMATE or GUEST device!";
}
@@ -140,7 +138,7 @@ m/^(off|nextrun|trigger|start|stop|end|reset|auto|[\+\-][1-9]*[0-9]*|[\+\-]?[0-9
fhem "attr $NAME wakeupMacro $macroName";
$wakeupMacro = $macroName;
}
- if ( !RESIDENTStk_IsDevice($wakeupMacro) ) {
+ if ( !IsDevice($wakeupMacro) ) {
my $wakeUpMacroTemplate = "{\
##=============================================================================\
## This is an example wake-up program running within a period of 30 minutes:\
@@ -232,7 +230,7 @@ if (\$EVTPART0 eq \"stop\") {\
fhem "attr $wakeupMacro room $room"
if ($room);
}
- elsif ( RESIDENTStk_GetType($wakeupMacro) ne "notify" ) {
+ elsif ( GetType($wakeupMacro) ne "notify" ) {
Log3 $NAME, 3,
"RESIDENTStk $NAME: WARNING - defined macro device '$wakeupMacro' is not a notify device!";
}
@@ -244,7 +242,7 @@ if (\$EVTPART0 eq \"stop\") {\
fhem "attr $NAME wakeupAtdevice $atName";
$wakeupAtdevice = $atName;
}
- if ( !RESIDENTStk_IsDevice($wakeupAtdevice) ) {
+ if ( !IsDevice($wakeupAtdevice) ) {
Log3 $NAME, 3,
"RESIDENTStk $NAME: new at-device $wakeupAtdevice created";
fhem
@@ -260,8 +258,8 @@ if (\$EVTPART0 eq \"stop\") {\
# for ROOMMATE or GUEST devices
# macro: gotosleep
- if ( RESIDENTStk_GetType($wakeupUserdevice) ne "RESIDENTS"
- && !RESIDENTStk_IsDevice($macroNameGotosleep) )
+ if ( GetType($wakeupUserdevice) ne "RESIDENTS"
+ && !IsDevice($macroNameGotosleep) )
{
my $templateGotosleep = "{\
##=============================================================================\
@@ -326,7 +324,7 @@ return;;\
}
# wd: gotosleep
- if ( !RESIDENTStk_IsDevice($wdNameGotosleep) ) {
+ if ( !IsDevice($wdNameGotosleep) ) {
Log3 $NAME, 3,
"RESIDENTStk $NAME: new watchdog device $wdNameGotosleep created";
fhem
@@ -339,8 +337,8 @@ return;;\
}
# macro: asleep
- if ( RESIDENTStk_GetType($wakeupUserdevice) ne "RESIDENTS"
- && !RESIDENTStk_IsDevice($macroNameAsleep) )
+ if ( GetType($wakeupUserdevice) ne "RESIDENTS"
+ && !IsDevice($macroNameAsleep) )
{
my $templateAsleep = "{\
##=============================================================================\
@@ -401,7 +399,7 @@ return;;\
}
# wd: asleep
- if ( !RESIDENTStk_IsDevice($wdNameAsleep) ) {
+ if ( !IsDevice($wdNameAsleep) ) {
Log3 $NAME, 3,
"RESIDENTStk $NAME: new watchdog device $wdNameAsleep created";
fhem
@@ -414,8 +412,8 @@ return;;\
}
# macro: awoken
- if ( RESIDENTStk_GetType($wakeupUserdevice) ne "RESIDENTS"
- && !RESIDENTStk_IsDevice($macroNameAwoken) )
+ if ( GetType($wakeupUserdevice) ne "RESIDENTS"
+ && !IsDevice($macroNameAwoken) )
{
my $templateAwoken = "{\
##=============================================================================\
@@ -472,7 +470,7 @@ return;;\
}
# wd: awoken
- if ( !RESIDENTStk_IsDevice($wdNameAwoken) ) {
+ if ( !IsDevice($wdNameAwoken) ) {
Log3 $NAME, 3,
"RESIDENTStk $NAME: new watchdog device $wdNameAwoken created";
fhem
@@ -490,10 +488,10 @@ return;;\
#
my $RESIDENTGROUPS = "";
- if ( RESIDENTStk_IsDevice( $wakeupUserdevice, "RESIDENTS" ) ) {
+ if ( IsDevice( $wakeupUserdevice, "RESIDENTS" ) ) {
$RESIDENTGROUPS = $wakeupUserdevice;
}
- elsif ( RESIDENTStk_IsDevice($wakeupUserdevice)
+ elsif ( IsDevice($wakeupUserdevice)
&& defined( $defs{$wakeupUserdevice}{RESIDENTGROUPS} ) )
{
$RESIDENTGROUPS = $defs{$wakeupUserdevice}{RESIDENTGROUPS};
@@ -508,7 +506,7 @@ return;;\
my $wdRNameAwoken = "wd_" . $deviceName . "_awoken";
# macro: gotosleep
- if ( !RESIDENTStk_IsDevice($macroRNameGotosleep) ) {
+ if ( !IsDevice($macroRNameGotosleep) ) {
my $templateGotosleep = "{\
##=============================================================================\
## This is an example macro when all residents are gettin' ready for bed.\
@@ -554,7 +552,7 @@ return;;\
}
# wd: gotosleep
- if ( !RESIDENTStk_IsDevice($wdRNameGotosleep) ) {
+ if ( !IsDevice($wdRNameGotosleep) ) {
Log3 $NAME, 3,
"RESIDENTStk $NAME: new watchdog device $wdRNameGotosleep created";
fhem
@@ -567,7 +565,7 @@ return;;\
}
# macro: asleep
- if ( !RESIDENTStk_IsDevice($macroRNameAsleep) ) {
+ if ( !IsDevice($macroRNameAsleep) ) {
my $templateAsleep = "{\
##=============================================================================\
## This is an example macro when all residents are in their beds.\
@@ -613,7 +611,7 @@ return;;\
}
# wd: asleep
- if ( !RESIDENTStk_IsDevice($wdRNameAsleep) ) {
+ if ( !IsDevice($wdRNameAsleep) ) {
Log3 $NAME, 3,
"RESIDENTStk $NAME: new watchdog device $wdNameAsleep created";
fhem
@@ -626,7 +624,7 @@ return;;\
}
# macro: awoken
- if ( !RESIDENTStk_IsDevice($macroRNameAwoken) ) {
+ if ( !IsDevice($macroRNameAwoken) ) {
my $templateAwoken = "{\
##=============================================================================\
## This is an example macro when the first resident has confirmed to be awake\
@@ -675,7 +673,7 @@ return;;\
}
# wd: awoken
- if ( !RESIDENTStk_IsDevice($wdRNameAwoken) ) {
+ if ( !IsDevice($wdRNameAwoken) ) {
Log3 $NAME, 3,
"RESIDENTStk $NAME: new watchdog device $wdNameAwoken created";
fhem
@@ -690,7 +688,7 @@ return;;\
}
}
- elsif ( RESIDENTStk_GetType($wakeupAtdevice) ne "at" ) {
+ elsif ( GetType($wakeupAtdevice) ne "at" ) {
Log3 $NAME, 3,
"RESIDENTStk $NAME: WARNING - defined at-device '$wakeupAtdevice' is not an at-device!";
}
@@ -708,13 +706,13 @@ return;;\
return
"ERROR: wakeupHolidays set in this alarm clock but global attribute holiday2we not set!";
}
- elsif ( !RESIDENTStk_IsDevice($holidayDevice) ) {
+ elsif ( !IsDevice($holidayDevice) ) {
Log3 $NAME, 3,
"RESIDENTStk $NAME: ERROR - global attribute holiday2we has reference to non-existing device $holidayDevice";
return
"ERROR: global attribute holiday2we has reference to non-existing device $holidayDevice";
}
- elsif ( RESIDENTStk_GetType($holidayDevice) ne "holiday" ) {
+ elsif ( GetType($holidayDevice) ne "holiday" ) {
Log3 $NAME, 3,
"RESIDENTStk $NAME: ERROR - global attribute holiday2we seems to have invalid device reference - $holidayDevice is not of type 'holiday'";
return
@@ -746,11 +744,11 @@ return;;\
if ( !$wakeupMacro ) {
Log3 $NAME, 2, "RESIDENTStk $NAME: missing attribute wakeupMacro";
}
- elsif ( !RESIDENTStk_IsDevice($wakeupMacro) ) {
+ elsif ( !IsDevice($wakeupMacro) ) {
Log3 $NAME, 2,
"RESIDENTStk $NAME: notify macro $wakeupMacro not found - no wakeup actions defined!";
}
- elsif ( RESIDENTStk_GetType($wakeupMacro) ne "notify" ) {
+ elsif ( GetType($wakeupMacro) ne "notify" ) {
Log3 $NAME, 2,
"RESIDENTStk $NAME: device $wakeupMacro is not of type notify";
}
@@ -784,7 +782,7 @@ return;;\
}
my $wakeupStopAtdevice = $wakeupAtdevice . "_stop";
- if ( RESIDENTStk_IsDevice($wakeupStopAtdevice) ) {
+ if ( IsDevice($wakeupStopAtdevice) ) {
fhem "delete $wakeupStopAtdevice";
}
}
@@ -826,7 +824,7 @@ return;;\
|| $VALUE =~ /^[\+\-][1-9]*[0-9]*$/
|| $VALUE =~ /^[\+\-]?([0-9]{2}):([0-9]{2})$/
)
- && RESIDENTStk_GetType($wakeupAtdevice) eq "at"
+ && GetType($wakeupAtdevice) eq "at"
)
{
@@ -901,17 +899,17 @@ sub RESIDENTStk_wakeupGetBegin($;$) {
# just give any valuable return to at-device
# if wakeuptimer device does not exit anymore
# and run self-destruction to clean up
- if ( !RESIDENTStk_IsDevice($NAME) ) {
+ if ( !IsDevice($NAME) ) {
Log3 $NAME, 3,
"RESIDENTStk $NAME: this wake-up timer device does not exist anymore";
my $atName = "at_" . $NAME;
- if ( RESIDENTStk_GetType($wakeupAtdevice) eq "at" ) {
+ if ( GetType($wakeupAtdevice) eq "at" ) {
Log3 $NAME, 3,
"RESIDENTStk $NAME: Cleaning up at-device $wakeupAtdevice (self-destruction)";
fhem "sleep 1; delete $wakeupAtdevice";
}
- elsif ( RESIDENTStk_GetType($atName) eq "at" ) {
+ elsif ( GetType($atName) eq "at" ) {
Log3 $NAME, 3, "RESIDENTStk $NAME: Cleaning up at-device $atName";
fhem "sleep 1; delete $atName";
}
@@ -983,7 +981,7 @@ sub RESIDENTStk_wakeupRun($;$) {
my $holidayToday = "";
if ( $wakeupHolidays
- && RESIDENTStk_GetType($holidayDevice) eq "holiday" )
+ && GetType($holidayDevice) eq "holiday" )
{
my $hdayTod = ReadingsVal( $holidayDevice, "state", "" );
@@ -1035,7 +1033,7 @@ sub RESIDENTStk_wakeupRun($;$) {
if ( $wakeupResetdays ne "" );
my %rdays = map { $_ => 1 } @rdays;
- if ( !RESIDENTStk_IsDevice($NAME) ) {
+ if ( !IsDevice($NAME) ) {
return "$NAME: Non existing device";
}
elsif ( lc($nextRun) eq "off" && !$forceRun ) {
@@ -1045,16 +1043,14 @@ sub RESIDENTStk_wakeupRun($;$) {
elsif ( !$wakeupUserdevice ) {
return "$NAME: missing attribute wakeupUserdevice";
}
- elsif ( !RESIDENTStk_IsDevice($wakeupUserdevice) ) {
+ elsif ( !IsDevice($wakeupUserdevice) ) {
return "$NAME: Non existing wakeupUserdevice $wakeupUserdevice";
}
- elsif (
- !RESIDENTStk_IsDevice( $wakeupUserdevice, "RESIDENTS|ROOMMATE|GUEST" ) )
- {
+ elsif ( !IsDevice( $wakeupUserdevice, "RESIDENTS|ROOMMATE|GUEST" ) ) {
return
"$NAME: device $wakeupUserdevice is not of type RESIDENTS, ROOMMATE or GUEST";
}
- elsif ( RESIDENTStk_GetType($wakeupUserdevice) eq "GUEST"
+ elsif ( GetType($wakeupUserdevice) eq "GUEST"
&& $wakeupUserdeviceState eq "none" )
{
Log3 $NAME, 4,
@@ -1134,11 +1130,11 @@ sub RESIDENTStk_wakeupRun($;$) {
if ( !$wakeupMacro ) {
return "$NAME: missing attribute wakeupMacro";
}
- elsif ( !RESIDENTStk_IsDevice($wakeupMacro) ) {
+ elsif ( !IsDevice($wakeupMacro) ) {
return
"$NAME: notify macro $wakeupMacro not found - no wakeup actions defined!";
}
- elsif ( RESIDENTStk_GetType($wakeupMacro) ne "notify" ) {
+ elsif ( GetType($wakeupMacro) ne "notify" ) {
return "$NAME: device $wakeupMacro is not of type notify";
}
elsif ($wakeupUserdeviceWakeup) {
@@ -1189,7 +1185,7 @@ sub RESIDENTStk_wakeupRun($;$) {
if ( $wakeupOffset > 0 ) {
my $wakeupStopAtdevice = $wakeupAtdevice . "_stop";
- if ( RESIDENTStk_IsDevice($wakeupStopAtdevice) ) {
+ if ( IsDevice($wakeupStopAtdevice) ) {
fhem "delete $wakeupStopAtdevice";
}
@@ -1231,7 +1227,7 @@ sub RESIDENTStk_wakeupRun($;$) {
my $doReset = 1;
if ( $wakeupResetSwitcher
- && RESIDENTStk_GetType($wakeupResetSwitcher) eq "dummy"
+ && GetType($wakeupResetSwitcher) eq "dummy"
&& ReadingsVal( $wakeupResetSwitcher, "state", 0 ) eq "off" )
{
$doReset = 0;
@@ -1266,7 +1262,7 @@ sub RESIDENTStk_AttrFnDummy(@) {
# wakeupResetSwitcher
if ( $aName eq "wakeupResetSwitcher" ) {
- if ( !RESIDENTStk_IsDevice($aVal) ) {
+ if ( !IsDevice($aVal) ) {
my $alias = AttrVal( $name, "alias", 0 );
my $group = AttrVal( $name, "group", 0 );
my $room = AttrVal( $name, "room", 0 );
@@ -1294,7 +1290,7 @@ sub RESIDENTStk_AttrFnDummy(@) {
Log3 $name, 3,
"RESIDENTStk $name: new slave dummy device $aVal created";
}
- elsif ( RESIDENTStk_GetType($aVal) ne "dummy" ) {
+ elsif ( GetType($aVal) ne "dummy" ) {
Log3 $name, 3,
"RESIDENTStk $name: Defined device name in attr $aName is not a dummy device";
return "Existing device $aVal is not a dummy!";
@@ -1346,7 +1342,7 @@ sub RESIDENTStk_wakeupGetNext($) {
for my $wakeupDevice ( split /,/, $wakeupDeviceList ) {
next if !$wakeupDevice;
- if ( !RESIDENTStk_IsDevice($wakeupDevice) ) {
+ if ( !IsDevice($wakeupDevice) ) {
Log3 $name, 4,
"RESIDENTStk $name: 00 - ignoring reference to non-existing wakeupDevice $wakeupDevice";
@@ -1371,7 +1367,7 @@ sub RESIDENTStk_wakeupGetNext($) {
my $wakeupAtdevice = AttrVal( $wakeupDevice, "wakeupAtdevice", 0 );
my $wakeupOffset = AttrVal( $wakeupDevice, "wakeupOffset", 0 );
my $wakeupAtNTM = (
- RESIDENTStk_IsDevice($wakeupAtdevice)
+ IsDevice($wakeupAtdevice)
&& defined( $defs{$wakeupAtdevice}{NTM} )
? substr( $defs{$wakeupAtdevice}{NTM}, 0, -3 )
: 0
@@ -1384,7 +1380,7 @@ sub RESIDENTStk_wakeupGetNext($) {
# get holiday status for today and tomorrow
if ( $wakeupHolidays
&& $holidayDevice
- && RESIDENTStk_GetType($holidayDevice) eq "holiday" )
+ && GetType($holidayDevice) eq "holiday" )
{
if ( $hdayTod ne "none" && $hdayTod ne "" ) {
$holidayToday = 1;
@@ -1779,31 +1775,4 @@ sub RESIDENTStk_findResidentSlaves($) {
}
}
-sub RESIDENTStk_IsDevice($;$) {
- my $devname = shift;
- my $devtype = shift;
-
- return 1
- if ( defined($devname)
- && defined( $defs{$devname} )
- && ( !$devtype || $devtype eq "" ) );
-
- return 1
- if ( defined($devname)
- && defined( $defs{$devname} )
- && defined( $defs{$devname}{TYPE} )
- && $defs{$devname}{TYPE} =~ m/^$devtype$/ );
-
- return 0;
-}
-
-sub RESIDENTStk_GetType($;$) {
- my $devname = shift;
- my $default = shift;
-
- return $default
- unless ( RESIDENTStk_IsDevice($devname) && $defs{$devname}{TYPE} );
- return $defs{$devname}{TYPE};
-}
-
1;
diff --git a/fhem/FHEM/Unit.pm b/fhem/FHEM/Unit.pm
index 005733233..b37371133 100644
--- a/fhem/FHEM/Unit.pm
+++ b/fhem/FHEM/Unit.pm
@@ -4458,7 +4458,7 @@ sub CommandSetReadingDesc($@) {
my @rets;
my $last;
foreach my $name ( devspec2array( $a->[0], $cl ) ) {
- unless ( Unit_IsDevice($name) ) {
+ unless ( IsDevice($name) ) {
push @rets, "Please define $name first";
next;
}
@@ -4524,7 +4524,7 @@ sub CommandDeleteReadingDesc($@) {
my @rets;
my $last;
foreach my $name ( devspec2array( $a->[0], $cl ) ) {
- unless ( Unit_IsDevice($name) ) {
+ unless ( IsDevice($name) ) {
push @rets, "Please define $name first";
next;
}
@@ -4549,22 +4549,4 @@ sub CommandDeleteReadingDesc($@) {
return join( "\n", @rets );
}
-sub Unit_IsDevice($;$) {
- my $devname = shift;
- my $devtype = shift;
-
- return 1
- if ( defined($devname)
- && defined( $defs{$devname} )
- && ( !$devtype || $devtype eq "" ) );
-
- return 1
- if ( defined($devname)
- && defined( $defs{$devname} )
- && defined( $defs{$devname}{TYPE} )
- && $defs{$devname}{TYPE} =~ m/^$devtype$/ );
-
- return 0;
-}
-
1;