diff --git a/fhem/FHEM/lib/AttrTemplate/mqtt2.template b/fhem/FHEM/lib/AttrTemplate/mqtt2.template index ccc424459..05e533f83 100644 --- a/fhem/FHEM/lib/AttrTemplate/mqtt2.template +++ b/fhem/FHEM/lib/AttrTemplate/mqtt2.template @@ -1443,6 +1443,75 @@ attr DEVICE,DEVICE_CH2 model tasmota_4ch_two_shutters_invert_0 setreading DEVICE,DEVICE_CH2 attrTemplateVersion 20210607 set DEVICE,DEVICE_CH2 attrTemplate speechcontrol_type_blind +name:tasmota_2ch_shutter_venetian_invert_0 +filter:TYPE=MQTT2_DEVICE:FILTER=readingList=.*(tele|cmnd|stat).* +desc:Configures a dual chanel tasmota device as venetian shutter; needs Tasmota version 10.0.0.1 or higher, see Tasmota wiki
and Forum Thread
NOTE: This template will configure the shutter in Homematic-style device pct 100% = open. +order:A_02b3 +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:IO_DEV;Currently used IO;{ AttrVal('DEVICE','IODev',InternalVal('DEVICE','IODev',undef)->{NAME}) } +par:CALLSPEECHRECOGN;Set this to 0 to not set any speech recogn. related attributes;{ 1 } +par:BCKLGCMND;Send out configuration command via backlog?;{ 1 } +par:ICON;ICON as set, defaults to fts_shutter_updown;{ AttrVal('DEVICE','icon','fts_shutter_updown') } +set DEVICE attrTemplate tasmota_set_lowercase_texts_and_state1 +attr DEVICE icon ICON +option:{BCKLGCMND} +set IO_DEV publish CMNDTOPIC/Backlog LedState 2; SetOption80 1; Interlock 1,2; Interlock ON; SetOption81 1; SetOption80 1; PowerOnState 0; switchmode1 3; switchmode2 3; PulseTime1 0; PulseTime2 0; SaveData 1; +set IO_DEV publish CMNDTOPIC/Restart 1 +option:global +attr DEVICE setList \ + close:noArg CMNDTOPIC/ShutterClose1\ + open:noArg CMNDTOPIC/ShutterOpen1\ + half:noArg CMNDTOPIC/ShutterPosition1 50\ + pct:slider,0,1,100 CMNDTOPIC/ShutterPosition1 $EVTPART1\ + stop:noArg CMNDTOPIC/ShutterStop1\ + closeSlat:noArg CMNDTOPIC/ShutterClose2\ + openSlat:noArg CMNDTOPIC/ShutterOpen2\ + halfSlat:noArg CMNDTOPIC/ShutterPosition2 50\ + pctSlat:slider,0,1,100 CMNDTOPIC/ShutterPosition2 $EVTPART1\ + stopSlat:noArg CMNDTOPIC/ShutterStop2\ + resetClose:noArg CMNDTOPIC/ShutterSetClose1\ + resetCloseSlat:noArg CMNDTOPIC/ShutterSetClose2 + x_configuration CMNDTOPIC/$EVTPART1 $EVTPART2 +attr DEVICE readingList \ + TELETOPIC/LWT:.* LWT\ + STATTOPIC/RESULT:.* { json2nameValue($EVENT) }\ + STATTOPIC/POWER1:.* POWER1\ + STATTOPIC/POWER1:on {{'state' => 'opening'}}\ + STATTOPIC/POWER2:.* POWER2\ + STATTOPIC/POWER2:on {{'state' => 'closing'}}\ + STATTOPIC/SHUTTER1:.* state\ + STATTOPIC/SHUTTER1:.* pct\ + STATTOPIC/SHUTTER2:.* stateSlat\ + STATTOPIC/SHUTTER2:.* pctSlat\ + TELETOPIC/RESULT:.* { json2nameValue($EVENT) }\ + TELETOPIC/STATE:.* { json2nameValue($EVENT) }\ + TELETOPIC/SENSOR:.* { json2nameValue($EVENT) }\ + TELETOPIC/INFO.:.* { $EVENT =~ m,^..Info[1-3]..(.+).$, ? json2nameValue($1,'',$JSONMAP) : json2nameValue($EVENT,'',$JSONMAP) }\ + TELETOPIC/UPTIME:.* { json2nameValue($EVENT) } +attr DEVICE devStateIcon opening:fts_shutter_up@red closing:fts_shutter_down@red Online:10px-kreis-gruen Offline:10px-kreis-rot 100:fts_shutter_100 0:fts_shutter_10 9\d.*:fts_shutter_90 8\d.*:fts_shutter_80 7\d.*:fts_shutter_70 6\d.*:fts_shutter_60 5\d.*:fts_shutter_50 4\d.*:fts_shutter_40 3\d.*:fts_shutter_30 2\d.*:fts_shutter_20 1\d.*:fts_shutter_10 \b\d\b.*:fts_shutter_10 set_.*:fts_shutter_updown +attr DEVICE cmdIcon open:fts_shutter_up close:fts_shutter_down stop:fts_shutter_manual half:fts_shutter_50 +attr DEVICE webCmd :open:close:half:stop:pct +attr DEVICE eventMap open:opens close:closes +attr DEVICE stateFormat \ +LWT\ +\ +state +deletereading -q DEVICE (?!associatedWith|IODev).* +attr DEVICE setStateList open close half stop pct +attr DEVICE comment After applying the template set "ShutterOpenDuration1", "ShutterCloseDuration1" and "shuttertiltconfig1" first.\ +Use the "set x_configuration" Option. Example: "set x_configuration ShutterOpenDuration1 35"\ +Shutter specific commands available: ShutterOpenDuration1, ShutterCloseDuration1, ShutterRelay1, ShutterSetHalfway1, ShutterSetClose1, ShutterInvert1, ShutterMotordelay1, ShutterCalibration1; you may use this for general setOptions in tasmota also.\ +commands may need restart to take effect.\ +For calibration, use of more than one shutter device and further information on the available commands see Tasmota wiki. +attr DEVICE model tasmota_2ch_shutter_venetian_invert_0 +setreading DEVICE attrTemplateVersion 20211110 +option:{ CALLSPEECHRECOGN } +set DEVICE attrTemplate speechcontrol_type_blind + + # based on a proposal by twdotnet, https://forum.fhem.de/index.php/topic,94495.msg1137400.html#msg1137400 # shelly i3 3 channel input switches # shelly i3 3 channel input switches with device configuration @@ -2469,10 +2538,52 @@ attr DEVICE comment To get appropriate loadState values: Change the default limi attr DEVICE model shelly1_w_energy_measuring_washer_example setreading DEVICE attrTemplateVersion 20200831 +name:shelly2em +filter:TYPE=MQTT2_DEVICE:FILTER=readingList=.*shellies.* +order:A_10c +desc:Applies to Shelly 2em devices.
See https://forum.fhem.de/index.php/topic,123920.msg1185387.html#msg1185387 +par:DEVNAME;Shelly device name in the topic;{ AttrVal('DEVICE','readingList','') =~ m,shellies/([^/]*)/, ? $1 : undef } +par:RADIO_SETUSERREADING;Set userreading for total energy consumption;{ undef } +par:RADIO_DONOTSETUSERREADING;Do not set userreading for total energy consumption;{ undef } +par:NEWUSERREADINGS;NEWUSERREADINGS as set if emeter_0_energy_total is included, otherwise it will be added;{ my $tobeadded = q(emeter_0_energy_total:emeter_0_energy:.* monotonic {ReadingsNum($name,'emeter_0_energy',0)}, emeter_1_energy_total:emeter_1_energy:.* monotonic {ReadingsNum($name,'emeter_1_energy',0)}); my $old = AttrVal('DEVICE','userReadings',undef); !defined $old ? $tobeadded : $old =~ m,emeter_0_energy_total:emeter_0_energy.*, ? $old : $old." $tobeadded" } +set DEVICE attrTemplate shelly1_w_energy_measuring \RADIO_SETUSERREADING=RADIO_SETUSERREADING \RADIO_DONOTSETUSERREADING=RADIO_DONOTSETUSERREADING +attr DEVICE devStateIcon {my $onl = ReadingsVal($name,'online','false') eq 'true'?'10px-kreis-gruen':'10px-kreis-rot'; my $light = ReadingsVal($name,'state','off'); my $cons1 = ReadingsVal($name,'emeter_0_power','unknown'); my $cons2 = ReadingsVal($name,'emeter_1_power','unknown'); my my $total1 = ReadingsVal($name,'emeter_0_kWh','unknown'); my $total2 = ReadingsVal($name,'emeter_1_kWh','unknown'); my $total_sum = $total1+$total2; ''.FW_makeImage($onl)." ".FW_makeImage($light)."
P1: $cons1 W / Total P1: $total1 kWh
P2: $cons2 W / Total P2: $total2 kWh
2 Phases total: $total_sum kWh
"} +attr DEVICE stateFormat { my $light = ReadingsVal($name,'state','off'); my $cons1 = ReadingsVal($name,'emeter_0_power','unknown'); my $cons2 = ReadingsVal($name,'emeter_1_power','unknown'); my my $total1 = ReadingsVal($name,'emeter_0_kWh','unknown'); my $total2 = ReadingsVal($name,'emeter_1_kWh','unknown'); return qq(Relay: $light,
P1: $cons1 W / Total P1: $total1 kWh
P2: $cons2 W / Total P2: $total2 kWh) } +attr DEVICE readingList shellies/DEVNAME/online:.* online\ + shellies/DEVNAME/announce:.* { json2nameValue($EVENT) }\ + shellies/DEVNAME/relay/0:.* state\ + shellies/DEVNAME/input_event/0:.* { json2nameValue($EVENT) }\ + shellies/DEVNAME/input/0:.* input0\ + shellies/DEVNAME/online:.* online\ + shellies/DEVNAME/emeter/0/power:.* emeter_0_power\ + shellies/DEVNAME/emeter/0/current:.* emeter_0_current\ + shellies/DEVNAME/emeter/0/voltage:.* emeter_0_voltage\ + shellies/DEVNAME/emeter/0/reactive_power:.* emeter_0_reactive_power\ + shellies/DEVNAME/emeter/1/power:.* emeter_1_power\ + shellies/DEVNAME/emeter/1/pf:.* emeter_1_pf\ + shellies/DEVNAME/emeter/1/current:.* emeter_1_current\ + shellies/DEVNAME/emeter/1/voltage:.* emeter_1_voltage\ + shellies/DEVNAME/emeter/1/reactive_power:.* emeter_1_reactive_power\ + shellies/DEVNAME/emeter/0/energy:.* emeter_0_energy\ + shellies/DEVNAME/emeter/0/returned_energy:.* emeter_0_returned_energy\ + shellies/DEVNAME/emeter/0/total:.* emeter_0_total\ + shellies/DEVNAME/emeter/0/total:.* {'emeter_0_kWh' => sprintf("%.2f",$EVENT/1000)}\ + shellies/DEVNAME/emeter/0/total_returned:.* emeter_0_total_returned\ + shellies/DEVNAME/emeter/1/energy:.* emeter_1_energy\ + shellies/DEVNAME/emeter/1/returned_energy:.* emeter_1_returned_energy\ + shellies/DEVNAME/emeter/1/total:.* emeter_1_total\ + shellies/DEVNAME/emeter/1/total:.* {'emeter_1_kWh' => sprintf("%.2f",$EVENT/1000)}\ + shellies/DEVNAME/emeter/1/total_returned:.* emeter_1_total_returned +deletereading -q DEVICE (?!associatedWith|IODev).* +set DEVICE x_mqttcom announce +attr DEVICE model shelly2em +setreading DEVICE attrTemplateVersion 20211110 +option:{ RADIO_SETUSERREADING } +attr DEVICE userReadings NEWUSERREADINGS name:shelly3em filter:TYPE=MQTT2_DEVICE:FILTER=readingList=.*shellies.* -order:A_10c +order:A_10c1 desc:Applies to Shelly 3em devices.
NOTE: early version, might still need some testing par:DEVNAME;Shelly1 name in the topic;{ AttrVal("DEVICE","readingList","") =~ m,shellies/([^/]*)/, ? $1 : undef } par:RADIO_SETUSERREADING;Set userreading for total energy consumption;{ undef } @@ -2800,7 +2911,8 @@ attr DEVICE stateFormat R0: relay0 R1: relay1 R2: relay2 R3: relay3 attr DEVICE model shelly4pro_unified setreading DEVICE attrTemplateVersion 20200522 or prior -# shellybulb using original firmware +#shellybulb using original firmware +# some modifications by Rico, https://forum.fhem.de/index.php/topic,123486.msg1185455.html#msg1185455 name:shellybulb filter:TYPE=MQTT2_DEVICE:FILTER=readingList=.*shellies.* desc:shellybulb using original firmware
Tested with 1.49 @@ -2808,26 +2920,25 @@ order:A_15 par:DEVNAME;name of this shelly;{ AttrVal('DEVICE','readingList','') =~ m,shellies/([^/]+)/, ? $1 : undef } par:ICON;ICON as set, defaults to light_control;{ AttrVal('DEVICE','icon','light_control') } attr DEVICE icon ICON +attr DEVICE devStateIcon {my $onl = ReadingsVal($name,'online','false') eq 'true'?'10px-kreis-gruen':'10px-kreis-rot'; my $light = ReadingsVal($name,'state','off'); my $cons = ReadingsVal($name,'light_0_power','unknown'); ''.FW_makeImage($onl)." ".FW_makeImage($light)."
Verbrauch: $cons
"} attr DEVICE setList\ off:noArg shellies/DEVNAME/color/0/command off\ on:noArg shellies/DEVNAME/color/0/command on\ - pct:colorpicker,BRI,0,1,100 shellies/DEVNAME/color/0/set {"gain":"$EVTPART1","brightness":$EVTPART1}\ - pct_on:colorpicker,BRI,0,1,100 shellies/DEVNAME/color/0/set {"turn":"on","gain":$EVTPART1,"brightness":$EVTPART1}\ - ct:colorpicker,CT,3000,10,6500 {$EVTPART1=3000 if $EVTPART1<3000;qq(shellies/DEVNAME/color/0/set {"mode":"white","temp":$EVTPART1})}\ - ct_on:colorpicker,CT,3000,10,6500 {$EVTPART1=3000 if $EVTPART1<3000;qq(shellies/DEVNAME/color/0/set {"turn":"on","mode":"white","temp":$EVTPART1})}\ - rgb:colorpicker,RGB {$EVTPART1=~/(..)(..)(..)/;return if !defined $3;if($1 ne $2 || $2 ne $3){qq(shellies/DEVNAME/color/0/set {"mode":"color","gain":"100","red":).hex($1).qq(,"green":).hex($2).qq(,"blue":).hex($3).'}'}else{qq(shellies/DEVNAME/color/0/set {"turn":"on","mode":"white","brightness":).int(hex($1)/2.55).'}'}}\ - rgb_on:colorpicker,RGB {$EVTPART1=~/(..)(..)(..)/;return if !defined $3;if($1 ne $2 || $2 ne $3){qq(shellies/DEVNAME/color/0/set {"turn":"on","mode":"color","gain":"100","red":).hex($1).qq(,"green":).hex($2).qq(,"blue":).hex($3).'}'}else{qq(shellies/DEVNAME/color/0/set {"turn":"on","mode":"white","brightness":).int(hex($1)/2.55).'}'}}\ + effect:selectnumbers,0,1,3,0,lin shellies/DEVNAME/color/0/set {"turn": "on","mode":"color","effect":$EVTPART1}\ + pct:colorpicker,BRI,0,1,100 shellies/DEVNAME/color/0/set {"turn":"on","gain":$EVTPART1,"brightness":$EVTPART1}\ + ct:colorpicker,CT,3000,10,6500 {$EVTPART1=3000 if $EVTPART1<3000;qq(shellies/DEVNAME/color/0/set {"turn":"on","mode":"white","temp":$EVTPART1})}\ + rgb:colorpicker,RGB {return 'shellies/DEVNAME/color/0/command off' if $EVTPART1 eq '000000'; return 'shellies/DEVNAME/color/0/set {"turn":"on","mode":"white","temp":4000}' if $EVTPART1 eq 'FFFFFF'; $EVTPART1=~/(..)(..)(..)/; return if !defined $3; if($1 ne $2 || $2 ne $3){qq(shellies/DEVNAME/color/0/set {"mode":"color","gain":"100","red":).hex($1).qq(,"green":).hex($2).qq(,"blue":).hex($3).'}'}else{qq(shellies/DEVNAME/color/0/set {"turn":"on","mode":"white","brightness":).int(hex($1)/2.55).'}'}}\ x_update:noArg shellies/DEVNAME/command update_fw\ x_mqttcom shellies/DEVNAME/command $EVTPART1 deletereading -q DEVICE status_.* attr DEVICE readingList shellies/DEVNAME/color/0/status:.* {json2nameValue($EVENT,'',$JSONMAP)} attr DEVICE userReadings ct:temp.* {ReadingsVal($name,"temp",3000)}, rgb:red.* {if(ReadingsVal($name,'mode','') eq 'color'){sprintf("%02X%02X%02X", ReadingsVal($name,'red',99), ReadingsVal($name,'green',99), ReadingsVal($name,'blue',99))}else{my $a=sprintf("%02X",ReadingsVal($name,'brightness',0)*2.555);"$a$a$a"}} -attr DEVICE webCmd on:off:pct:ct:rgb +attr DEVICE webCmd on:off:pct:ct:rgb:effect attr DEVICE jsonMap brightness:pct set DEVICE x_mqttcom announce set DEVICE attrTemplate speechcontrol_type_light attr DEVICE model shellybulb -setreading DEVICE attrTemplateVersion 20211022 +setreading DEVICE attrTemplateVersion 20211110 # contributed by KurtK https://forum.fhem.de/index.php/topic,94495.msg1055093.html#msg1055093 # shellyduo using original firmware