Creating a Factory Reset Daemon for SUSI.AI Smart Speaker

In our constantly evolving SUSI.AI Smart Speaker project, we require regular updates for our devices. And imagine a scenario that during a crucial update, there is a crash or an internet disconnection which stops the SUSI.AI Linux program from booting up. We’ll require a reset method for that. So, we have added a button in SUSI smart speaker that works as a factory reset switch. This daemon was accomplished by using python scripting, bash scripting, and Raspbian’s systemd rules.

Approach followed

We have created a python script that detects the button presses on GPIO port 17. The script is run as soon as the Raspberry Pi is booted using the systemd rules and checks for the device inputs. And if the button press is for more than 7 seconds, the script is run which deletes all the contents of the repo and clones it again.


#! /bin/bash
# To be executed using a physical button

SCRIPT_PATH=$(realpath $0)

cd $DIR_PATH/../..
mv susi_linux/ susi_temp
git clone #while testing change to personal repo
cd susi_linux

rm -rf ../susi_temp



Detecting the Button Press

We have Used the library RPi.GPIO to detect button click on raspberry Pi.

while True:
       if GPIO.input(17) == 1:
       elif GPIO.input(17) == 0 :
           start = time.time()
          while GPIO.input(17) == 0 :
          end = time.time()
           total = end – start
           if total >= 7 :
          else :
               mixer = alsaaudio.Mixer()
               value = mixer.getvolume()[0]
              if value != 0:


If the button press is greater than 7 seconds, factory reset process will start and if the press is less than 7 seconds, the button will function as mute button


Auto Booting The program


For the script to autorun everytime the raspberry pi started. We create systemd file which will allow the program to start as soon as the device has started


Description=SUSI Linux Factory Daemon

ExecStart=/usr/bin/python3 /home/pi/SUSI.AI/susi_linux/factory_reset/



This runs the factory reset script to boot up as soon as the Raspberry Pi starts



susi, factory_daemon, factory_reset, gsoc, gsoc’18,susi_linux , fossasia