|
|
|
@ -47,10 +47,10 @@ sub msgConfig_Undefine($$);
|
|
|
|
|
sub msgConfig_Initialize($) {
|
|
|
|
|
my ($hash) = @_;
|
|
|
|
|
|
|
|
|
|
$hash->{DefFn} = "msgConfig_Define";
|
|
|
|
|
$hash->{SetFn} = "msgConfig_Set";
|
|
|
|
|
$hash->{GetFn} = "msgConfig_Get";
|
|
|
|
|
$hash->{UndefFn} = "msgConfig_Undefine";
|
|
|
|
|
$hash->{DefFn} = "msgConfig_Define";
|
|
|
|
|
$hash->{SetFn} = "msgConfig_Set";
|
|
|
|
|
$hash->{GetFn} = "msgConfig_Get";
|
|
|
|
|
$hash->{UndefFn} = "msgConfig_Undefine";
|
|
|
|
|
|
|
|
|
|
# add attributes for configuration
|
|
|
|
|
no warnings 'qw';
|
|
|
|
@ -141,23 +141,24 @@ sub msgConfig_Define($$) {
|
|
|
|
|
|
|
|
|
|
return "Usage: define <name> msgConfig"
|
|
|
|
|
if ( int(@a) < 2 );
|
|
|
|
|
my $name = $a[0];
|
|
|
|
|
my $name = $a[0];
|
|
|
|
|
|
|
|
|
|
return "Global configuration device already defined: " . $modules{msgConfig}{defptr}{NAME}
|
|
|
|
|
if (defined($modules{msgConfig}{defptr}));
|
|
|
|
|
return "Global configuration device already defined: "
|
|
|
|
|
. $modules{msgConfig}{defptr}{NAME}
|
|
|
|
|
if ( defined( $modules{msgConfig}{defptr} ) );
|
|
|
|
|
|
|
|
|
|
# create global unique device definition
|
|
|
|
|
$modules{msgConfig}{defptr} = $hash;
|
|
|
|
|
|
|
|
|
|
# set default settings on first define
|
|
|
|
|
if ($init_done) {
|
|
|
|
|
my $group = AttrVal("global","group","Global");
|
|
|
|
|
my $room = AttrVal("global","room","");
|
|
|
|
|
my $verbose = AttrVal("global","verbose",3);
|
|
|
|
|
my $group = AttrVal( "global", "group", "Global" );
|
|
|
|
|
my $room = AttrVal( "global", "room", "" );
|
|
|
|
|
my $verbose = AttrVal( "global", "verbose", 3 );
|
|
|
|
|
|
|
|
|
|
$attr{$name}{group} = $group;
|
|
|
|
|
$attr{$name}{group} = $group;
|
|
|
|
|
$attr{$name}{verbose} = $verbose;
|
|
|
|
|
$attr{$name}{room} = $room if ($room ne "");
|
|
|
|
|
$attr{$name}{room} = $room if ( $room ne "" );
|
|
|
|
|
$attr{$name}{comment} = "FHEM Global Configuration for command 'msg'";
|
|
|
|
|
$attr{$name}{stateFormat} = "fhemMsgState";
|
|
|
|
|
|
|
|
|
@ -189,98 +190,121 @@ sub msgConfig_Set($@) {
|
|
|
|
|
|
|
|
|
|
Log3 $name, 5, "msgConfig $name: called function msgConfig_Set()";
|
|
|
|
|
|
|
|
|
|
my @msgTypes =
|
|
|
|
|
( "audio", "light", "mail", "push", "screen" );
|
|
|
|
|
my @msgTypes = ( "audio", "light", "mail", "push", "screen" );
|
|
|
|
|
|
|
|
|
|
# cleanReadings
|
|
|
|
|
if ( lc($what) eq "cleanreadings" ) {
|
|
|
|
|
my $device = defined($a[0]) ? $a[0] : ".*";
|
|
|
|
|
my $device = defined( $a[0] ) ? $a[0] : ".*";
|
|
|
|
|
|
|
|
|
|
return fhem ("deletereading $device fhemMsg.*", 1);
|
|
|
|
|
return fhem( "deletereading $device fhemMsg.*", 1 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# addLocation
|
|
|
|
|
elsif ( lc($what) eq "addlocation" ) {
|
|
|
|
|
my $location = join(" ", @a);
|
|
|
|
|
my $group = AttrVal($name, "group", "msgConfig");
|
|
|
|
|
my $room = AttrVal($name, "room", "");
|
|
|
|
|
my $location = join( " ", @a );
|
|
|
|
|
my $group = AttrVal( $name, "group", "msgConfig" );
|
|
|
|
|
my $room = AttrVal( $name, "room", "" );
|
|
|
|
|
my $return = "";
|
|
|
|
|
|
|
|
|
|
return "Missing argument 'location'"
|
|
|
|
|
if ($location eq "");
|
|
|
|
|
if ( $location eq "" );
|
|
|
|
|
|
|
|
|
|
my $device = "msgRoom_" . $location;
|
|
|
|
|
$device =~ s/[\s\t-]+/_/g;
|
|
|
|
|
|
|
|
|
|
return "Device $device is already existing but not a dummy device"
|
|
|
|
|
if (defined($defs{$device}) && $defs{$device}{TYPE} ne "dummy");
|
|
|
|
|
|
|
|
|
|
if (!defined($defs{$device})) {
|
|
|
|
|
$return = fhem ("define $device dummy", 1);
|
|
|
|
|
$return .= "Device $device was created"
|
|
|
|
|
if ($return eq "");
|
|
|
|
|
} else {
|
|
|
|
|
$return = "Existing dummy device $device was updated";
|
|
|
|
|
return "Device $device is already existing but not a dummy device"
|
|
|
|
|
if ( defined( $defs{$device} ) && $defs{$device}{TYPE} ne "dummy" );
|
|
|
|
|
|
|
|
|
|
if ( !defined( $defs{$device} ) ) {
|
|
|
|
|
$return = fhem( "define $device dummy", 1 );
|
|
|
|
|
$return .= "Device $device was created"
|
|
|
|
|
if ( $return eq "" );
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$return = "Existing dummy device $device was updated";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$attr{$device}{group} = $group if (!defined($attr{$device}{group}));
|
|
|
|
|
$attr{$device}{room} = $room if (!defined($attr{$device}{room}) && $room ne "");
|
|
|
|
|
$attr{$device}{comment} = "Auto-created by $name" if (!defined($attr{$device}{comment}));
|
|
|
|
|
$attr{$device}{userattr} .= " msgLocationName" if (defined($attr{$device}{userattr}) && $attr{$device}{userattr} !~ /^msgLocationName$|^msgLocationName\s|\smsgLocationName\s|\smsgLocationName$/);
|
|
|
|
|
$attr{$device}{userattr} = "msgLocationName" if (!defined($attr{$device}{userattr}));
|
|
|
|
|
$attr{$device}{group} = $group if ( !defined( $attr{$device}{group} ) );
|
|
|
|
|
$attr{$device}{room} = $room
|
|
|
|
|
if ( !defined( $attr{$device}{room} ) && $room ne "" );
|
|
|
|
|
$attr{$device}{comment} = "Auto-created by $name"
|
|
|
|
|
if ( !defined( $attr{$device}{comment} ) );
|
|
|
|
|
$attr{$device}{userattr} .= " msgLocationName"
|
|
|
|
|
if ( defined( $attr{$device}{userattr} )
|
|
|
|
|
&& $attr{$device}{userattr} !~
|
|
|
|
|
/^msgLocationName$|^msgLocationName\s|\smsgLocationName\s|\smsgLocationName$/
|
|
|
|
|
);
|
|
|
|
|
$attr{$device}{userattr} = "msgLocationName"
|
|
|
|
|
if ( !defined( $attr{$device}{userattr} ) );
|
|
|
|
|
$attr{$device}{msgLocationName} = $location;
|
|
|
|
|
fhem ("set $device $location");
|
|
|
|
|
fhem("set $device $location");
|
|
|
|
|
|
|
|
|
|
$attr{$name}{msgLocationDevs} .= "," . $device
|
|
|
|
|
if ( defined( $attr{$name}{msgLocationDevs} )
|
|
|
|
|
&& $attr{$name}{msgLocationDevs} !~
|
|
|
|
|
/^$device\$|^$device,|,$device,|,$device$/ );
|
|
|
|
|
$attr{$name}{msgLocationDevs} = $device
|
|
|
|
|
if ( !defined( $attr{$name}{msgLocationDevs} ) );
|
|
|
|
|
|
|
|
|
|
$attr{$name}{msgLocationDevs} .= ",".$device if (defined($attr{$name}{msgLocationDevs}) && $attr{$name}{msgLocationDevs} !~ /^$device\$|^$device,|,$device,|,$device$/);
|
|
|
|
|
$attr{$name}{msgLocationDevs} = $device if (!defined($attr{$name}{msgLocationDevs}));
|
|
|
|
|
|
|
|
|
|
return $return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# createSwitcherDev
|
|
|
|
|
elsif ( lc($what) eq "createswitcherdev" ) {
|
|
|
|
|
my $device = AttrVal($name, "msgSwitcherDev", "HouseAnn");
|
|
|
|
|
my $state = AttrVal($device, "state", "???");
|
|
|
|
|
my $device = AttrVal( $name, "msgSwitcherDev", "HouseAnn" );
|
|
|
|
|
my $state = AttrVal( $device, "state", "???" );
|
|
|
|
|
my $return = "";
|
|
|
|
|
|
|
|
|
|
my $lang = "en";
|
|
|
|
|
$lang = $a[0]
|
|
|
|
|
if (defined($a[0]) && $a[0] eq "de");
|
|
|
|
|
if ( defined( $a[0] ) && $a[0] eq "de" );
|
|
|
|
|
|
|
|
|
|
return "Device $device is already existing but not a dummy device"
|
|
|
|
|
if (defined($defs{$device}) && $defs{$device}{TYPE} ne "dummy");
|
|
|
|
|
if ( defined( $defs{$device} ) && $defs{$device}{TYPE} ne "dummy" );
|
|
|
|
|
|
|
|
|
|
if (!defined($defs{$device})) {
|
|
|
|
|
$return = fhem ("define $device dummy", 1);
|
|
|
|
|
$return .= "Device $device was created"
|
|
|
|
|
if ($return eq "");
|
|
|
|
|
} else {
|
|
|
|
|
$return = "Existing dummy device $device was updated";
|
|
|
|
|
if ( !defined( $defs{$device} ) ) {
|
|
|
|
|
$return = fhem( "define $device dummy", 1 );
|
|
|
|
|
$return .= "Device $device was created"
|
|
|
|
|
if ( $return eq "" );
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$return = "Existing dummy device $device was updated";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($lang eq "de") {
|
|
|
|
|
$attr{$device}{alias} = "Durchsagen";
|
|
|
|
|
$attr{$device}{eventMap} = "active:aktiv long:lang short:kurz visual:visuell off:aus";
|
|
|
|
|
$attr{$device}{room} = "Haus" if (!defined($attr{$device}{room}));
|
|
|
|
|
$attr{$device}{setList} = "state:lang,kurz,visuell,aus";
|
|
|
|
|
} else {
|
|
|
|
|
$attr{$device}{alias} = "Announcements";
|
|
|
|
|
$attr{$device}{room} = "House" if (!defined($attr{$device}{room}));
|
|
|
|
|
$attr{$device}{setList} = "state:long,short,visual,off";
|
|
|
|
|
delete $attr{$device}{eventMap} if (defined($attr{$device}{eventMap}));
|
|
|
|
|
if ( $lang eq "de" ) {
|
|
|
|
|
$attr{$device}{alias} = "Durchsagen";
|
|
|
|
|
$attr{$device}{eventMap} =
|
|
|
|
|
"active:aktiv long:lang short:kurz visual:visuell off:aus";
|
|
|
|
|
$attr{$device}{room} = "Haus"
|
|
|
|
|
if ( !defined( $attr{$device}{room} ) );
|
|
|
|
|
$attr{$device}{setList} = "state:lang,kurz,visuell,aus";
|
|
|
|
|
}
|
|
|
|
|
$attr{$device}{comment} = "Auto-created by $name" if (!defined($attr{$device}{comment}) || $attr{$device}{comment} ne "Auto-created by $name");
|
|
|
|
|
$attr{$device}{devStateIcon} = 'aktiv:general_an@90EE90 active:general_an@90EE90 lang:general_an@green:off long:general_an@green:off aus:general_aus@red:long off:general_aus@red:long kurz:general_an@orange:long short:general_an@orange:long visuell:general_an@orange:long visual:general_an@orange:long';
|
|
|
|
|
$attr{$device}{"event-on-change-reading"} = "state" if (!defined($attr{$device}{"event-on-change-reading"}));
|
|
|
|
|
$attr{$device}{group} = "Automation" if (!defined($attr{$device}{group}));
|
|
|
|
|
$attr{$device}{icon} = "audio_volume_mid";
|
|
|
|
|
else {
|
|
|
|
|
$attr{$device}{alias} = "Announcements";
|
|
|
|
|
$attr{$device}{room} = "House"
|
|
|
|
|
if ( !defined( $attr{$device}{room} ) );
|
|
|
|
|
$attr{$device}{setList} = "state:long,short,visual,off";
|
|
|
|
|
delete $attr{$device}{eventMap}
|
|
|
|
|
if ( defined( $attr{$device}{eventMap} ) );
|
|
|
|
|
}
|
|
|
|
|
$attr{$device}{comment} = "Auto-created by $name"
|
|
|
|
|
if ( !defined( $attr{$device}{comment} )
|
|
|
|
|
|| $attr{$device}{comment} ne "Auto-created by $name" );
|
|
|
|
|
$attr{$device}{devStateIcon} =
|
|
|
|
|
'aktiv:general_an@90EE90 active:general_an@90EE90 lang:general_an@green:off long:general_an@green:off aus:general_aus@red:long off:general_aus@red:long kurz:general_an@orange:long short:general_an@orange:long visuell:general_an@orange:long visual:general_an@orange:long';
|
|
|
|
|
$attr{$device}{"event-on-change-reading"} = "state"
|
|
|
|
|
if ( !defined( $attr{$device}{"event-on-change-reading"} ) );
|
|
|
|
|
$attr{$device}{group} = "Automation"
|
|
|
|
|
if ( !defined( $attr{$device}{group} ) );
|
|
|
|
|
$attr{$device}{icon} = "audio_volume_mid";
|
|
|
|
|
$attr{$device}{webCmd} = "state";
|
|
|
|
|
fhem ("set $device long") if ($state eq "???");
|
|
|
|
|
fhem("set $device long") if ( $state eq "???" );
|
|
|
|
|
|
|
|
|
|
$return .= "\nAttribute msgSwitcherDev at device $name was changed to $device"
|
|
|
|
|
if (defined($attr{$name}{msgSwitcherDev}));
|
|
|
|
|
$return .=
|
|
|
|
|
"\nAttribute msgSwitcherDev at device $name was changed to $device"
|
|
|
|
|
if ( defined( $attr{$name}{msgSwitcherDev} ) );
|
|
|
|
|
$return .= "\nAdded attribute msgSwitcherDev to device $name"
|
|
|
|
|
if (!defined($attr{$name}{msgSwitcherDev}));
|
|
|
|
|
if ( !defined( $attr{$name}{msgSwitcherDev} ) );
|
|
|
|
|
$attr{$name}{msgSwitcherDev} = $device;
|
|
|
|
|
|
|
|
|
|
return $return;
|
|
|
|
@ -288,44 +312,68 @@ sub msgConfig_Set($@) {
|
|
|
|
|
|
|
|
|
|
# createResidentsDev
|
|
|
|
|
elsif ( lc($what) eq "createresidentsdev" ) {
|
|
|
|
|
my $device = AttrVal($name, "msgResidentsDev", "rgr_Residents");
|
|
|
|
|
my $device = AttrVal( $name, "msgResidentsDev", "rgr_Residents" );
|
|
|
|
|
my $return = "";
|
|
|
|
|
|
|
|
|
|
my $lang = "en";
|
|
|
|
|
$lang = $a[0]
|
|
|
|
|
if (defined($a[0]) && $a[0] eq "de");
|
|
|
|
|
if ( defined( $a[0] ) && $a[0] eq "de" );
|
|
|
|
|
|
|
|
|
|
return "Device $device is already existing but not a RESIDENTS or ROOMMATE device"
|
|
|
|
|
if (defined($defs{$device}) && ($defs{$device}{TYPE} ne "RESIDENTS" && $defs{$device}{TYPE} ne "ROOMMATE"));
|
|
|
|
|
return
|
|
|
|
|
"Device $device is already existing but not a RESIDENTS or ROOMMATE device"
|
|
|
|
|
if (
|
|
|
|
|
defined( $defs{$device} )
|
|
|
|
|
&& ( $defs{$device}{TYPE} ne "RESIDENTS"
|
|
|
|
|
&& $defs{$device}{TYPE} ne "ROOMMATE" )
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!defined($defs{$device})) {
|
|
|
|
|
$return = fhem ("define $device RESIDENTS", 1);
|
|
|
|
|
$return .= "RESIDENTS device $device was created."
|
|
|
|
|
if ($return eq "");
|
|
|
|
|
} else {
|
|
|
|
|
$return = "Existing ".$defs{$device}{TYPE}." device $device was updated.";
|
|
|
|
|
if ( !defined( $defs{$device} ) ) {
|
|
|
|
|
$return = fhem( "define $device RESIDENTS", 1 );
|
|
|
|
|
$return .= "RESIDENTS device $device was created."
|
|
|
|
|
if ( $return eq "" );
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$return =
|
|
|
|
|
"Existing "
|
|
|
|
|
. $defs{$device}{TYPE}
|
|
|
|
|
. " device $device was updated.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($lang eq "de") {
|
|
|
|
|
$attr{$device}{alias} = "Bewohner";
|
|
|
|
|
$attr{$device}{eventMap} = "home:zu_Hause absent:außer_Haus gone:verreist gotosleep:bettfertig asleep:schläft awoken:aufgestanden";
|
|
|
|
|
$attr{$device}{group} = "Haus Status" if (!defined($attr{$device}{group}));
|
|
|
|
|
$attr{$device}{room} = "Haus" if (!defined($attr{$device}{room}));
|
|
|
|
|
$attr{$device}{widgetOverride} = "state:zu_Hause,bettfertig,außer_Haus,verreist";
|
|
|
|
|
} else {
|
|
|
|
|
$attr{$device}{alias} = "Residents";
|
|
|
|
|
$attr{$device}{group} = "Home State" if (!defined($attr{$device}{group}));
|
|
|
|
|
$attr{$device}{room} = "House" if (!defined($attr{$device}{room}));
|
|
|
|
|
delete $attr{$device}{eventMap} if (defined($attr{$device}{eventMap}));
|
|
|
|
|
delete $attr{$device}{widgetOverride} if (defined($attr{$device}{widgetOverride}));
|
|
|
|
|
if ( $lang eq "de" ) {
|
|
|
|
|
$attr{$device}{alias} = "Bewohner";
|
|
|
|
|
$attr{$device}{eventMap} =
|
|
|
|
|
"home:zu_Hause absent:außer_Haus gone:verreist gotosleep:bettfertig asleep:schläft awoken:aufgestanden";
|
|
|
|
|
$attr{$device}{group} = "Haus Status"
|
|
|
|
|
if ( !defined( $attr{$device}{group} ) );
|
|
|
|
|
$attr{$device}{room} = "Haus"
|
|
|
|
|
if ( !defined( $attr{$device}{room} ) );
|
|
|
|
|
$attr{$device}{widgetOverride} =
|
|
|
|
|
"state:zu_Hause,bettfertig,außer_Haus,verreist";
|
|
|
|
|
}
|
|
|
|
|
$attr{$device}{comment} = "Auto-created by $name" if (!defined($attr{$device}{comment}) || $attr{$device}{comment} ne "Auto-created by $name");
|
|
|
|
|
$attr{$device}{devStateIcon} = '.*home:status_available@green .*absent:status_away_1@orange .*gone:status_standby .*none:control_building_empty .*gotosleep:status_night@green:asleep .*asleep:status_night@green .*awoken:status_available@green:home .*zu_Hause:user_available:absent .*außer_Haus:user_away:home .*verreist:user_ext_away:home .*bettfertig:scene_toilet:asleep .*schläft:scene_sleeping:awoken .*aufgestanden:scene_sleeping_alternat:home .*:user_unknown';
|
|
|
|
|
else {
|
|
|
|
|
$attr{$device}{alias} = "Residents";
|
|
|
|
|
$attr{$device}{group} = "Home State"
|
|
|
|
|
if ( !defined( $attr{$device}{group} ) );
|
|
|
|
|
$attr{$device}{room} = "House"
|
|
|
|
|
if ( !defined( $attr{$device}{room} ) );
|
|
|
|
|
delete $attr{$device}{eventMap}
|
|
|
|
|
if ( defined( $attr{$device}{eventMap} ) );
|
|
|
|
|
delete $attr{$device}{widgetOverride}
|
|
|
|
|
if ( defined( $attr{$device}{widgetOverride} ) );
|
|
|
|
|
}
|
|
|
|
|
$attr{$device}{comment} = "Auto-created by $name"
|
|
|
|
|
if ( !defined( $attr{$device}{comment} )
|
|
|
|
|
|| $attr{$device}{comment} ne "Auto-created by $name" );
|
|
|
|
|
$attr{$device}{devStateIcon} =
|
|
|
|
|
'.*home:status_available@green .*absent:status_away_1@orange .*gone:status_standby .*none:control_building_empty .*gotosleep:status_night@green:asleep .*asleep:status_night@green .*awoken:status_available@green:home .*zu_Hause:user_available:absent .*außer_Haus:user_away:home .*verreist:user_ext_away:home .*bettfertig:scene_toilet:asleep .*schläft:scene_sleeping:awoken .*aufgestanden:scene_sleeping_alternat:home .*:user_unknown';
|
|
|
|
|
|
|
|
|
|
$return .= "\nIf you would like this device to act as an overall presence device for ALL msg commands, please adjust attribute msgResidentsDev at device $name to $device."
|
|
|
|
|
if (defined($attr{$name}{msgResidentsDev}) && $attr{$name}{msgResidentsDev} ne $device);
|
|
|
|
|
$return .= "\nNext, set a device's msgResidentsDev attribute to '$device' (think of using 'userattr' to add 'msgResidentsDev' to the list of available attributes). \nIf you would like '$device' to act as an overall presence device for ALL msg commands, sett attribute msgResidentsDev at device $name to $device."
|
|
|
|
|
if (!defined($attr{$name}{msgResidentsDev}));
|
|
|
|
|
$return .=
|
|
|
|
|
"\nIf you would like this device to act as an overall presence device for ALL msg commands, please adjust attribute msgResidentsDev at device $name to $device."
|
|
|
|
|
if ( defined( $attr{$name}{msgResidentsDev} )
|
|
|
|
|
&& $attr{$name}{msgResidentsDev} ne $device );
|
|
|
|
|
$return .=
|
|
|
|
|
"\nNext, set a device's msgResidentsDev attribute to '$device' (think of using 'userattr' to add 'msgResidentsDev' to the list of available attributes). \nIf you would like '$device' to act as an overall presence device for ALL msg commands, sett attribute msgResidentsDev at device $name to $device."
|
|
|
|
|
if ( !defined( $attr{$name}{msgResidentsDev} ) );
|
|
|
|
|
|
|
|
|
|
return $return;
|
|
|
|
|
}
|
|
|
|
@ -345,160 +393,209 @@ sub msgConfig_Get($@) {
|
|
|
|
|
|
|
|
|
|
Log3 $name, 5, "msgConfig $name: called function msgConfig_Get()";
|
|
|
|
|
|
|
|
|
|
my @msgTypes =
|
|
|
|
|
( "audio", "light", "mail", "push", "screen" );
|
|
|
|
|
my @msgTypes = ( "audio", "light", "mail", "push", "screen" );
|
|
|
|
|
|
|
|
|
|
# routeCmd
|
|
|
|
|
if ( lc($what) eq "routecmd" ) {
|
|
|
|
|
my $return = "";
|
|
|
|
|
my $msgTypesReq = defined($a[0]) ? lc($a[0]) : join( ',', @msgTypes );
|
|
|
|
|
my $devicesReq = defined($a[1]) ? $a[1] : $name;
|
|
|
|
|
my $cmdSchema = msgSchema::get();
|
|
|
|
|
my $msgTypesReq =
|
|
|
|
|
defined( $a[0] ) ? lc( $a[0] ) : join( ',', @msgTypes );
|
|
|
|
|
my $devicesReq = defined( $a[1] ) ? $a[1] : $name;
|
|
|
|
|
my $cmdSchema = msgSchema::get();
|
|
|
|
|
my $UserDeviceTypes = "";
|
|
|
|
|
|
|
|
|
|
foreach my $msgType (split( /,/, $msgTypesReq )) {
|
|
|
|
|
foreach my $msgType ( split( /,/, $msgTypesReq ) ) {
|
|
|
|
|
|
|
|
|
|
# Check device
|
|
|
|
|
if ($devicesReq ne "") {
|
|
|
|
|
foreach my $device (split( /,/, $devicesReq )) {
|
|
|
|
|
if (defined($defs{$device})) {
|
|
|
|
|
$UserDeviceTypes .= ",".$defs{$device}{TYPE} if ($UserDeviceTypes ne "" && $msgType ne "mail" && $device ne $name);
|
|
|
|
|
$UserDeviceTypes = $defs{$device}{TYPE} if ($UserDeviceTypes eq "" && $msgType ne "mail" && $device ne $name);
|
|
|
|
|
$UserDeviceTypes .= ",fhemMsgMail" if ($UserDeviceTypes ne "" && $msgType eq "mail" && $device ne $name);
|
|
|
|
|
$UserDeviceTypes = "fhemMsgMail" if ($UserDeviceTypes eq "" && $msgType eq "mail" && $device ne $name);
|
|
|
|
|
# Check device
|
|
|
|
|
if ( $devicesReq ne "" ) {
|
|
|
|
|
foreach my $device ( split( /,/, $devicesReq ) ) {
|
|
|
|
|
if ( defined( $defs{$device} ) ) {
|
|
|
|
|
$UserDeviceTypes .= "," . $defs{$device}{TYPE}
|
|
|
|
|
if ( $UserDeviceTypes ne ""
|
|
|
|
|
&& $msgType ne "mail"
|
|
|
|
|
&& $device ne $name );
|
|
|
|
|
$UserDeviceTypes = $defs{$device}{TYPE}
|
|
|
|
|
if ( $UserDeviceTypes eq ""
|
|
|
|
|
&& $msgType ne "mail"
|
|
|
|
|
&& $device ne $name );
|
|
|
|
|
$UserDeviceTypes .= ",fhemMsgMail"
|
|
|
|
|
if ( $UserDeviceTypes ne ""
|
|
|
|
|
&& $msgType eq "mail"
|
|
|
|
|
&& $device ne $name );
|
|
|
|
|
$UserDeviceTypes = "fhemMsgMail"
|
|
|
|
|
if ( $UserDeviceTypes eq ""
|
|
|
|
|
&& $msgType eq "mail"
|
|
|
|
|
&& $device ne $name );
|
|
|
|
|
|
|
|
|
|
my $typeUc = ucfirst($msgType);
|
|
|
|
|
my $typeUc = ucfirst($msgType);
|
|
|
|
|
|
|
|
|
|
my @priorities;
|
|
|
|
|
@priorities = ("Normal", "ShortPrio", "Short") if ($msgType eq "audio");
|
|
|
|
|
@priorities = ("Normal", "High", "Low") if ($msgType ne "audio");
|
|
|
|
|
my @priorities;
|
|
|
|
|
@priorities = ( "Normal", "ShortPrio", "Short" )
|
|
|
|
|
if ( $msgType eq "audio" );
|
|
|
|
|
@priorities = ( "Normal", "High", "Low" )
|
|
|
|
|
if ( $msgType ne "audio" );
|
|
|
|
|
|
|
|
|
|
my $output = 0;
|
|
|
|
|
foreach my $prio (@priorities) {
|
|
|
|
|
my $priorityCat = "";
|
|
|
|
|
$priorityCat = $prio if ($prio ne "Normal");
|
|
|
|
|
|
|
|
|
|
my $cmd =
|
|
|
|
|
# look for direct
|
|
|
|
|
my $output = 0;
|
|
|
|
|
foreach my $prio (@priorities) {
|
|
|
|
|
my $priorityCat = "";
|
|
|
|
|
$priorityCat = $prio if ( $prio ne "Normal" );
|
|
|
|
|
|
|
|
|
|
my $cmd =
|
|
|
|
|
|
|
|
|
|
# look for direct
|
|
|
|
|
AttrVal(
|
|
|
|
|
$device, "msgCmd$typeUc$priorityCat",
|
|
|
|
|
|
|
|
|
|
# look for indirect
|
|
|
|
|
AttrVal(
|
|
|
|
|
$device, "msgCmd$typeUc$priorityCat",
|
|
|
|
|
|
|
|
|
|
# look for indirect
|
|
|
|
|
AttrVal(
|
|
|
|
|
AttrVal(
|
|
|
|
|
$device, "msgRecipient$typeUc",
|
|
|
|
|
""
|
|
|
|
|
),
|
|
|
|
|
$device, "msgRecipient$typeUc", ""
|
|
|
|
|
),
|
|
|
|
|
"msgCmd$typeUc$priorityCat",
|
|
|
|
|
|
|
|
|
|
#look for indirect general
|
|
|
|
|
AttrVal(
|
|
|
|
|
AttrVal( $device, "msgRecipient", "" ),
|
|
|
|
|
"msgCmd$typeUc$priorityCat",
|
|
|
|
|
|
|
|
|
|
#look for indirect general
|
|
|
|
|
# look for global direct
|
|
|
|
|
AttrVal(
|
|
|
|
|
AttrVal(
|
|
|
|
|
$device, "msgRecipient", ""
|
|
|
|
|
),
|
|
|
|
|
$name,
|
|
|
|
|
"msgCmd$typeUc$priorityCat",
|
|
|
|
|
|
|
|
|
|
# look for global direct
|
|
|
|
|
# look for global indirect
|
|
|
|
|
AttrVal(
|
|
|
|
|
$name,
|
|
|
|
|
AttrVal(
|
|
|
|
|
$name,
|
|
|
|
|
"msgRecipient$typeUc", ""
|
|
|
|
|
),
|
|
|
|
|
"msgCmd$typeUc$priorityCat",
|
|
|
|
|
|
|
|
|
|
# look for global indirect
|
|
|
|
|
#look for global indirect general
|
|
|
|
|
AttrVal(
|
|
|
|
|
AttrVal(
|
|
|
|
|
$name,
|
|
|
|
|
"msgRecipient$typeUc",
|
|
|
|
|
$name, "msgRecipient",
|
|
|
|
|
""
|
|
|
|
|
),
|
|
|
|
|
"msgCmd$typeUc$priorityCat",
|
|
|
|
|
|
|
|
|
|
#look for global indirect general
|
|
|
|
|
AttrVal(
|
|
|
|
|
AttrVal(
|
|
|
|
|
$name,
|
|
|
|
|
"msgRecipient",
|
|
|
|
|
""
|
|
|
|
|
), "msgCmd$typeUc$priorityCat",
|
|
|
|
|
|
|
|
|
|
# none
|
|
|
|
|
""
|
|
|
|
|
)
|
|
|
|
|
# none
|
|
|
|
|
""
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
next if ($cmd eq "" && $device eq $name && $output == 0);
|
|
|
|
|
$return .= uc($msgType).": USER DEFINED COMMANDS WITH PRECEDENCE\n-------------------------------------------------------------------------------\n\n" if ($output == 0);
|
|
|
|
|
$return .= " $device (DEVICE TYPE: ".$defs{$device}{TYPE}.")\n" if ($output == 0);
|
|
|
|
|
$output = 1 if ($output == 0);
|
|
|
|
|
next
|
|
|
|
|
if ( $cmd eq ""
|
|
|
|
|
&& $device eq $name
|
|
|
|
|
&& $output == 0 );
|
|
|
|
|
$return .=
|
|
|
|
|
uc($msgType)
|
|
|
|
|
. ": USER DEFINED COMMANDS WITH PRECEDENCE\n-------------------------------------------------------------------------------\n\n"
|
|
|
|
|
if ( $output == 0 );
|
|
|
|
|
$return .=
|
|
|
|
|
" $device (DEVICE TYPE: "
|
|
|
|
|
. $defs{$device}{TYPE} . ")\n"
|
|
|
|
|
if ( $output == 0 );
|
|
|
|
|
$output = 1 if ( $output == 0 );
|
|
|
|
|
|
|
|
|
|
$return .= " Priority $prio:\n $cmd\n" if ($cmd ne "");
|
|
|
|
|
$return .= " Priority $prio:\n [DEFAULT COMMAND]\n" if ($cmd eq "");
|
|
|
|
|
}
|
|
|
|
|
$return .= " Priority $prio:\n $cmd\n"
|
|
|
|
|
if ( $cmd ne "" );
|
|
|
|
|
$return .=
|
|
|
|
|
" Priority $prio:\n [DEFAULT COMMAND]\n"
|
|
|
|
|
if ( $cmd eq "" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$return .= "\n" if ($return ne "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$return .= "\n" if ($return ne "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Default commands
|
|
|
|
|
if (defined($cmdSchema->{$msgType})) {
|
|
|
|
|
|
|
|
|
|
my $deviceTypes = $devicesReq;
|
|
|
|
|
$deviceTypes = join(',', keys $cmdSchema->{$msgType})
|
|
|
|
|
if ($deviceTypes eq "" || $devicesReq eq $name);
|
|
|
|
|
$deviceTypes = $UserDeviceTypes
|
|
|
|
|
if ($UserDeviceTypes ne "");
|
|
|
|
|
|
|
|
|
|
my $outout = 0;
|
|
|
|
|
foreach my $deviceType (split( /,/, $deviceTypes )) {
|
|
|
|
|
|
|
|
|
|
if (defined($cmdSchema->{$msgType}{$deviceType})) {
|
|
|
|
|
$return .= uc($msgType).": DEFAULT COMMANDS\n-------------------------------------------------------------------------------\n\n"
|
|
|
|
|
if ($outout == 0);
|
|
|
|
|
$outout = 1;
|
|
|
|
|
$return .= " $deviceType\n";
|
|
|
|
|
|
|
|
|
|
my @priorities;
|
|
|
|
|
@priorities = ("Normal", "ShortPrio", "Short") if ($msgType eq "audio");
|
|
|
|
|
@priorities = ("Normal", "High", "Low") if ($msgType ne "audio");
|
|
|
|
|
|
|
|
|
|
foreach my $prio (@priorities) {
|
|
|
|
|
$return .= " Priority $prio:\n ".$cmdSchema->{$msgType}{$deviceType}{$prio}."\n";
|
|
|
|
|
|
|
|
|
|
if (defined($cmdSchema->{$msgType}{$deviceType}{defaultValues}{$prio})) {
|
|
|
|
|
$return .= " Default Values:\n";
|
|
|
|
|
|
|
|
|
|
foreach my $key (keys $cmdSchema->{$msgType}{$deviceType}{defaultValues}{$prio}) {
|
|
|
|
|
if ($cmdSchema->{$msgType}{$deviceType}{defaultValues}{$prio}{$key} ne "") {
|
|
|
|
|
$return .= " $key = ".$cmdSchema->{$msgType}{$deviceType}{defaultValues}{$prio}{$key}."\n" ;
|
|
|
|
|
} else {
|
|
|
|
|
$return .= " $key = [EMPTY]\n" ;
|
|
|
|
|
}
|
|
|
|
|
$return .= "\n" if ( $return ne "" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$return .= "\n" if ($return ne "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$return .= "\n" if ( $return ne "" );
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$return .= "Unknown messaging type '$msgType'\n" if ($msgType ne "text");
|
|
|
|
|
$return .= "Messaging type 'text' does not have dedicated routing commands. This is a wrapper type to dynamically distinguish between push and mail.\n" if ($msgType eq "text");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$return .= "\n" if ($return ne "");
|
|
|
|
|
# Default commands
|
|
|
|
|
if ( defined( $cmdSchema->{$msgType} ) ) {
|
|
|
|
|
|
|
|
|
|
my $deviceTypes = $devicesReq;
|
|
|
|
|
$deviceTypes = join( ',', keys $cmdSchema->{$msgType} )
|
|
|
|
|
if ( $deviceTypes eq "" || $devicesReq eq $name );
|
|
|
|
|
$deviceTypes = $UserDeviceTypes
|
|
|
|
|
if ( $UserDeviceTypes ne "" );
|
|
|
|
|
|
|
|
|
|
my $outout = 0;
|
|
|
|
|
foreach my $deviceType ( split( /,/, $deviceTypes ) ) {
|
|
|
|
|
|
|
|
|
|
if ( defined( $cmdSchema->{$msgType}{$deviceType} ) ) {
|
|
|
|
|
$return .=
|
|
|
|
|
uc($msgType)
|
|
|
|
|
. ": DEFAULT COMMANDS\n-------------------------------------------------------------------------------\n\n"
|
|
|
|
|
if ( $outout == 0 );
|
|
|
|
|
$outout = 1;
|
|
|
|
|
$return .= " $deviceType\n";
|
|
|
|
|
|
|
|
|
|
my @priorities;
|
|
|
|
|
@priorities = ( "Normal", "ShortPrio", "Short" )
|
|
|
|
|
if ( $msgType eq "audio" );
|
|
|
|
|
@priorities = ( "Normal", "High", "Low" )
|
|
|
|
|
if ( $msgType ne "audio" );
|
|
|
|
|
|
|
|
|
|
foreach my $prio (@priorities) {
|
|
|
|
|
$return .=
|
|
|
|
|
" Priority $prio:\n "
|
|
|
|
|
. $cmdSchema->{$msgType}{$deviceType}{$prio}
|
|
|
|
|
. "\n";
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
defined(
|
|
|
|
|
$cmdSchema->{$msgType}{$deviceType}
|
|
|
|
|
{defaultValues}{$prio}
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
$return .= " Default Values:\n";
|
|
|
|
|
|
|
|
|
|
foreach my $key (
|
|
|
|
|
keys $cmdSchema->{$msgType}{$deviceType}
|
|
|
|
|
{defaultValues}{$prio} )
|
|
|
|
|
{
|
|
|
|
|
if ( $cmdSchema->{$msgType}{$deviceType}
|
|
|
|
|
{defaultValues}{$prio}{$key} ne "" )
|
|
|
|
|
{
|
|
|
|
|
$return .=
|
|
|
|
|
" $key = "
|
|
|
|
|
. $cmdSchema->{$msgType}{$deviceType}
|
|
|
|
|
{defaultValues}{$prio}{$key} . "\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$return .= " $key = [EMPTY]\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$return .= "\n" if ( $return ne "" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$return .= "Unknown messaging type '$msgType'\n"
|
|
|
|
|
if ( $msgType ne "text" );
|
|
|
|
|
$return .=
|
|
|
|
|
"Messaging type 'text' does not have dedicated routing commands. This is a wrapper type to dynamically distinguish between push and mail.\n"
|
|
|
|
|
if ( $msgType eq "text" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$return .= "\n" if ( $return ne "" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$return = "Non-existing device or unknown module messaging schema definition: $devicesReq" if ($return eq "");
|
|
|
|
|
$return =
|
|
|
|
|
"Non-existing device or unknown module messaging schema definition: $devicesReq"
|
|
|
|
|
if ( $return eq "" );
|
|
|
|
|
return $return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -511,7 +608,7 @@ sub msgConfig_Get($@) {
|
|
|
|
|
1;
|
|
|
|
|
|
|
|
|
|
=pod
|
|
|
|
|
|
|
|
|
|
=item helper
|
|
|
|
|
=begin html
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
@ -521,11 +618,38 @@ sub msgConfig_Get($@) {
|
|
|
|
|
msgConfig
|
|
|
|
|
</h3>
|
|
|
|
|
<ul>
|
|
|
|
|
Provides global settings for FHEM command <a href="#MSG">msg</a>.<br>
|
|
|
|
|
Provides global settings and tools for FHEM command <a href="#MSG">msg</a>.<br>
|
|
|
|
|
A device named globalMsg will be created automatically when using msg-command for the first time and no msgConfig device could be found.<br>
|
|
|
|
|
The device name can be renamed and reconfigured afterwards if desired.<br>
|
|
|
|
|
<br>
|
|
|
|
|
<a name="msgConfigdefine" id="msgConfigdefine"></a> <b>Define</b>
|
|
|
|
|
<div style="margin-left: 2em">
|
|
|
|
|
<code>define <name> msgConfig</code><br>
|
|
|
|
|
</div><br>
|
|
|
|
|
<br>
|
|
|
|
|
<a name="msgConfigset" id="msgConfigset"></a> <b>Set</b>
|
|
|
|
|
<div style="margin-left: 2em">
|
|
|
|
|
<ul>
|
|
|
|
|
<li>
|
|
|
|
|
<b>addLocation</b> <Location Name> <br>
|
|
|
|
|
Conveniently creates a Dummy device based on the given location name. It will be pre-configured to be used together with location-based routing when using the msg-command. The dummy device will be added to attribute msgLocationDevs automatically. Afterwards additional configuration is required by adding msgContact* or msgRecipient* attributes for gateway devices placed at this specific location.
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<b>cleanReadings</b> [<device and/or regex>] <br>
|
|
|
|
|
Easy way to cleanup all fhemMsg readings. A parameter is optional and can be a concrete device name or mixed together with regex. This command is an alias for "deletereading <device and/or regex> fhemMsg.*".
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<b>createResidentsDev</b> <de|en> <br>
|
|
|
|
|
Creates a new device named rgr_Residents of type <a href="#RESIDENTS">RESIDENTS</a>. It will be pre-configured based on the given language. In case rgr_Residents exists it will be updated based on the given language (basically only a language change). Afterwards next configuration steps will be displayed to use RESIDENTS together with presence-based routing of the msg-command.<br>
|
|
|
|
|
This next step is basically to set attribute msgResidentsDevice to refer to this RESIDENTS device either globally or for any other specific FHEM device (most likely you do NOT want to have this attribute set globally as otherwise this will affect ALL devices and therefore ALL msg-commands in your automations).<br>
|
|
|
|
|
Note that use of RESIDENTS only makes sense together with ROOMMATE and or GUEST devices which still need to be created manually. See <a href="#RESIDENTSset">RESIDENTS Set commands</a> addRoommate and addGuest respectively.
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<b>createSwitcherDev</b> <de|en> <br>
|
|
|
|
|
Creates a pre-configured Dummy device named HouseAnn and updates globalMsg attribute msgSwitcherDev to refer to it.
|
|
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
@ -540,11 +664,23 @@ sub msgConfig_Get($@) {
|
|
|
|
|
msgConfig
|
|
|
|
|
</h3>
|
|
|
|
|
<ul>
|
|
|
|
|
Stellt globale Einstellungen für das FHEM Kommando <a href="#MSG">msg</a> bereit.<br>
|
|
|
|
|
Stellt globale Einstellungen und Tools für das FHEM Kommando <a href="#MSG">msg</a> bereit.<br>
|
|
|
|
|
Ein Device mit dem Namen globalMsg wird automatisch bei der ersten Benutzung des msg Kommandos angelegt, sofern kein msgConfig Device gefunden wurde.<br>
|
|
|
|
|
Der Device Name kann anschließend beliebig umbenannt und umkonfiguriert werden.<br>
|
|
|
|
|
<br>
|
|
|
|
|
<a name="msgConfigdefine" id="msgConfigdefine"></a> <b>Define</b>
|
|
|
|
|
<div style="margin-left: 2em">
|
|
|
|
|
<code>define <name> msgConfig</code><br>
|
|
|
|
|
</div><br>
|
|
|
|
|
<br>
|
|
|
|
|
<a name="msgConfigset" id="msgConfigset"></a> <b>Set</b>
|
|
|
|
|
<div style="margin-left: 2em">
|
|
|
|
|
<ul>
|
|
|
|
|
<li>
|
|
|
|
|
<b>addLocation</b> <Name der Lokation> <br>
|
|
|
|
|
Erstellt auf einfache Weise ein Dummy Device basierend auf dem übergebenen Lokationsnamen. Es wird for die lokations-basierte Verwendung mit dem msg-Kommando vorkonfiguriert. Das Dummy Device wird automatisch zum Attribut msgLocationDevs hinzugefügt. Anschließend ist eine weitere Konfiguration über die Attribute msgContact* oder msgRecipient* notwendig, die auf entsprechende Gateway Devices verweisen, die an dieser Lokation stehen.
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|