From 76514bc13bcf4c8496d14dad729cf4e6c0421158 Mon Sep 17 00:00:00 2001 From: Beta-User <> Date: Wed, 4 Jan 2023 19:41:50 +0000 Subject: [PATCH] mqtt2.template: fix esp. IODev in shellyPlus_2pm_split git-svn-id: https://svn.fhem.de/fhem/trunk@26963 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/lib/AttrTemplate/mqtt2.template | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/fhem/FHEM/lib/AttrTemplate/mqtt2.template b/fhem/FHEM/lib/AttrTemplate/mqtt2.template index 7ed766417..b4ddc38aa 100644 --- a/fhem/FHEM/lib/AttrTemplate/mqtt2.template +++ b/fhem/FHEM/lib/AttrTemplate/mqtt2.template @@ -3609,6 +3609,7 @@ filter:TYPE=MQTT2_DEVICE desc:May be incomlete first version of split template for second generation shelly devices (names with "plus", with power measurement). par:CALLSPEECHRECOGN;Set this to 0 to not set any speech recogn. related attributes;{ 1 } par:DEV_TPC;Shelly name in the topic;{ AttrVal('DEVICE','devicetopic',AttrVal('DEVICE','readingList','')) =~ m<(shellies/[^/]+|shellyp(lus|ro4pm)[^/:_]{4,}+)> ? $1 : undef } +par:IODEVNAME;Name of the IO-Device; { InternalVal('DEVICE','LASTInputDev',AttrVal('DEVICE','IODev',InternalVal('DEVICE','IODev',undef)->{NAME})) } order:A_20c1 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(${onl}${light}
Verbrauch: $cons W / Total: $total kwh / Temp: $temp °C
)} @@ -3620,23 +3621,24 @@ attr DEVICE readingList $\DEVICETOPIC/online:.* online\ attr DEVICE setList toggle:noArg $\DEVICETOPIC/rpc {"id":1,"src":"fhem2shelly","method":"Switch.Toggle","params": {"id":0}}\ off:noArg $\DEVICETOPIC/rpc {"id":1,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":false}}\ on:noArg $\DEVICETOPIC/rpc {"id":1,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":true}}\ - on-for-timer $\DEVICETOPIC/rpc {"id":1,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":true,"toggle_after":$EVTPART1}}\ - off-for-timer $\DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":false,"toggle_after":$EVTPART1}}\ + on-for-timer $\DEVICETOPIC/rpc {"id":1,"src":"fhem2shelly","method":"Switch.Set","params": {"id":1,"on":true,"toggle_after":$EVTPART1}}\ + off-for-timer $\DEVICETOPIC/rpc {"id":1,"src":"fhem2shelly","method":"Switch.Set","params": {"id":1,"on":false,"toggle_after":$EVTPART1}}\ x_update:noArg $\DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Shelly.Update","params": {"stage":"stable"}}\ x_reboot:noArg $\DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Shelly.Reboot"} attr DEVICE jsonMap params_switch_0_state:state params_switch_0_aenergy_total:aenergy_total params_switch_0_apower:apower params_switch_0_temperature_tC:temperature params_switch_0_temperature_tF:0 params_wifi_sta_ip:ip loop:#:1 copy DEVICE DEVICE_CH# deleteattr DEVICE_CH# stateFormat -deleteattr DEVICE_CH# devStateIcon +attr DEVICE_CH# devStateIcon { my $light = FW_makeImage(ReadingsVal($name,'state','off')); my $cons = ReadingsNum($name,'apower',0); my $total = round(ReadingsNum($name,'aenergy_total',0)/1000,1);qq(${light}
Verbrauch: $cons W / Total: $total kwhC
) } attr DEVICE_CH# jsonMap params_switch_#_state:state params_switch_#_aenergy_total:aenergy_total params_switch_#_apower:apower params_switch_#_temperature_tC:temperature params_switch_#_temperature_tF:0 attr DEVICE_CH# readingList $\DEVICETOPIC/events/rpc:.* { return if $EVENT !~ m{switch:#}; $EVENT =~ s/"output":true/"state":"on"/g; $EVENT =~ s/"output":false/"state":"off"/g; json2nameValue($EVENT,'',$JSONMAP) }\ $\DEVICETOPIC/status/switch.#:.* { json2nameValue($EVENT, '', $JSONMAP) } attr DEVICE_CH# setList toggle:noArg $\DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Toggle","params": {"id":#}}\ off:noArg $\DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":#,"on":false}}\ on:noArg $\DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":#,"on":true}}\ - on-for-timer $\DEVICETOPIC/rpc {"id"shellyPlus_2pm_split:0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":#,"on":true,"toggle_after":$EVTPART1}}\ + on-for-timer $\DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":#,"on":true,"toggle_after":$EVTPART1}}\ off-for-timer $\DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":#,"on":false,"toggle_after":$EVTPART1}} +attr DEVICE_CH# IODev IODEVNAME loop:END rename DEVICE_CH1 DEVICE_CH2 loop:#:2 @@ -3645,7 +3647,7 @@ attr DEVICE_CH# devicetopic DEV_TPC loop:END set DEVICE attrTemplate set_associatedWith \CHANNELS=2 set DEVICE,DEVICE_CH2 attrTemplate speechcontrol_type_switch -setreading DEVICE,DEVICE_CH2 attrTemplateVersion 20221229 +setreading DEVICE,DEVICE_CH2 attrTemplateVersion 20230104 attr DEVICE,DEVICE_CH2 model shellyPlus_2pm_split # Shelly Plus 2 PM using original firmware in roller mode. @@ -3690,6 +3692,7 @@ filter:TYPE=MQTT2_DEVICE desc:Incomlete first version of split template for second generation shelly devices (names with "plus", with power measurement). NOTE: as channels 2-4 do not work, only channel 2 is created for further testing... par:CALLSPEECHRECOGN;Set this to 0 to not set any speech recogn. related attributes;{ 1 } par:DEV_TPC;Shelly name in the topic;{ AttrVal('DEVICE','devicetopic',AttrVal('DEVICE','readingList','')) =~ m<(shellies/[^/]+|shellyp(lus|ro4pm)[^/:_]{4,}+)> ? $1 : undef } +par:IODEVNAME;Name of the IO-Device; { InternalVal('DEVICE','LASTInputDev',AttrVal('DEVICE','IODev',InternalVal('DEVICE','IODev',undef)->{NAME})) } 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(${onl}${light}
Verbrauch: $cons W / Total: $total kwh / Temp: $temp °C
)} @@ -3718,6 +3721,7 @@ attr DEVICE_CH# setList toggle:noArg $\DEVICETOPIC/rpc {"id":0,"src":"fhem2shell on:noArg $\DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":#,"on":true}}\ on-for-timer $\DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":#,"on":true,"toggle_after":$EVTPART1}}\ off-for-timer $\DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":#,"on":false,"toggle_after":$EVTPART1}} +attr DEVICE_CH# IODev IODEVNAME loop:END rename DEVICE_CH3 DEVICE_CH4 rename DEVICE_CH2 DEVICE_CH3 @@ -3728,7 +3732,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 20220505 +setreading DEVICE,DEVICE_CH2,DEVICE_CH3,DEVICE_CH4 attrTemplateVersion 20230104 attr DEVICE,DEVICE_CH2,DEVICE_CH3,DEVICE_CH4 model shellypro4pm