2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-13 17:26:34 +00:00

fhem.pl: add IsDevice and GetType (Forum #63709)

git-svn-id: https://svn.fhem.de/fhem/trunk@13894 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2017-04-04 15:05:24 +00:00
parent abb6b90e62
commit 969aca78e2

View File

@ -63,12 +63,14 @@ sub FmtDateTime($);
sub FmtTime($); sub FmtTime($);
sub GetLogLevel(@); sub GetLogLevel(@);
sub GetTimeSpec($); sub GetTimeSpec($);
sub GetType($;$);
sub GlobalAttr($$$$); sub GlobalAttr($$$$);
sub HandleArchiving($;$); sub HandleArchiving($;$);
sub HandleTimeout(); sub HandleTimeout();
sub IOWrite($@); sub IOWrite($@);
sub InternalTimer($$$;$); sub InternalTimer($$$;$);
sub InternalVal($$$); sub InternalVal($$$);
sub IsDevice($;$);
sub IsDisabled($); sub IsDisabled($);
sub IsDummy($); sub IsDummy($);
sub IsIgnored($); sub IsIgnored($);
@ -751,6 +753,26 @@ while (1) {
#Functions ahead, no more "plain" code #Functions ahead, no more "plain" code
################################################ ################################################
sub
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 sub
IsDummy($) IsDummy($)
{ {
@ -842,6 +864,16 @@ GetVerbose($)
} }
} }
sub
GetType($;$)
{
my $devname = shift;
my $default = shift;
return $default unless ( IsDevice($devname) && $defs{$devname}{TYPE} );
return $defs{$devname}{TYPE};
}
################################################ ################################################
# the new Log with integrated loglevel checking # the new Log with integrated loglevel checking