2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-19 00:26:03 +00:00

mqtt-templates: add some MGB stuff + SYS-Info to mqtt2

git-svn-id: https://svn.fhem.de/fhem/trunk@23602 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Beta-User 2021-01-24 07:58:06 +00:00
parent e41ed41a6d
commit d4c6f518fb
2 changed files with 60 additions and 1 deletions

View File

@ -104,6 +104,18 @@ deleteattr TYPE=MQTT2_\DEVICE:FILTER=model=MQTT2_CLIENT_general_bridge readingLi
#option:{return 1 if 'NEWIGNOREREGEXP' ne AttrVal('IODEVNAME','ignoreRegexp','not_set');;return 0} #option:{return 1 if 'NEWIGNOREREGEXP' ne AttrVal('IODEVNAME','ignoreRegexp','not_set');;return 0}
#attr IODEVNAME ignoreRegexp NEWIGNOREREGEXP #attr IODEVNAME ignoreRegexp NEWIGNOREREGEXP
###########################################
# mosquitto state, see https://forum.fhem.de/index.php/topic,117988.msg1124272.html#msg1124272
name:MQTT2_mosquitto_SYS
prereq:{my @devices=devspec2array("TYPE=MQTT2_CLIENT");;return 1 if $devices[0];;return 0}
filter:TYPE=MQTT2_DEVICE
desc:Shows health info about mosquitto. Needs additional subscriptions on MQTT2_CLIENT side, see https://forum.fhem.de/index.php/topic,117988.msg1124272.html#msg1124272 for details.
order:000002
attr DEVICE readingList\
.*SYS/broker/.+:.* { $TOPIC=~m,SYS/broker/(.*),;; my %h;; $h{$1}=$EVENT;; \%h }
attr DEVICE model MQTT2_mosquitto_SYS
setreading DEVICE attrTemplateVersion 20210121
########################################### ###########################################
# zigbee2mqtt # zigbee2mqtt

View File

