mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-09 20:57:11 +00:00
75_MSG: add new msg schema entry for Matrix and SignalBot
git-svn-id: https://svn.fhem.de/fhem/trunk@26965 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
8a375b9822
commit
3c85787637
@ -1,5 +1,7 @@
|
||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||
# Do not insert empty lines here, update check depends on it.
|
||||
- feature: 75_MSG: add new msg schema entry for Matrix and SignalBot
|
||||
- feature: 75_msgConfig: add commandref
|
||||
- bugfix: 98_todoist: key in header
|
||||
- feature: 36_ShellyMonitor: Support Shelly3EM correctly
|
||||
- feature: 70_ESCVP21net: optimze help text
|
||||
|
@ -31,7 +31,7 @@ use utf8;
|
||||
# initialize ##################################################################
|
||||
sub MSG_Initialize($$) {
|
||||
my %hash = (
|
||||
Fn => "CommandMsg",
|
||||
Fn => "CommandMsg",
|
||||
Hlp =>
|
||||
"[<type>] [<\@device>|<e-mail address>] [<priority>] [|<title>|] <message-text>",
|
||||
);
|
||||
@ -42,6 +42,7 @@ sub MSG_Initialize($$) {
|
||||
|
||||
# regular Fn ##################################################################
|
||||
sub CommandMsg($$;$$);
|
||||
|
||||
sub CommandMsg($$;$$) {
|
||||
my ( $cl, $msg, $testMode ) = @_;
|
||||
my $return = "";
|
||||
@ -112,7 +113,7 @@ sub CommandMsg($$;$$) {
|
||||
### extract message details
|
||||
###
|
||||
|
||||
my ( $msgA, $params ) = parseParams($msg, "[^\\S\\n]", " ");
|
||||
my ( $msgA, $params ) = parseParams( $msg, "[^\\S\\n]", " " );
|
||||
|
||||
# only use output from parseParams when
|
||||
# parameters where found
|
||||
@ -638,8 +639,7 @@ m/^@?([A-Za-z0-9._]+):([A-Za-z0-9._\-\/@+]*):?([A-Za-z0-9._\-\/@+]*)$/
|
||||
ReadingsVal(
|
||||
$gatewayDev,
|
||||
"presence",
|
||||
"present"
|
||||
) eq $_
|
||||
"present" ) eq $_
|
||||
} @unavailabilityIndicators
|
||||
)
|
||||
|
||||
@ -648,8 +648,7 @@ m/^@?([A-Za-z0-9._]+):([A-Za-z0-9._\-\/@+]*):?([A-Za-z0-9._\-\/@+]*)$/
|
||||
ReadingsVal(
|
||||
$gatewayDev,
|
||||
"state",
|
||||
"present"
|
||||
) eq $_
|
||||
"present" ) eq $_
|
||||
} @unavailabilityIndicators
|
||||
)
|
||||
|
||||
@ -1636,9 +1635,9 @@ m/^(absent|disappeared|unauthorized|disconnected|unreachable)$/i
|
||||
$loopTitleShrt =
|
||||
substr( $loopTitleShrt, 0, 37 ) . "..."
|
||||
if ( length($loopTitleShrt) > 40 );
|
||||
$cmd =~ s/%TITLESHRT%/$loopTitleShrt/gi;
|
||||
$cmd =~ s/%TITLESHRT%/$loopTitleShrt/gi;
|
||||
$loopTitleShrt =~ s/ /_/;
|
||||
$cmd =~ s/%TITLESHRT2%/$loopTitleShrt/gi;
|
||||
$cmd =~ s/%TITLESHRT2%/$loopTitleShrt/gi;
|
||||
$loopTitleShrt =~ s/^([\s\t ]*\w+).*/$1/g;
|
||||
$loopTitleShrt =
|
||||
substr( $loopTitleShrt, 0, 17 ) . "..."
|
||||
@ -1955,19 +1954,24 @@ m/^(absent|disappeared|unauthorized|disconnected|unreachable)$/i
|
||||
Log3 $logDevice, 5,
|
||||
"msg $device: "
|
||||
. "$type[$i] route command (Perl): $cmd";
|
||||
|
||||
#eval $cmd;
|
||||
my $ret = AnalyzePerlCommand(undef, $cmd);
|
||||
unless ( !$ret || $ret =~ m/^[\s\t\n ]*$/ )
|
||||
my $ret =
|
||||
AnalyzePerlCommand( undef, $cmd );
|
||||
unless ( !$ret
|
||||
|| $ret =~ m/^[\s\t\n ]*$/ )
|
||||
{
|
||||
$error = 1;
|
||||
$loopReturn3 .= "$gatewayDev: $ret\n";
|
||||
$loopReturn3 .=
|
||||
"$gatewayDev: $ret\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log3 $logDevice, 5,
|
||||
"msg $device: "
|
||||
. "$type[$i] route command (fhem): $cmd";
|
||||
my $ret = AnalyzeCommandChain(undef,$cmd);
|
||||
my $ret =
|
||||
AnalyzeCommandChain( undef, $cmd );
|
||||
unless ( !$ret
|
||||
|| $ret =~ m/^[\s\t\n ]*$/ )
|
||||
{
|
||||
@ -2463,26 +2467,47 @@ m/^(absent|disappeared|unauthorized|disconnected|unreachable)$/i
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
=item command
|
||||
=item summary dynamic routing of messages to FHEM devices and modules
|
||||
=item summary_DE dynamisches Routing für Nachrichten an FHEM Geräte und Module
|
||||
=begin html
|
||||
|
||||
<a name="MSG"></a>
|
||||
<a id="MSG"></a>
|
||||
<h3>msg</h3>
|
||||
<ul>
|
||||
<p>For documentation in german see <a href="http://forum.fhem.de/index.php/topic,39983.0.html">FHEM Forum</a> or <a href="https://wiki.fhem.de/wiki/Msg">FHEM Wiki</a></p>
|
||||
Syntax is:<br>
|
||||
<code>msg [<type>] [<@device>|<e-mail address>] [<priority>] [|<title>|] <message></code>
|
||||
<br><br>
|
||||
Except for <i>message</i> all parameters are optional, for configuration of the entire messageing logics see also <a href="#msgConfig">msgConfig</a>.<br>
|
||||
<br>
|
||||
Basic idea behind the command (and msgConfig) is to establish a central logic for dispatching messages to be sent to the user, so e.g. in case an address of an recipient changes, you only have to change one single point in your entire configuration.<br>
|
||||
Parameters are as follows:<br>
|
||||
<ul>
|
||||
<li>type<br>
|
||||
Is optional and one of <i>text</i>, <i>audio</i>, <i>light</i> or <i>screen</i>. If ommitted, it defaults to <i>text</i>.<br>
|
||||
You may provide more than one type by providing a comma-seperated list.
|
||||
</li>
|
||||
<li>@device or e-mail address<br>
|
||||
For <i>@device</i> you may opt for any instance of a messenger service available in <i>mscConfig</i>, by default <a href="#Pushover">Pushover</a> will be used (if available). <br>
|
||||
For emailing, per default <code>system()</code> command per <code>/usr/bin/mail</code> is issued.
|
||||
You may provide more than one recipent by providing a comma-seperated list here (also mixed).
|
||||
</li>
|
||||
<li>priority<br>
|
||||
Is also optional. You may any (nummeric) value understood by your addressed messaging device, good idea is to use values common in the Pushover API (-2 to 2).
|
||||
</li>
|
||||
<li>title<br>
|
||||
Is also optional, but when given, it has to be enclosed in <i>pipe</i> characters.
|
||||
</li>
|
||||
<br>
|
||||
No documentation here yet, sorry.<br>
|
||||
<a href="http://forum.fhem.de/index.php/topic,39983.0.html">FHEM Forum</a>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
=end html
|
||||
=begin html_DE
|
||||
=begin html_old_DE
|
||||
|
||||
<a name="MSG"></a>
|
||||
<a id="MSG"></a>
|
||||
<h3>msg</h3>
|
||||
<ul>
|
||||
<code>msg [<type>] [<@device>|<e-mail address>] [<priority>] [|<title>|] <message></code>
|
||||
@ -2493,7 +2518,7 @@ m/^(absent|disappeared|unauthorized|disconnected|unreachable)$/i
|
||||
</ul>
|
||||
|
||||
|
||||
=end html_DE
|
||||
=end html_old_DE
|
||||
|
||||
=for :application/json;q=META.json 75_MSG.pm
|
||||
{
|
||||
|
@ -143,7 +143,7 @@ sub msgConfig_Initialize($) {
|
||||
"msgType:text,push,mail,screen,light,audio,queue",
|
||||
)
|
||||
{
|
||||
addToAttrList($_);
|
||||
addToAttrList( $_, 'msgConfig' );
|
||||
}
|
||||
|
||||
return FHEM::Meta::InitMod( __FILE__, $hash );
|
||||
@ -190,9 +190,9 @@ sub msgConfig_Define($$) {
|
||||
readingsEndUpdate( $hash, 1 );
|
||||
}
|
||||
|
||||
$hash->{NOTIFYDEV} = "TYPE=(Jabber|TelegramBot|yowsup)";
|
||||
setNotifyDev( $hash, 'TYPE=(Jabber|TelegramBot|yowsup|Signalbot)' );
|
||||
|
||||
return undef;
|
||||
return;
|
||||
}
|
||||
|
||||
sub msgConfig_Undefine($$) {
|
||||
@ -226,9 +226,9 @@ sub msgConfig_Set($@) {
|
||||
# addLocation
|
||||
elsif ( lc($what) eq "addlocation" ) {
|
||||
my $location = join( " ", @a );
|
||||
my $group = AttrVal( $name, "group", $TYPE );
|
||||
my $room = AttrVal( $name, "room", "" );
|
||||
my $return = "";
|
||||
my $group = AttrVal( $name, "group", $TYPE );
|
||||
my $room = AttrVal( $name, "room", "" );
|
||||
my $return = "";
|
||||
|
||||
return "Missing argument 'location'"
|
||||
if ( $location eq "" );
|
||||
@ -250,7 +250,7 @@ sub msgConfig_Set($@) {
|
||||
}
|
||||
|
||||
$attr{$device}{group} = $group if ( !defined( $attr{$device}{group} ) );
|
||||
$attr{$device}{room} = $room
|
||||
$attr{$device}{room} = $room
|
||||
if ( !defined( $attr{$device}{room} ) && $room ne "" );
|
||||
$attr{$device}{comment} = "Auto-created by $name"
|
||||
if ( !defined( $attr{$device}{comment} ) );
|
||||
@ -616,6 +616,12 @@ sub msgConfig_Notify($$) {
|
||||
$msg = ReadingsVal( $devName, "message", undef );
|
||||
}
|
||||
|
||||
#Signalbot
|
||||
elsif ( $devType eq 'Signalbot' ) {
|
||||
$sender = ReadingsVal( $devName, 'msgSender', undef );
|
||||
$msg = ReadingsVal( $devName, 'msgText', undef );
|
||||
}
|
||||
|
||||
next unless ( $msg && $msg ne "" );
|
||||
|
||||
unless ( $sender && $sender ne "" ) {
|
||||
@ -809,14 +815,19 @@ sub msgConfig_QueueReleaseMsgId($$) {
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding utf8
|
||||
|
||||
=item helper
|
||||
=item summary global settings and tools for FHEM command <a href="#MSG">msg</a>
|
||||
=item summary_DE globale Einstellungen und Tools f¨r das FHEM Kommando <a href="#MSG">msg</a>
|
||||
=item summary_DE globale Einstellungen und Tools für das FHEM Kommando <a href="#MSG">msg</a>
|
||||
=begin html
|
||||
|
||||
<p>
|
||||
<a name="msgConfig" id="msgConfig"></a>
|
||||
<a id="msgConfig"></a>
|
||||
</p>
|
||||
<h3>
|
||||
msgConfig
|
||||
@ -826,30 +837,30 @@ sub msgConfig_QueueReleaseMsgId($$) {
|
||||
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>
|
||||
<a id="msgConfig-define"></a> <h4>Define</h4>
|
||||
<ul>
|
||||
<code>define <name> msgConfig</code><br>
|
||||
</ul><br>
|
||||
<br>
|
||||
<a name="msgConfigset" id="msgConfigset"></a> <b>Set</b>
|
||||
<a id="msgConfig-set"></a> <h4>Set</h4>
|
||||
<ul>
|
||||
<ul>
|
||||
<li>
|
||||
<b>addLocation</b> <Location Name> <br>
|
||||
<a id="msgConfig-set-addLocation"></a><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>
|
||||
<a id="msgConfig-set-cleanReadings"></a><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>
|
||||
<a id="msgConfig-set-createResidentsDev"></a><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>
|
||||
<a id="msgConfig-set-createSwitcherDev"></a><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>
|
||||
@ -861,7 +872,7 @@ This next step is basically to set attribute msgResidentsDevice to refer to this
|
||||
=begin html_DE
|
||||
|
||||
<p>
|
||||
<a name="msgConfig" id="msgConfig"></a>
|
||||
<a id="msgConfig"></a>
|
||||
</p>
|
||||
<h3>
|
||||
msgConfig
|
||||
@ -871,20 +882,54 @@ This next step is basically to set attribute msgResidentsDevice to refer to this
|
||||
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>
|
||||
<a id="msgConfig-define"></a> <h4>Define</h4>
|
||||
<ul>
|
||||
<code>define <name> msgConfig</code><br>
|
||||
</ul><br>
|
||||
<br>
|
||||
<a name="msgConfigset" id="msgConfigset"></a> <b>Set</b>
|
||||
|
||||
<a id="msgConfig-set"></a> <h4>Set</h4>
|
||||
<ul>
|
||||
<ul>
|
||||
<li>
|
||||
<b>addLocation</b> <Name der Lokation> <br>
|
||||
<a id="msgConfig-set-addLocation"></a><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>
|
||||
<li>
|
||||
<a id="msgConfig-set-cleanReadings"></a><b>cleanReadings</b> [<device and/or regex>] <br>
|
||||
Einfache Methode, um alle fhemMsg-Readings zu säubern. Optional kann ein Parameter angegeben werden, um ein bestimmtes Device zu säubern, als Device Name kann auch regex angegeben werden. Dieses Kommando ist ein Alias for "deletereading <device and/or regex> fhemMsg.*".
|
||||
</li>
|
||||
<li>
|
||||
<a id="msgConfig-set-createResidentsDev"></a><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>
|
||||
<a id="msgConfig-set-createSwitcherDev"></a><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>
|
||||
</ul>
|
||||
|
||||
<a id="msgConfig-attr"></a> <h4>Attribute</h4>
|
||||
<ul>
|
||||
<ul>
|
||||
<li>
|
||||
<a id="msgConfig-attr-msgContact" data-pattern="msgContact.*"></a><b>msgContact<TYPE></b> <br>
|
||||
FHEM Gerätename, welcher zur Übermittlung von Nachrichten des jeweiligen Typs angesprochen werden soll.
|
||||
<ul>
|
||||
<li>Muss bei Audio Nachrichten ohne eigene Definition von msgCmdAudio* ein Gerät vom Typ SONOSPLAYER sein.</li>
|
||||
<li>Muss bei Screen Nachrichten ohne eigene Definition von msgCmdScreen* ein Gerät vom Typ ENIGMA2 sein.</li>
|
||||
<li>Muss bei Light Nachrichten ohne eigene Definition von msgCmdLight* ein Gerät vom Typ HUEDevice sein.</li>
|
||||
<li>Muss bei Push Nachrichten ohne eigene Definition von msgCmdPush* ein Gerät vom Typ Pushover sein.</li>
|
||||
<li>Muss bei Mail Nachrichten eine oder mehrere gültige E-Mail Adressen enthalten.</li>
|
||||
</ul>
|
||||
Bei FHEM Gerätenamen, über die mehrere Empfänger adressiert werden können, kann der Empfänger mittels Doppelpunkt getrennt vom FHEM Gerätenamen angegeben werden. Je nach Modul ist das optional oder verbindlich.
|
||||
</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
|
||||
=end html_DE
|
||||
|
@ -201,6 +201,12 @@ my $db = {
|
||||
'Low' => 'set %DEVICE% message %MSG%',
|
||||
},
|
||||
|
||||
'Matrix' => {
|
||||
'Normal' => 'set %DEVICE% msg %MSG%',
|
||||
'High' => 'set %DEVICE% msg %MSG%',
|
||||
'Low' => 'set %DEVICE% msg %MSG%',
|
||||
},
|
||||
|
||||
'Pushover' => {
|
||||
'Normal' =>
|
||||
'set %DEVICE% %Pushover_MTYPE% title=\'%TITLE%\' device=\'%RECIPIENT%:%TERMINAL%\' priority=%PRIORITY% url_title="%URLTITLE%" message=\'%MSG%\'',
|
||||
@ -306,6 +312,26 @@ my $db = {
|
||||
},
|
||||
},
|
||||
|
||||
'Signalbot' => {
|
||||
'Normal' => 'set %DEVICE% %Signalbot_MTYPE% %RECIPIENT% %MSG%',
|
||||
'High' => 'set %DEVICE% %Signalbot_MTYPE% %RECIPIENT% %MSG%',
|
||||
'Low' => 'set %DEVICE% %Signalbot_MTYPE% %RECIPIENT% %MSG%',
|
||||
'defaultValues' => {
|
||||
'Normal' => {
|
||||
'RECIPIENT' => '',
|
||||
'Signalbot_MTYPE' => 'send',
|
||||
},
|
||||
'High' => {
|
||||
'RECIPIENT' => '',
|
||||
'Signalbot_MTYPE' => 'send',
|
||||
},
|
||||
'Low' => {
|
||||
'RECIPIENT' => '',
|
||||
'Signalbot_MTYPE' => 'send',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
'yowsup' => {
|
||||
'Normal' => 'set %DEVICE% send %RECIPIENT% %MSG%',
|
||||
'High' => 'set %DEVICE% send %RECIPIENT% %MSG%',
|
||||
@ -470,6 +496,8 @@ sub get {
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
=encoding utf8
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user