Skip to content

[How to] Use the device OFFLINE (disconnected from tuya servers) ?

Wagner edited this page Aug 8, 2022 · 1 revision

Yes, there're two ways to make the device work offline (disconnected from the tuya servers).

Option 1 (Preferred):

This is also known as the Universal offline method because it should work on all devices without additional patching.

All you have to do is:

  1. make sure (download+unzip) this offline script is on the root of the SD card
  2. make sure (download+unzip) this hosts file is on the root of the SD card
  3. make sure your custom.sh file has the line /mnt/mmc01/offline.sh & inside the main if section without a # in front, so it looks like this:
!/bin/sh
if [ ! -e /tmp/customrun ]; then
 echo custom > /tmp/customrun
 cp /mnt/mmc01/passwd /etc/passwd
 /mnt/mmc01/busybox telnetd
 /mnt/mmc01/busybox httpd -c /mnt/mmc01/httpd.conf -h /mnt/mmc01 -p 8080
 if [ -e /mnt/mmc01/ppsapp ]; then
  PPSID=$(ps | grep -v grep | grep ppsapp | awk '{print $1}')
  kill $PPSID
  /mnt/mmc01/set record_enable 0
  #/mnt/mmc01/set enable_event_record 1
  /mnt/mmc01/ppsapp &
 fi
 /mnt/mmc01/offline.sh &
fi

NOTICE: This method requires internet access to be available. The device will boot up, use the internet connection to connect to Tuya servers momentarily (just enough to set the date/time on the device to allow it to finish booting up) then it will drop offline to disconnect from the tuya servers and finally reconnect to the wifi (so you can use it locally). The whole process should only take a few minutes and you should be able to verify that it blocked connections to the tuya servers by executing cat /tmp/offline.log in telnet.

Option 2 (extra patching):

If you plan to use the device on an isolated network (no internet access at all), the only option to allow the device to boot completely (and enable RTSP/ONVIF) is by patching ppsapp to not 'wait' for a connection to the tuya server during boot. Some firmware versions have an 'offline' patch available and there are instructions on how to build an offline patch buried in https://github.com/guino/BazzDoorbell/issues/4 -- if you have a firmware without an offline patch and need to use the device on an isolated network feel free to request an offline patch for it but I would like to avoid making offline patches in general as it takes extra time for me to create them. Also keep in mind that if you'd like the date/time to be correct you will also need to create an NTP server within the isolated network (and add a command to custom.sh to start the NTP client) so that the device displays the correct date/time in the video feed.

I understand that many people have concerns with keeping open connections to tuya servers as a potential security risk and this is why I am providing this information -- I do believe 'Option 1' is enough to limit the risks/exposure considerably. Personally I still leave my devices connected to the internet (100% of the time) because I like to use the phone app, but I also have placed my devices in a 'guest' network with internet access and no actual access to the computers on my network, so you should decide how you deal with security on your network.