2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-21 07:56:03 +00:00

mqtt2 and huedevice.template: various fixes

git-svn-id: https://svn.fhem.de/fhem/trunk@25466 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Beta-User 2022-01-14 20:43:11 +00:00
parent bc923edbd0
commit 63e8345f14
2 changed files with 86 additions and 13 deletions

View File

@ -9,6 +9,27 @@
# If undef, the user has to specify them (the comment is shown to the user)
###########################################
# Generic devices section
name:Generic_Multibutton_Remote
filter:TYPE=HUEDevice
desc: For remotes like Aqara Opple or 6 button
order:C_01
par:RADIO_REGULAR_LEFT_RIGHT;Button orientation to the left and right, mounted normal. Fits e.g. Opple 6 buttons;{ undef }
par:RADIO_TILTED_LEFT_RIGHT;Regular button orientation to the left and right, but mounted tilted 90 degrees;{ undef }
par:RADIO_TOP_BUTTOM;Button orientation to the top and buttom. Fits e.g. Friends of Hue with hidden buttons 5/6;{ undef }
par:ICON;ICON as set, defaults to fs20_S4A-2_1;{ AttrVal('DEVICE','icon','fs20_S4A-2_1') }
attr DEVICE icon ICON
option:{ RADIO_REGULAR_LEFT_RIGHT }
attr DEVICE devStateIcon 100.:taster_ch6_1 200.:taster_ch6_2 300.:taster_ch6_3 400.:taster_ch6_4 500.:taster_ch6_5 600.:taster_ch6_6
option:{ RADIO_TILTED_LEFT_RIGHT }
attr DEVICE devStateIcon 100.:taster_ch6_5 200.:taster_ch6_6 300.:taster_ch6_8 400.:taster_ch6_9 500.:taster_ch6_1 600.:taster_ch6_2
option:{ RADIO_TOP_BUTTOM }
attr DEVICE devStateIcon 100.:taster_ch6_1 200.:taster_ch6_2 300.:taster_ch6_3 400.:taster_ch6_4 500.:taster_ch6_8 600.:taster_ch6_9
option:global
setreading DEVICE attrTemplateVersion Generic_Multibutton_Remote_20220114
###########################################
# Eurotronic Spirit ZigBee (SPZB0001)
name:Eurotronic_SPZB0001_Spirit_ZigBee
@ -77,21 +98,33 @@ attr DEVICE stateFormat H: humidity %
setreading DEVICE attrTemplateVersion Xiaomi_Aqara_WSDCGQ11LM_Humidity_Sensor_20211015
# generic Motion Sensor, https://forum.fhem.de/index.php/topic,125416.msg1200527.html#msg1200527
name:Generic_Motion_Sensor
filter:TYPE=HUEDevice
desc: Might be suitable for all motion sensors without option to set duration...
order:F_01
set DEVICE attrTemplate Xiaomi_Aqara_RTCGQ11LM_Motion_Sensor
attr DEVICE configList /delay (.*)/:{"delay":$1}\
/ledindication (.*)/:true,false:{"ledindication":$1}\
/on (.*)/:true,false:{"on":$1}\
/sensitivity (.*)/:0,1,2:{"sensitivity":$1}
setreading DEVICE attrTemplateVersion Generic_Motion_Sensor_20220114
###########################################
# Xiaomi/Aqara RTCGQ11LM Motion Sensor
name:Xiaomi_Aqara_RTCGQ11LM_Motion_Sensor
filter:TYPE=HUEDevice
desc: The Xiaomi/Aqara motion sensor is a multisensor, and is interpreted by ZigBee as two sensors that is motion sensor.<br><a href="https://www.aqara.com/en/motion_sensor.html">Manufacturer link: Klick me</a>
desc: The Xiaomi/Aqara motion sensor is a multisensor, and is interpreted by ZigBee as two sensors that is motion sensor.<br><a href="https://www.aqara.com/en/motion_sensor.html">Manufacturer link: Klick me</a><br>Might be suitable for other motion sensors with option to set duration as well...
order:F_01a
par:ICON;ICON as set, defaults to motion_detector;{ AttrVal('DEVICE','icon','motion_detector') }
attr DEVICE icon ICON
attr DEVICE devStateIcon motion:people_sensor nomotion:message_presence
attr DEVICE configList /duration (.*)/:{"duration":"$1"}\
attr DEVICE configList /duration (.*)/:{"duration":$1}\
/delay (.*)/:{"delay":$1}\
/ledindication (.*)/:true,false:{"ledindication":$1}\
/on (.*)/:true,false:{"on":$1}\
/sensitivity (.*)/:0,1,2:{"sensitivity":$1}
setreading DEVICE attrTemplateVersion Xiaomi_Aqara_RTCGQ11LM_Motion_Sensor_20211215
setreading DEVICE attrTemplateVersion Xiaomi_Aqara_RTCGQ11LM_Motion_Sensor_20220114
name:Xiaomi_Aqara_DJT11LM_Vibration_Sensor
@ -149,3 +182,4 @@ attr DEVICE { usr => { 'effectSpeed\s+(.*)' => '{"effectSpeed":"$1"}', 'sparkles
attr DEVICE widgetOverride effect:steady,snow,rainbow,snake,twinkle,fireworks,flag,waves,updown,vintage,fading,collide,strobe,sparkles,carnival,glow effectSpeed:selectnumbers,0,1,10,0,lin sparkles1:noArg sparkles2:noArg
attr DEVICE webCmd bri:effect:effectSpeed:sparkles1:sparkles2:NormalWhite
setreading DEVICE attrTemplateVersion Melinera_LED_fairy_lights_ZigBee_20211222

View File

@ -154,6 +154,7 @@ attr DEVICE readingList\
$\DEVICETOPIC/bridge/devices:.* devices\
$\DEVICETOPIC/bridge/info:.* info\
$\DEVICETOPIC/bridge/groups:.* groups\
$\DEVICETOPIC/bridge/event:.* { json2nameValue($EVENT) }\
$\DEVICETOPIC/bridge/extensions:.* extensions
attr DEVICE setList\
log_level:debug,info,warn,error $\DEVICETOPIC/bridge/config/log_level $EVTPART1\
@ -174,13 +175,13 @@ attr DEVICE setList\
z_last_seen:disable,ISO_8601,epoch,ISO_8601_local $\DEVICETOPIC/bridge/config/last_seen $EVTPART1\
z_ban:textField $\DEVICETOPIC/bridge/config/ban $EVTPART1\
z_rename:textField $\DEVICETOPIC/bridge/config/rename {"old":"$EVTPART1","new":"$EVTPART2"}\
z_reset_CC:noArg $\DEVICETOPIC/bridge/config/reset
z_reset_CC:noArg $\DEVICETOPIC/bridge/config/reset
attr DEVICE setStateList on off
attr DEVICE comment To check for new updates of the deamon software, you might want to use a separate HTTPMOD device. See HTTPMOD template zigbee2mqtt_daemon_updates for further details.
#set DEVICE attrTemplate do_general_mqtt_cleanup ADD_TO_IO_IGNOREREGEXP=BASE_TOPIC/[A-Za-z0-9._]+/set
set DEVICE attrTemplate do_general_mqtt_cleanup
attr DEVICE model zigbee2mqtt_bridge
setreading DEVICE attrTemplateVersion 20211022
setreading DEVICE attrTemplateVersion 2022014
# Based on https://forum.fhem.de/index.php/topic,94060.msg872371.html#msg872371
@ -2159,6 +2160,43 @@ par:IO_DEV;Currently used IO;{ AttrVal('DEVICE','IODev',InternalVal('DEVICE','IO
set IO_DEV publish CMNDTOPIC/SetOption26 0
attr DEVICE userReadings state:POWER:.* { lc(ReadingsVal($name,"POWER","")) }
######
#Tasmota bt2tasmota section
name:tasmota_bt2tasmota_bridge
filter:TYPE=MQTT2_DEVICE:FILTER=readingList=.*(tele|cmnd|stat).*
desc:This is a very early version of a template meant to configure a bridge device showing some basic info about the microcontroller (mcu) itself. For further details on bluetooth2tasmota visit https://tasmota.github.io/docs/Bluetooth_ESP32/ and https://tasmota.github.io/docs/Commands/#ble-esp32<br>NOTE: Initial version, not yet tested...<br>Most likely will be subject to changes!!!
order:A_06t01
farewell:template has been applied successfully.\n Note: some changes have been applied to the mcu firmware settings. Incoming messages from bluetooth devices now should be forwarded to different FHEM devices, make sure, you have a TYPE=autocreate device active.
par:CMNDTOPIC;Command topic prefix, without trailing /;{ AttrVal('DEVICE','readingList','') =~ m,([^:]*)\b(tele|cmnd|stat)(/.*)?/LWT:, ? "${1}cmnd$3" : undef }
par:TELETOPIC;info topic prefix, without trailing /;{ AttrVal('DEVICE','readingList','') =~ m,([^:]*)\b(tele|cmnd|stat)(/.*)?/LWT:, ? "${1}tele$3" : undef }
par:STATTOPIC;ack topic prefix, without trailing /;{ AttrVal('DEVICE','readingList','') =~ m,([^:]*)\b(tele|cmnd|stat)(/.*)?/LWT:, ? "${1}stat$3" : undef }
par:BRIDGETOPIC;bridgeRegexp to be set;{ my $rL = AttrVal('DEVICE','readingList',''); $rL =~ m,([^:]*)\btele(/.*/)LWT:, ? qq{${1}tele${2}([^/]+)} : $rL =~ m,([^:]*/)tele/LWT:, ? qq{${1}([^/]+)/tele} : undef }
par:IO_DEV;Currently used IO;{ AttrVal('DEVICE','IODev',InternalVal('DEVICE','IODev',undef)->{NAME}) }
set IO_DEV publish CMNDTOPIC/Backlog StateText1 off; StateText2 on; StateText3 toggle; StateText4 hold; SetOption26 1; MI32Option6 1; SaveData 1
par:ICON;ICON as set, defaults to MQTT;{ AttrVal('DEVICE','icon','mqtt') }
attr DEVICE icon ICON
attr DEVICE bridgeRegexp \
BRIDGETOPIC/SENSOR:.* "bt2t_$1"
attr DEVICE readingList \
TELETOPIC/LWT:.* LWT\
TELETOPIC/INFO.:.* { $EVENT =~ m,^..Info[1-3]..(.+).$, ? json2nameValue($1,'',$JSONMAP) : json2nameValue($EVENT,'',$JSONMAP) }\
TELETOPIC/UPTIME:.* { json2nameValue($EVENT,'',$JSONMAP) }\
TELETOPIC/STATE:.* { json2nameValue($EVENT,'',$JSONMAP) }\
STATTOPIC/RESULT:.* { json2nameValue($EVENT,'',$JSONMAP) }\
STATTOPIC/POWER:.* LED
attr DEVICE setStateList on off
attr DEVICE stateFormat LWT\
<a href="http://IPAddress" target="_blank">Hostname</a><br>
attr DEVICE devStateIcon Online:10px-kreis-gruen@green Offline:10px-kreis-rot@red
set IO_DEV publish CMNDTOPIC/restart 1
attr DEVICE model tasmota_bt2tasmota_bridge
deletereading -q DEVICE (?!associatedWith|IODev).*
setreading DEVICE attrTemplateVersion 20220111
#$yyMMddhhmmsshex = sub{sprintf '%02X%02X%02X%02X%02X%02X', $_[5]-100, $_[4]+1, $_[3], $_[2], $_[1], $_[0]}->(localtime); # see https://forum.fhem.de/index.php/topic,123411.msg1179717.html#msg1179717
######
#Tasmota zigbee2tasmota section
@ -3326,7 +3364,7 @@ setreading DEVICE attrTemplateVersion 20200831
# Shelly Plus 1 using original firmware.
name:shellyPlus_1
filter:TYPE=MQTT2_DEVICE
desc:Early version of a base template for second generation shelly devices (names with "plus", without power measurement). NOTE: requires to activate generic status update in firmware settings.
desc:Early version of a base template for second generation shelly devices (names with "plus", without power measurement). NOTE: requires to activate generic status update in firmware settings (if not available: reset device to factory defaults).<br>NOTE: Please wait some seconds to allow Shelly device to complete reboot.
par:DEV_TPC;Shelly name in the topic;{ AttrVal('DEVICE','devicetopic',AttrVal('DEVICE','readingList','')) =~ m<(shellies/[^/]+|shellyp(lus|ro4pm)[^/:_]{4,}+)> ? $1 : undef }
par:CALLSPEECHRECOGN;Set this to 0 to not set any speech recogn. related attributes;{ 1 }
order:A_20
@ -3347,26 +3385,27 @@ attr DEVICE readingList $\DEVICETOPIC/online:.* online\
$\DEVICETOPIC/status/sys:.* { json2nameValue($EVENT, 'sys_', $JSONMAP) }\
$\DEVICETOPIC/status/switch_0:.* { $EVENT =~ s/"output":true/"state":"on"/g; $EVENT =~ s/"output":false/"state":"off"/g; json2nameValue($EVENT, 'switch_', $JSONMAP) }\
fhem2shelly/rpc:.* {}
attr DEVICE devStateIcon {my $onl = ReadingsVal($name,'online','false') eq 'false'?'10px-kreis-rot': '10px-kreis-gruen'; $onl = FW_makeImage($onl); my $light = FW_makeImage(ReadingsVal($name,'state','off')); my $temp = ReadingsVal($name,'temperature','-100'); my $ip = ReadingsVal($name,'ip','none'); qq(<a href="http://$ip"target="_blank">${onl}</a><a href="/fhem?cmd.dummy=set $name toggle&XHR=1">${light}</a><div>Temp: $temp °C</div>)}
attr DEVICE devStateIcon {my $onl = ReadingsVal($name,'online','false') eq 'false'?'10px-kreis-rot': '10px-kreis-gruen'; $onl = FW_makeImage($onl); my $light = FW_makeImage(ReadingsVal($name,'state','off')); my $temp = ReadingsVal($name,'temperature','-100'); my $ip = ReadingsVal($name,'ip','none'); qq(<a href="http://$ip" target="_blank">${onl}</a><a href="/fhem?cmd.dummy=set $name toggle&XHR=1">${light}</a><div>Temp: $temp °C</div>)}
attr DEVICE jsonMap switch_state:state switch_temperature_tC:temperature switch_temperature_tF:0 params_wifi_sta_ip:ip
attr DEVICE setStateList on off toggle
attr DEVICE webCmd :
attr DEVICE model shellyPlus_1
setreading DEVICE attrTemplateVersion 20220110
setreading DEVICE attrTemplateVersion 20220114
set DEVICE x_reboot
option:{ CALLSPEECHRECOGN }
set DEVICE attrTemplate speechcontrol_type_switch
# Shelly Plus 1PM using original firmware.
name:shellyPlus_1pm
filter:TYPE=MQTT2_DEVICE
desc:Early version of a base template for second generation shelly devices (names with "plus", with power measurement). NOTE: requires to activate generic status update in firmware settings.
desc:Early version of a base template for second generation shelly devices (names with "plus", with power measurement). NOTE: requires to activate generic status update in firmware settings (if not available: reset device to factory defaults).<br>NOTE: Please wait some seconds to allow Shelly device to complete reboot.
par:CALLSPEECHRECOGN;Set this to 0 to not set any speech recogn. related attributes;{ 1 }
order:A_20a
set DEVICE attrTemplate shellyPlus_1 \CALLSPEECHRECOGN=0
attr DEVICE devStateIcon {my $onl = ReadingsVal($name,'online','false') eq 'false'?'10px-kreis-rot':'10px-kreis-gruen'; $onl = FW_makeImage($onl); my $light = FW_makeImage(ReadingsVal($name,'state','off')); my $cons = ReadingsNum($name,'apower',0); my $total = round(ReadingsNum($name,'aenergy_total',0)/1000,1); my $temp = ReadingsVal($name,'temperature','-100'); my $ip = ReadingsVal($name,'ip','none'); qq(<a href="http://$ip"target="_blank">${onl}</a><a href="/fhem?cmd.dummy=set $name toggle&XHR=1">${light}</a><div>Verbrauch: $cons W / Total: $total kwh / Temp: $temp °C</div>)}
attr DEVICE devStateIcon {my $onl = ReadingsVal($name,'online','false') eq 'false'?'10px-kreis-rot':'10px-kreis-gruen'; $onl = FW_makeImage($onl); my $light = FW_makeImage(ReadingsVal($name,'state','off')); my $cons = ReadingsNum($name,'apower',0); my $total = round(ReadingsNum($name,'aenergy_total',0)/1000,1); my $temp = ReadingsVal($name,'temperature','-100'); my $ip = ReadingsVal($name,'ip','none'); qq(<a href="http://$ip" target="_blank">${onl}</a><a href="/fhem?cmd.dummy=set $name toggle&XHR=1">${light}</a><div>Verbrauch: $cons W / Total: $total kwh / Temp: $temp °C</div>)}
attr DEVICE jsonMap switch_state:state switch_aenergy_total:aenergy_total switch_apower:apower switch_temperature_tC:temperature switch_temperature_tF:0 params_wifi_sta_ip:ip
attr DEVICE model shellyPlus_1pm
setreading DEVICE attrTemplateVersion 20220110
setreading DEVICE attrTemplateVersion 20220114
option:{ CALLSPEECHRECOGN }
set DEVICE attrTemplate speechcontrol_type_switch
@ -3378,7 +3417,7 @@ par:CALLSPEECHRECOGN;Set this to 0 to not set any speech recogn. related attribu
par:DEV_TPC;Shelly name in the topic;{ AttrVal('DEVICE','devicetopic',AttrVal('DEVICE','readingList','')) =~ m<(shellies/[^/]+|shellyp(lus|ro4pm)[^/:_]{4,}+)> ? $1 : undef }
order:A_20d
set DEVICE attrTemplate shellyPlus_1 \CALLSPEECHRECOGN=0
attr DEVICE devStateIcon {my $onl = ReadingsVal($name,'online','false') eq 'false'?'10px-kreis-rot': ReadingsVal($name,'new_fw','false') eq 'true' ? '10px-kreis-gelb' : '10px-kreis-gruen'; $onl = FW_makeImage($onl); my $light = FW_makeImage(ReadingsVal($name,'state','off')); my $cons = ReadingsNum($name,'apower',0); my $total = round(ReadingsNum($name,'aenergy_total',0)/1000,1); my $temp = ReadingsVal($name,'temperature','-100'); my $ip = ReadingsVal($name,'ip','none'); qq(<a href="http://$ip"target="_blank">${onl}</a><a href="/fhem?cmd.dummy=set $name toggle&XHR=1">${light}</a><div>Verbrauch: $cons W / Total: $total kwh / Temp: $temp °C</div>)}
attr DEVICE devStateIcon {my $onl = ReadingsVal($name,'online','false') eq 'false'?'10px-kreis-rot': ReadingsVal($name,'new_fw','false') eq 'true' ? '10px-kreis-gelb' : '10px-kreis-gruen'; $onl = FW_makeImage($onl); my $light = FW_makeImage(ReadingsVal($name,'state','off')); my $cons = ReadingsNum($name,'apower',0); my $total = round(ReadingsNum($name,'aenergy_total',0)/1000,1); my $temp = ReadingsVal($name,'temperature','-100'); my $ip = ReadingsVal($name,'ip','none'); qq(<a href="http://$ip" target="_blank">${onl}</a><a href="/fhem?cmd.dummy=set $name toggle&XHR=1">${light}</a><div>Verbrauch: $cons W / Total: $total kwh / Temp: $temp °C</div>)}
attr DEVICE readingList $\DEVICETOPIC/online:.* online\
$\DEVICETOPIC/events/rpc:.* { return if $EVENT =~ m{switch:[1-3]}; $EVENT =~ s/"output":true/"state":"on"/g; $EVENT =~ s/"output":false/"state":"off"/g; json2nameValue($EVENT,'',$JSONMAP) }\
fhem2shelly/rpc:.* {}
@ -3409,7 +3448,7 @@ attr DEVICE_CH# devicetopic DEV_TPC
loop:END
set DEVICE attrTemplate set_associatedWith \CHANNELS=4
set DEVICE,DEVICE_CH2,DEVICE_CH3,DEVICE_CH4 attrTemplate speechcontrol_type_switch
setreading DEVICE,DEVICE_CH2,DEVICE_CH3,DEVICE_CH4 attrTemplateVersion 202201043
setreading DEVICE,DEVICE_CH2,DEVICE_CH3,DEVICE_CH4 attrTemplateVersion 20220114
attr DEVICE,DEVICE_CH2,DEVICE_CH3,DEVICE_CH4 model shellypro4pm