Hallo liebe Gemeinde
Ich habe ein Problem und weiß leider im Moment nicht wie ich das lösen kann?
Ich habe einen ShellyPro4PM per MQTT eingebunden und ein UserReading mit Monotonic erstellt damit ich Werte nach Stromausfall nicht verliere. So weit so gut.
Nun habe ich eine neu SD Karte aufgesetzt, FHEM installier und upgedated und mein BU restored und das userReadings "aenergy_total_kWh stimmt nicht mehr,
da das ursprüngliche Readings "aenergy_total" ja ei anderes ist.
Anbei ein List vom original System:
Internals:
CID shellypro4pm_083af27b3304
DEF shellypro4pm_083af27b3304
FUUID 62728c75-f33f-b033-8005-ce1b5dc400cc450c
IODev myBroker
NAME MQTT2_shellypro4pm_083af27b3304
NR 550
STATE off
TYPE MQTT2_DEVICE
JSONMAP:
params_switch_0_aenergy_total aenergy_total
params_switch_0_apower apower
params_switch_0_state state
params_switch_0_temperature_tC temperature
params_switch_0_temperature_tF 0
params_wifi_sta_ip ip
READINGS:
2022-12-07 12:54:42 IODev myBroker
2022-09-27 10:31:42 Kosten 193.58
2022-12-06 12:59:00 aenergy_by_minute_1 0.000
2022-12-06 12:59:00 aenergy_by_minute_2 0.000
2022-12-06 12:59:00 aenergy_by_minute_3 0.000
2022-12-06 12:59:00 aenergy_minute_ts 1670327939
2022-12-06 12:59:00 aenergy_total 250211.719
2022-09-27 10:31:42 aenergy_total_kWh 967.880138000124
2022-12-06 12:59:00 apower 0.0
2022-05-04 16:24:31 associatedWith MQTT2_shellypro4pm_083af27b3304_CH2,MQTT2_shellypro4pm_083af27b3304_CH3,MQTT2_shellypro4pm_083af27b3304_CH4
2022-05-04 16:24:31 attrTemplateVersion 20220115
2022-05-05 16:24:47 cfg_rev 10
2022-12-06 00:22:27 connected true
2022-12-06 12:59:00 current 0.000
2022-12-06 12:59:00 dst shellypro4pm-083af27b3304/events
2022-05-05 16:24:47 fs_free 282624
2022-05-05 16:24:47 fs_size 524288
2022-12-06 12:59:00 id 0
2022-05-05 16:24:47 mac 083AF27B3304
2022-12-06 12:59:00 method NotifyStatus
2022-12-06 00:22:26 online true
2022-12-06 12:59:00 output false
2022-09-27 18:14:16 params_events_1_cfg_rev 15
2022-09-27 18:14:16 params_events_1_component switch:0
2022-09-27 18:14:16 params_events_1_event config_changed
2022-09-27 18:14:16 params_events_1_id 0
2022-09-27 18:12:13 params_events_1_msg Waiting for data
2022-09-27 18:12:13 params_events_1_progress_percent 22
2022-09-27 18:14:16 params_events_1_restart_required false
2022-09-27 18:14:16 params_events_1_ts 1664295256.53
2022-12-06 00:22:26 params_mqtt_connected true
2022-12-06 12:59:00 params_switch_0_aenergy_by_minute_1 0.000
2022-12-06 12:59:00 params_switch_0_aenergy_by_minute_2 0.000
2022-12-06 12:59:00 params_switch_0_aenergy_by_minute_3 0.000
2022-12-06 12:59:00 params_switch_0_aenergy_minute_ts 1670327939
2022-09-27 18:14:33 params_switch_0_current 0
2022-12-06 12:59:00 params_switch_0_id 0
2022-09-27 18:14:33 params_switch_0_pf 0
2022-09-27 18:14:33 params_switch_0_source WS_in
2022-11-13 17:47:55 params_switch_0_voltage 227.9
2022-12-05 17:13:37 params_sys_available_updates_beta_version 0.12.0-beta3
2022-12-05 17:13:37 params_sys_available_updates_stable_version 0.11.4
2022-12-06 12:59:00 params_ts 1670327940.83
2022-12-06 12:59:00 pf 0.00
2022-05-05 16:24:47 ram_free 155084
2022-05-05 16:24:47 ram_size 238192
2022-05-05 16:24:47 restart_required false
2022-12-06 12:59:00 source init
2022-12-06 12:59:00 src shellypro4pm-083af27b3304
2022-09-27 18:14:33 state off
2022-12-04 23:59:19 temperature 15.74
2022-12-06 12:59:00 temperature_tC 15.9
2022-12-06 12:59:00 temperature_tF 60.5
2022-05-05 16:24:47 time 16:24
2022-05-05 16:24:47 unixtime 1651760687
2022-05-05 16:24:47 uptime 86414
2022-12-06 12:59:00 voltage 231.2
2022-05-04 16:24:29 x_reboot set
Attributes:
alias Poolpumpe
autocreate 0
comment Channel 1 for MQTT2_shellypro4pm_083af27b3304, see also MQTT2_shellypro4pm_083af27b3304_CH2, MQTT2_shellypro4pm_083af27b3304_CH3 and MQTT2_shellypro4pm_083af27b3304_CH4
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_tC','-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>)}
devicetopic shellypro4pm-083af27b3304
event-on-change-reading .*
getList in_mode:noArg in_mode $DEVICETOPIC/rpc {"id": 1,"src":"$DEVICETOPIC", "method": "Switch.GetConfig", "params": {"id": 0}}
icon message_socket
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
model shellypro4pm
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:.* {}
$DEVICETOPIC/status/switch.0:.* { json2nameValue($EVENT, '', $JSONMAP) }
$DEVICETOPIC/status/mqtt:.* { json2nameValue($EVENT, '', $JSONMAP) }
room MQTT2_DEVICE,Poolsteuerung
setList 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}}
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"}
setStateList on off
userReadings aenergy_total_kWh:aenergy_total:.* monotonic {ReadingsNum($name,'aenergy_total',0)/1000.0}, Kosten:aenergy_total_kWh.* { sprintf("%.2f",(ReadingsNum($name,'aenergy_total_kWh',0) + 0.0)*.2);;}
webCmd :
und ein List nach dem Restore
Internals:
CID shellypro4pm_083af27b3304
DEF shellypro4pm_083af27b3304
FUUID 62728c75-f33f-b033-8005-ce1b5dc400cc450c
IODev myBroker
LASTInputDev myBroker
MSGCNT 14407
NAME MQTT2_shellypro4pm_083af27b3304
NR 546
STATE set_off
TYPE MQTT2_DEVICE
eventCount 4801
myBroker_CONN myBroker_10.0.0.186_60479
myBroker_MSGCNT 14407
myBroker_TIME 2022-12-10 14:57:28
JSONMAP:
params_switch_0_aenergy_total aenergy_total
params_switch_0_apower apower
params_switch_0_state state
params_switch_0_temperature_tC temperature
params_switch_0_temperature_tF 0
params_wifi_sta_ip ip
READINGS:
2022-12-09 12:18:47 IODev myBroker
2022-12-06 13:18:36 Kosten 50.04
2022-12-10 14:57:00 aenergy_by_minute_1 0.000
2022-12-10 14:57:00 aenergy_by_minute_2 0.000
2022-12-10 14:57:00 aenergy_by_minute_3 0.000
2022-12-10 14:57:00 aenergy_minute_ts 1670680619
2022-12-10 14:57:28 aenergy_total 250211.719
2022-12-06 13:18:36 aenergy_total_kWh 250.211719
2022-12-10 14:57:00 apower 0.0
2022-12-09 12:18:52 connected true
2022-12-10 14:57:00 current 0.000
2022-12-10 14:57:28 dst shellypro4pm-083af27b3304/events
2022-12-10 14:57:00 id 0
2022-12-10 14:57:28 method NotifyStatus
2022-12-09 12:18:52 online true
2022-12-10 14:57:00 output false
2022-12-09 12:18:52 params_mqtt_connected true
2022-12-10 14:57:28 params_switch_0_aenergy_by_minute_1 0.000
2022-12-10 14:57:28 params_switch_0_aenergy_by_minute_2 0.000
2022-12-10 14:57:28 params_switch_0_aenergy_by_minute_3 0.000
2022-12-10 14:57:28 params_switch_0_aenergy_minute_ts 1670680619
2022-12-10 14:57:28 params_switch_0_id 0
2022-12-09 17:13:28 params_sys_available_updates_stable_version 0.12.0
2022-12-10 14:57:28 params_ts 1670680620.97
2022-12-10 14:57:00 pf 0.00
2022-12-10 14:57:00 source init
2022-12-10 14:57:28 src shellypro4pm-083af27b3304
2022-12-09 20:00:00 state set_off
2022-12-10 01:45:40 temperature 15.74
2022-12-10 14:57:00 temperature_tC 15.0
2022-12-10 14:57:00 temperature_tF 58.9
2022-12-10 14:57:00 voltage 226.4
Attributes:
alias Poolpumpe
autocreate 0
comment Channel 1 for MQTT2_shellypro4pm_083af27b3304, see also MQTT2_shellypro4pm_083af27b3304_CH2, MQTT2_shellypro4pm_083af27b3304_CH3 and MQTT2_shellypro4pm_083af27b3304_CH4
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_tC','-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>)}
devicetopic shellypro4pm-083af27b3304
event-on-change-reading .*
getList in_mode:noArg in_mode $DEVICETOPIC/rpc {"id": 1,"src":"$DEVICETOPIC", "method": "Switch.GetConfig", "params": {"id": 0}}
icon message_socket
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
model shellypro4pm
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:.* {}
$DEVICETOPIC/status/switch.0:.* { json2nameValue($EVENT, '', $JSONMAP) }
$DEVICETOPIC/status/mqtt:.* { json2nameValue($EVENT, '', $JSONMAP) }
room MQTT2_DEVICE,Poolsteuerung
setList 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}}
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"}
setStateList on off
userReadings aenergy_total_kWh:aenergy_total:.* monotonic {ReadingsNum($name,'aenergy_total',0)/1000.0}, Kosten:aenergy_total_kWh.* { sprintf("%.2f",(ReadingsNum($name,'aenergy_total_kWh',0) + 0.0)*.2);;}
webCmd :
Ich stehe im Moment auf der Leitung wie ich das beim nächsten mal vermeiden kann?
Ja ich könnte in meinem userReadings bei
(ReadingsNum($name,'aenergy_total_kWh',0) + 0.0)*.2);;}
Bei +0.0 die kWh anpassen? Is glaube ich nicht die sauberste Art, weil ich nicht jedesmal vor einem Restore einen Screenshot meiner rg_Kosten mache
Danke für eure Unterstützung
LG
Helmut
Hi,
dann hast Du beim restore dein state File nicht gehabt?
Das alte Reading wird doch eigentlich beim Start entsprechend state File gesetzt sonst ginge ja ein Neustart gar nicht.
Ja ein Stromausfall ist kritisch, dann kann der alte Wert alt sein :)
Jetzt machst Du einfach ein, dann geht es bei dem Wert weiter setreading MQTT2_shellypro4pm_083af27b3304 aenergy_total_kWh 967.880138000124
Gruß
Hallo Otto
Danke für den Tipp mit dem setreading. Das klappt natürlich.
ABER die Frage, wieso kann state File verschwinden?
Ich habe ds Backup in FHEM angestoßen und nach deiner super Anleitung das Restore am neuen System durchgeführt
Muss oder kann ich das extra sichern?
Schönen Abend
Helmut
Hallo Helmut,
zum schauen:
{qx(ls -lha log/fhem.save)}
Die Datei wird beim ordentlichen Restart oder bei einem save geschrieben. Im normalen backup ist die enthalten.
Gruß Otto
N'Abend
das wird zurückgeliefert
-rwxrwxrwx 1 fhem dialout 244K 10. Dez 22:13 log/fhem.save
Ich hatte vergessen, das ist nicht nur bei dem einen Device sondern bei der gesamten rG
Danke für deine Unterstützung
Gruß
Helmut
naja dann hattest Du gerade restart oder save?
Die Rechtemaske ist unnütz "hoch" gesetzt, aber das stört für diesen Fall nicht.
Es ist klar, wenn diese Datei alte Werte enthält werden alle Readings in FHEM auf alte Startwerte gesetzt.
Hallo Otto,
danke für deine Zeit.
Ich habe am alten System über die FHEM Eingabezeile ein "backup" angestoßen.
Ich habe aber keinen Systemstop (systemctl stop fhem) ausgeführt - kann das der Fehler sein?
Muß/soll ich vor dem "backup" noch ein save machen?
Danach am neuen System das Backup eingespielt
sudo tar -xvzf /home/pi/FHEM-202xxxxx_xxxxxx.tar.gz -C /opt/fhem/
Ich dachte das auf diese Art und Weise alles notwendige "mitgenommen" wird....
Gruß
Helmut
Hallo Helmut,
ja so wird es wohl sein. Das mit dem save vor dem backup ist auch so ne Sache, aus gutem Grunde wird ja autosave manchmal beim Start deaktiviert, dann würde das save nicht ausgeführt.
Aber vor einem Umzug sollte man auf alle Fälle erst ein save und dann ein backup machen. (Muss mal schauen ob ich das so dokumentiert habe)
Irgendwie gibt es keine dokumentierte Funktion für den Anwender das stateFile separat zu sichern, ich habe zumindest nichts gefunden.
Gruß Otto
Danke Otto für deine ausführliche Info
Schönen 3. Advent
Gruß aus Niederösterreich
Helmut
Helmut, Dir auch einen schönen dritten Advent ;D
Grüße aus einem leicht in Schnee gehüllten Markranstädt
Otto