-
Notifications
You must be signed in to change notification settings - Fork 50
Setup Instructions
You will need your iPhone and console access to the server you are using or plan to use for Homebridge. All the following steps are to be performed on the console of your server, unless stated. While it might appear to be just too much, it hardly takes 5 minutes to get done.
Make sure you perform the cleanup steps after you are done.
While the number of steps might scare you, they hardly take 5 minutes if you already have Homebridge working.
- If you haven't already, install and configure Homebridge.
- Install this plugin using
npm i -g homebridge-tuya-lan
. - Add all your devices to the Tuya Smart app to avoid having to repeat the following painful steps.
- Follow these steps to get the
id
andkey
combinations for the devices:-
Execute
npm i -g anyproxy @tuyapi/cli
. -
Execute
anyproxy-ca
to generate a CA Root certificate; when prompted to generate one, sayy
for yes.- We will remove this later on too.
-
The CA Root certificate you just generated, needs to be trusted.
-
On Linux, do the following:
sudo mkdir /usr/share/ca-certificates/extra/ sudo cp $HOME/.anyproxy/certificates/rootCA.crt /usr/share/ca-certificates/extra/ sudo dpkg-reconfigure ca-certificates
The last command will open up a GUI; hit
yes
on the first prompt. Using the arrows on your keyboard, locateextra/rootCA.crt
, place an*
next to it by hitting the space bar, hit theTab
key on your keyboard to highlightOK
, and press theEnter
key.
-
On Window, open an elevated command prompt and run the following:
certutil -addstore -f "ROOT" "%USERPROFILE%\.anyproxy\certificates\rootCA.crt"
-
On macOS:
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain $HOME/.anyproxy/certificates/rootCA.crt
-
-
Execute
tuya-cli list-app
. Within a few seconds, you would be shown (a) a QR code and (b) details of the proxy server. -
Scan the barcode with your iPhone. If you don't know how to do that, just say "Hey Siri, scan a QR code!" and point the camera at the barcode.
-
Your phone will ask you your permission to open Safari; let it.
-
Safari will alert you that the website is trying to open the settings; allow that too. This will open
Install Profile
. -
On the
Install Profile
screen, hitInstall
on the top-right of the screen. If your phone has a passcode, you would be asked to enter it. This will open up aWarning
screen. -
On the
Warning
screen, hitInstall
. A confirmation dialog will pop up; hitInstall
again. Finally hitDone
to close it all.- We will get rid of this later.
-
On your iPhone, go to
Settings
and openGeneral
andAbout
. Towards the bottom, locate and openCertificate Trust Settings
. -
Enable full trust for
AnyProxy
by flicking its switch. You will be prompted with a warning; just hitContinue
. -
On your iPhone, go to
Settings
and openWi-Fi
. Hit the info button, which is a bluei
in a circle, for the WiFi connection you are using. This will open the configuration for your connection. -
On your WiFi connection screen, scroll to the bottom and hit
Configure Proxy
. This will open the proxy configuration screen. -
On the proxy configuration screen, tap on
Manual
to reveal additional settings. Use the details from step 4 (above) to fill in the server and port.- The text below the QR code should read "Set your HTTP proxy IP to
SERVER
with portPORT
"; simply enter those values into the fields of the proxy configuration. - Leave the
Authentication
switch off. - Here on, your phone will not be able to open anything so don't panic.
- The text below the QR code should read "Set your HTTP proxy IP to
-
Open the Tuya Smart app; if it was already open, pull the screen down to refresh. In a few seconds, you would be shown an error dialog about your network connection; that is exactly what we want.
-
A bunch of
id
andkey
combinations will be shown on the console, below the QR code you scanned earlier. -
After storing the
id
andkey
combinations elsewhere, follow the clean up instructions below to get rid of all the things we won't need anymore, and to be able to use your phone again.
-
- Update the
config.json
file of your Homebridge setup, by modifying the sample configurations and using theid
andkey
combinations.
After taking note of your id
and key
combinations, you have no need for anyproxy
or @tuyapi/cli
. Follow this steps to revert the changes you made above. Do not miss these!
- On your iPhone, go to
Settings
and openWi-Fi
. Hit the info button, which is a bluei
in a circle, for the WiFi connection you are using. OpenConfigure Proxy
and selectOff
. - On your iPhone, go to
Settings
>General
>About
>Certificate Trust Settings
and switch off full trust forAnyProxy
. - On your iPhone, go to
Settings
>General
>Profiles & Device Management
>AnyProxy
and tapRemove Profile
. If one is set, you will be asked to enter your passcode. You would also be asked to confirm that you want to remove the profile; hitRemove
. - Remove AnyProcy's CA Root certificate we installed earlier:
-
On Linux, do the following:
sudo dpkg-reconfigure ca-certificates
This command will open up a GUI; hit
yes
on the first prompt. Using the arrows on your keyboard, locateextra/rootCA.crt
, remove the*
next to it by hitting the space bar, hit theTab
key on your keyboard to highlightOK
, and press theEnter
key. Then execute:sudo rm -rf $HOME/.anyproxy /usr/share/ca-certificates/extra
-
On Window, open an elevated command prompt and run the following:
certutil -delstore "ROOT" AnyProxy rmdir /S /Q "%USERPROFILE%\.anyproxy"
-
On macOS:
sudo security delete-certificate -c "AnyProxy" rm -rf $HOME/.anyproxy
-
- Run
npm r -g anyproxy @tuyapi/cli
to uninstall those packages.