Hallo Beta-User,
habe die Änderung getestet Fehler bleibt. Habe zusätzlichfhem neu gestartet
Hier der geänderte Bereich:
#contributed by 87insane, https://forum.fhem.de/index.php/topic,94060.msg934614.html#msg934614
# shelly1pm using original firmware.
name:shelly1_w_energy_measuring
filter:TYPE=MQTT2_DEVICE:FILTER=readingList=.*shellies.*
order:A_10b
desc:Applies to single relay Shelly devices offering energy measuring like Shelly 1PM or Shelly Plug S
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 relay_0_energy_total is included, otherwise it will be added;{ my $old = AttrVal('DEVICE','userReadings',undef); !defined $old ? 'relay_0_energy_total:relay_0_energy:.* monotonic {ReadingsNum($name,'relay_0_energy',0)}' : $old =~ m,relay_0_energy_total:relay_0_energy.*, ? $old : $old . q(, relay_0_energy_total:relay_0_energy:.* monotonic {ReadingsNum($name,'relay_0_energy',0)}) }
par:CALLSPEECHRECOGN;Set this to 0 to not set any speech recogn. related attributes;{ 1 }
attr DEVICE setList\
relay0:on,off,toggle shellies/DEVNAME/relay/0/command $EVTPART1\
toggle:noArg shellies/DEVNAME/relay/0/command toggle\
off:noArg shellies/DEVNAME/relay/0/command off\
on:noArg shellies/DEVNAME/relay/0/command on\
x_update:noArg shellies/DEVNAME/command update_fw\
x_mqttcom shellies/DEVNAME/command $EVTPART1
attr DEVICE readingList \
shellies/DEVNAME/relay/0:.* {{ state => $EVENT, relay0 => $EVENT}}\
shellies/DEVNAME/input/0:.* input0\
shellies/DEVNAME/online:.* online\
shellies/announce:.* { $EVENT =~ m,..id...DEVNAME...mac.*, ? json2nameValue($EVENT) : return }\
shellies/DEVNAME/announce:.* { json2nameValue($EVENT) }\
shellies/DEVNAME/relay/0/power:.* relay_0_power\
shellies/DEVNAME/relay/0/power:.* { my $compare = $EVTPART0 < 100 ? 'off':'on'; ReadingsVal($NAME,'loadState','off') ne $compare ? { loadState => $compare } : return }\
shellies/DEVNAME/temperature:.* temperature\
shellies/DEVNAME/temperature_f:.* {}\
shellies/DEVNAME/input_event/0:.* { json2nameValue($EVENT) }\
shellies/DEVNAME/overtemperature:.* overtemperature\
shellies/DEVNAME/relay/0/energy:.* { relay_0_energy => $EVENT, relay_0_kWh => sprintf("%.2f",$EVENT/60/1000)}\
shellies/DEVNAME/longpush/0:.* longpush_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'; my $light = ReadingsVal($name,'state','off'); my $cons = ReadingsVal($name,'relay_0_power','unknown'); my $total = ReadingsVal($name,'relay_0_kWh','unknown'); my $temp = ReadingsVal($name,'temperature','-100'); "<a href=\"http://".ReadingsVal($name,'ip','none')." \"target=\"_blank\">".FW_makeImage($onl)."</a> <a href=\"/fhem?cmd.dummy=set $name toggle&XHR=1\">".FW_makeImage($light)."</a><div>Verbrauch: $cons / Total: $total/ Temp: $temp °C</div>"}
attr DEVICE comment To get appropriate loadState values: Change the default limit "100" in readingList to your needs.
attr DEVICE webCmd :
attr DEVICE setStateList on off toggle
deletereading -q DEVICE (?!associatedWith|IODev).*
set DEVICE x_mqttcom announce
attr DEVICE model shelly1_w_energy_measuring
setreading DEVICE attrTemplateVersion 20220404
option:{ CALLSPEECHRECOGN }
set DEVICE attrTemplate speechcontrol_type_switch
option:{ RADIO_SETUSERREADING }
attr DEVICE userReadings NEWUSERREADINGS