Skip to content

Commit 424cdd8

Browse files
committed
keep cloud configuration on factory reset
1 parent b11c2a6 commit 424cdd8

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

packages/helpermodules/subdata.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -844,9 +844,11 @@ def process_system_topic(self, client: mqtt.Client, var: dict, msg: mqtt.MQTTMes
844844
self.set_json_payload(var["system"].data["backup_cloud"], msg)
845845
elif ("openWB/system/dataprotection_acknowledged" == msg.topic and
846846
decode_payload(msg.payload) is False):
847-
Pub().pub("openWB/set/command/removeCloudBridge/todo", {
848-
"command": "removeCloudBridge"
849-
})
847+
if self.event_subdata_initialized.is_set():
848+
Pub().pub("openWB/set/command/removeCloudBridge/todo",
849+
{"command": "removeCloudBridge"})
850+
else:
851+
log.debug("skipping data protection message on startup")
850852
else:
851853
if "module_update_completed" in msg.topic:
852854
self.event_module_update_completed.set()

runs/factory_reset.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,28 @@ fi
88

99
case "$1" in
1010
"clearall")
11+
echo "checking for configured cloud bridge..."
12+
cloud_bridge=$(timeout 1 mosquitto_sub -t 'openWB/system/mqtt/bridge/+' | grep -E '"is_openwb_cloud": ?true')
13+
if [ -n "$cloud_bridge" ]; then
14+
echo "cloud bridge is configured"
15+
valid_partner_ids=$(timeout 1 mosquitto_sub -t 'openWB/system/mqtt/valid_partner_ids' -C 1)
16+
else
17+
echo "no cloud bridge configured"
18+
fi
1119
echo "deleting retained message store of external mosquitto..."
1220
timeout 3 mosquitto_sub -t '#' --remove-retained --retained-only
1321
echo "deleting retained message store of internal mosquitto..."
1422
timeout 3 mosquitto_sub -t '#' --remove-retained --retained-only -p 1886
1523
echo "deleting log data"
1624
rm -r "$OPENWBBASEDIR/data/charge_log/"* "$OPENWBBASEDIR/data/daily_log/"* "$OPENWBBASEDIR/data/log/"*.log "$OPENWBBASEDIR/data/monthly_log/"*
25+
echo "reset display rotation"
26+
sudo sed -i "s/^lcd_rotate=[0-3]$/lcd_rotate=0/" "/boot/config.txt"
27+
if [ -n "$cloud_bridge" ]; then
28+
echo "restore cloud bridge configuration: $cloud_bridge"
29+
mosquitto_pub -t 'openWB/command/max_id/mqtt_bridge' -r -m 1 -p 1886
30+
mosquitto_pub -t 'openWB/system/mqtt/valid_partner_ids' -r -m "$valid_partner_ids" -p 1886
31+
mosquitto_pub -t 'openWB/system/mqtt/bridge/0' -r -m "$cloud_bridge" -p 1886
32+
fi
1733
echo "all done";;
1834
*)
1935
echo "please pass \"clearall\" as parameter if you really want to reset all data stored in the internal and external broker"

0 commit comments

Comments
 (0)