@ -24,10 +24,17 @@ prereq:{my @devices=devspec2array("TYPE=MQTT_GENERIC_BRIDGE");return 1 if $devic
filter:TYPE=MQTT_GENERIC_BRIDGE filter:TYPE=MQTT_GENERIC_BRIDGE
desc:This template is proposal to fullfill requirements for the rest of the s some basic configuration on the MQTT_GENERIC_BRIDGE side itself, especially:<br>- different topic structures for sending readings values and receiving commands and/or reading values; <br>- Variable $name must be part of the base topic structures.<br>Note: All outgoing messages will be sent without retain flag; change this to 1, if you need values stored on your MQTT server (e.g. if your clients are not always connected). desc:This template is proposal to fullfill requirements for the rest of the s some basic configuration on the MQTT_GENERIC_BRIDGE side itself, especially:<br>- different topic structures for sending readings values and receiving commands and/or reading values; <br>- Variable $name must be part of the base topic structures.<br>Note: All outgoing messages will be sent without retain flag; change this to 1, if you need values stored on your MQTT server (e.g. if your clients are not always connected).
order:000001 order:000001
par:IODEVNAME;Name of the IO-Device; { AttrVal("DEVICE","IODev",undef) }
par:RADIO_SETCLIENTODERMGB_M2D;Set clientOrder on IODev to "MQTT_GENERIC_BRIDGE MQTT2_DEVICE" (recommended);{ my $io = AttrVal("DEVICE","IODev",""); return 0 if InternalVal($io,"TYPE","MQTT") eq "MQTT"; AttrVal($io,"clientOrder",undef) }
par:RADIO_SETCLIENTODERM2D_MGB;Set clientOrder on IODev to "MQTT2_DEVICE MQTT_GENERIC_BRIDGE" (default, may cause unintended autocreates);{ my $io = AttrVal("DEVICE","IODev",""); return 0 if InternalVal($io,"TYPE","MQTT") eq "MQTT"; AttrVal($io,"clientOrder",undef) }
par:RADIO_DONTSETCLIENTODER;Leave clientOrder on IODev (default is "MQTT2_DEVICE MQTT_GENERIC_BRIDGE", may cause unintended autocreates);{ my $io = AttrVal("DEVICE","IODev",""); return 0 if InternalVal($io,"TYPE","MQTT") eq "MQTT"; AttrVal($io,"clientOrder",undef) }
attr DEVICE globalDefaults sub:base={"DEVICE/set"} pub:base={"DEVICE"} attr DEVICE globalDefaults sub:base={"DEVICE/set"} pub:base={"DEVICE"}
option:{ RADIO_SETCLIENTODERMGB_M2D }
attr IODEVNAME clientOrder MQTT_GENERIC_BRIDGE MQTT2_\DEVICE
option:{ RADIO_SETCLIENTODERM2D_MGB }
attr IODEVNAME clientOrder MQTT2_\DEVICE MQTT_GENERIC_BRIDGE
farewell:Now you can start to configure your devices to send and receive messages over MQTT! farewell:Now you can start to configure your devices to send and receive messages over MQTT!
########## ##########
## subordintated devices section ## subordintated devices section
@ -105,3 +112,43 @@ attr TARGETDEV MQTTPREFIXPublish *:topic={"$base/$device/$name"}
option:{ SENDALLREADINGS && "TRGETDEVTYPE" eq "MAX" } option:{ SENDALLREADINGS && "TRGETDEVTYPE" eq "MAX" }
attr TARGETDEV MQTTPREFIXPublish *:topic={"$base/$device/$name"} attr TARGETDEV MQTTPREFIXPublish *:topic={"$base/$device/$name"}
############
name:mgb_shutter
prereq:{my @devices=devspec2array("TYPE=MQTT_GENERIC_BRIDGE");return 1 if $devices[0];return 0}
filter:TYPE=MQTT_GENERIC_BRIDGE
desc:This template is starting point to configure shutter devices in MQTT_GENERIC_BRIDGE usage context.<br>NOTE: Early testing version, see https://forum.fhem.de/index.php/topic,117423.0.html for details.<br>Might still need some changes!
order:C_10000
par:TARGETDEV;Pls enter name of the device you want to put under MQTT_GENERIC_BRIDGE controll;{ undef }
par:TRGETDEVTYPE;TYPE of target device;{ InternalVal("TARGETDEV",'TYPE',undef) }
par:RADIO_SENDNOREADINGS;Do not send any readings from device to MQTT server;{ undef }
par:RADIO_SENDBASICREADINGS;Send only basic readings (pct, motor (if available) and state) to MQTT server;{ undef }
par:RADIO_SENDALLREADINGS;Send all Readings from device to MQTT server (not recommended);{ undef }
par:MQTTPREFIX;prefix used in MGB;{ InternalVal("DEVICE",'prefix',undef) }
option:global
set DEVICE attrTemplate mgb_shutter_with_params \TARGETDEV=TARGETDEV \TRGETDEVTYPE=TRGETDEVTYPE SENDNOREADINGS=RADIO_SENDNOREADINGS SENDBASICREADINGS=RADIO_SENDBASICREADINGS SENDALLREADINGS=RADIO_SENDALLREADINGS \MQTTPREFIX=MQTTPREFIX
name:mgb_shutter_with_params
order:C_10000w
prereq:{my @devices=devspec2array("TYPE=MQTT_GENERIC_BRIDGE");return 1 if $devices[0];return 0}
filter:NAME=mgbTesting
par:TARGETDEV;Pls enter name of the device you want to put under MQTT_GENERIC_BRIDGE controll;{ undef }
par:SENDNOREADINGS;Do not send any readings from device to MQTT server;{ 0 }
par:RADIO_SENDBASICREADINGS;Send only basic readings (pct, motor (if available) and state) to MQTT server;{ undef }
par:SENDALLREADINGS;Send all Readings from device to MQTT server (not recommended);{ 0 }
par:MQTTPREFIX;prefix used in MGB;{ InternalVal("DEVICE",'prefix',undef) }
par:TRGETDEVTYPE;TYPE of target device;{ InternalVal("TARGETDEV",'TYPE',undef) }
option:{ "TRGETDEVTYPE" eq "CUL_HM" }
attr TARGETDEV MQTTPREFIXSubscribe state:stopic={"$base/$device"} pct:stopic={"$base/$device/$name"}
option:{SENDNOREADINGS}
deleteattr TARGETDEV MQTTPREFIXPublish
option:{ SENDBASICREADINGS && "TRGETDEVTYPE" eq "CUL_HM" }
attr TARGETDEV MQTTPREFIXPublish state|pct|motor:topic={"$base/$device/$name"} motor:expression={$value=~m,([^:]+)?,?$1:undef}
option:{ SENDALLREADINGS && "TRGETDEVTYPE" eq "CUL_HM" }
attr TARGETDEV MQTTPREFIXPublish *:topic={"$base/$device/$name"}