From 5f2aeb1669c2992c2c5c088af5aec588d595e902 Mon Sep 17 00:00:00 2001 From: Beta-User Date: Fri, 26 Feb 2021 06:40:34 +0000 Subject: [PATCH] mqtt2.template: add shelly motions, change battery handling in z2m aqara_cube git-svn-id: https://svn.fhem.de/fhem/trunk@23826 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/lib/AttrTemplate/mqtt2.template | 28 ++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/fhem/FHEM/lib/AttrTemplate/mqtt2.template b/fhem/FHEM/lib/AttrTemplate/mqtt2.template index 84bd5938f..e3e356c6c 100644 --- a/fhem/FHEM/lib/AttrTemplate/mqtt2.template +++ b/fhem/FHEM/lib/AttrTemplate/mqtt2.template @@ -778,10 +778,12 @@ par:BASE_TOPIC;base topic set in configuration.yaml of the zigbee2mqtt bridge;{ par:DEV_ID;name of the device in the zigbee2mqtt bridge;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,[^/]+[/]([^/:]+).*, ? $1 : undef } attr DEVICE stateFormat Action: action attr DEVICE devicetopic BASE_TOPIC/DEV_ID -attr DEVICE readingList $\DEVICETOPIC:.* { json2nameValue($EVENT) } +attr DEVICE readingList $\DEVICETOPIC:.* { json2nameValue($EVENT,'',$JSONMAP) } +attr DEVICE jsonMap battery:batteryPercent voltage:batterymV +attr DEVICE userReadings batteryVoltage:batterymV.* {ReadingsNum($name,'batterymV',0)/1000} deletereading -q DEVICE (?!associatedWith).* attr DEVICE model zigbee2mqtt_aqara_cube -setreading DEVICE attrTemplateVersion 20200904 +setreading DEVICE attrTemplateVersion 20210226 #source post: https://forum.fhem.de/index.php/topic,94494.msg983905.html#msg983905 name:zigbee2mqtt_AlarmSensor @@ -2693,12 +2695,32 @@ set DEVICE attrTemplate speechcontrol_type_light attr DEVICE model shellyduo setreading DEVICE attrTemplateVersion 20200831 +#contributed by MrTom, https://forum.fhem.de/index.php/topic,94060.msg1135513.html#msg1135513 +name:shellymotion +filter:TYPE=MQTT2_DEVICE:FILTER=readingList=.*shellies.* +desc:shellymotion using original firmware. +order:A_16 +par:DEVNAME;name of this shelly;{ AttrVal("DEVICE","readingList","") =~ m,shellies/([^/]+)/, ? $1 : undef } +par:ICON;ICON as set, defaults to motion_detector;{ AttrVal("DEVICE","icon","motion_detector") } +attr DEVICE icon ICON +attr DEVICE devStateIcon {my $onl = ReadingsVal($name,"online","false") eq "true"?"10px-kreis-gruen":"10px-kreis-rot"; \ +my $moti = ReadingsVal($name,"motion","false") eq "true"?"people_sensor ":"message_presence"; \ +"".FW_makeImage($onl)." ".FW_makeImage($moti).""} +attr DEVICE readingList shellies/DEVNAME/online:.* online\ + shellies/DEVNAME/sensor/status:.* { json2nameValue($EVENT) }\ + shellies/DEVNAME/announce:.* { json2nameValue($EVENT) }\ + shellies/announce:.* { $EVENT =~ m,..id...DEVNAME...mac.*, ? json2nameValue($EVENT) : return } +attr DEVICE setList x_update:noArg shellies/DEVNAME/command update_fw\ + x_mqttcom shellies/DEVNAME/command $EVTPART1 +attr DEVICE model shellymotion +setreading DEVICE attrTemplateVersion 20210226 + # shellyht using original firmware name:shellyht filter:TYPE=MQTT2_DEVICE:FILTER=readingList=.*shellies.* desc:shellyht using original firmware
Just adds stateFormat and icon -order:A_16 +order:A_161 par:DEVNAME;name of this shelly;{ AttrVal("DEVICE","readingList","") =~ m,shellies/([^/]+)/, ? $1 : undef } par:ICON;ICON as set, defaults to temperature_humidity;{ AttrVal("DEVICE","icon","temperature_humidity") } attr DEVICE icon ICON