Skip to content

Commit

Permalink
keep cloud configuration on factory reset
Browse files Browse the repository at this point in the history
  • Loading branch information
benderl committed Jan 2, 2025
1 parent 7f7718b commit 1fa7200
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/helpermodules/subdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,9 +839,11 @@ def process_system_topic(self, client: mqtt.Client, var: dict, msg: mqtt.MQTTMes
self.set_json_payload(var["system"].data["backup_cloud"], msg)
elif ("openWB/system/dataprotection_acknowledged" == msg.topic and
decode_payload(msg.payload) is False):
Pub().pub("openWB/set/command/removeCloudBridge/todo", {
"command": "removeCloudBridge"
})
if self.event_subdata_initialized.is_set():
Pub().pub("openWB/set/command/removeCloudBridge/todo",
{"command": "removeCloudBridge"})
else:
log.debug("skipping data protection message on startup")
else:
if "module_update_completed" in msg.topic:
self.event_module_update_completed.set()
Expand Down
16 changes: 16 additions & 0 deletions runs/factory_reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,28 @@ fi

case "$1" in
"clearall")
echo "checking for configured cloud bridge..."
cloud_bridge=$(timeout 1 mosquitto_sub -t 'openWB/system/mqtt/bridge/+' | grep -E '"is_openwb_cloud": ?true')
if [ -n "$cloud_bridge" ]; then
echo "cloud bridge is configured"
valid_partner_ids=$(timeout 1 mosquitto_sub -t 'openWB/system/mqtt/valid_partner_ids' -C 1)
else
echo "no cloud bridge configured"
fi
echo "deleting retained message store of external mosquitto..."
timeout 3 mosquitto_sub -t '#' --remove-retained --retained-only
echo "deleting retained message store of internal mosquitto..."
timeout 3 mosquitto_sub -t '#' --remove-retained --retained-only -p 1886
echo "deleting log data"
rm -r "$OPENWBBASEDIR/data/charge_log/"* "$OPENWBBASEDIR/data/daily_log/"* "$OPENWBBASEDIR/data/log/"*.log "$OPENWBBASEDIR/data/monthly_log/"*
echo "reset display rotation"
sudo sed -i "s/^lcd_rotate=[0-3]$/lcd_rotate=0/" "/boot/config.txt"
if [ -n "$cloud_bridge" ]; then
echo "restore cloud bridge configuration: $cloud_bridge"
mosquitto_pub -t 'openWB/command/max_id/mqtt_bridge' -r -m 1 -p 1886
mosquitto_pub -t 'openWB/system/mqtt/valid_partner_ids' -r -m "$valid_partner_ids" -p 1886
mosquitto_pub -t 'openWB/system/mqtt/bridge/0' -r -m "$cloud_bridge" -p 1886
fi
echo "all done";;
*)
echo "please pass \"clearall\" as parameter if you really want to reset all data stored in the internal and external broker"
Expand Down

0 comments on commit 1fa7200

Please sign in to comment.