Skip to content

Commit

Permalink
fix: fix the installation instructions (#208)
Browse files Browse the repository at this point in the history
* fix: fix the installation instructions and separate the installations instruction in differents files

Closes: #120
  • Loading branch information
ColinRgm authored Dec 16, 2024
1 parent 875db14 commit 280dc77
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 94 deletions.
94 changes: 0 additions & 94 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,97 +33,3 @@ For this project to work you need to have the following installed on the server:
- [Docker Engine](https://docs.docker.com/engine/install/ubuntu/)
- [Docker Compose](https://docs.docker.com/compose/install/)
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)

## Installation
First thing you need to do is to clone the repository from GitHub on the server
```bash
git clone https://github.com/museebolo/climat_guardian.git
cd climat-guardian
```

--
[Info]: <> (
This is the list of all the files that end with .example
)
Once the repository is cloned you can remove the `.example` at the end of the following files:
- .env.example
- esp32/config/secrets.yaml.example
```bash
cp .env.example .env
cp esp32/config/secrets.yaml.example esp32/config/secrets.yaml
```

---
Now you want to generate a secret key for the jwt tokens used by the api
```bash
sed -i '/JWT_SECRET/d' .env
echo "JWT_SECRET=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 32)" >> .env
```

You may also want to generate a random password for the database
```bash
sed -i '/POSTGRES_PASSWORD/d' .env
echo "POSTGRES_PASSWORD=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 32)" >> .env
```

It is recommended to let the other environment variables as they are

---
Then you have to install the project's dependencies, in the nextjs-interface folder
```bash
npm i
```

And also install php, in the php folder
```bash
composer install
```

---
Finally, you **have to** fill the Wi-Fi credentials in `esp32/config/secrets.yaml`\
You also **have to** change the `127.0.0.1` in `esp32/config/secrets.yaml` by the ip address of the server

## Start the project
Once everything is configured on the server, you can start the project by running the docker compose on the server
```bash
docker compose -f docker-compose.prod.yml up -d --remove-orphans --build
```
Once the docker is running you can access the web interface by going to the ip address of the server in the web browser of the computer\
the default user is `admin` and has `admin` as password, it is recommended to create a new user and delete the default one once you are connected, you can do so under the ``Users`` tab

You can check if all the containers are working by using the following command
```bash
docker compose ps
```

![Dashboard](/.assets/dashboard.png)
![Plan](/.assets/plan.png)
![Users](/.assets/users.png)
![Esp page](/.assets/esp.png)

## ESP 32 Installation
This project uses [esp home](https://github.com/esphome/esphome) to manage the esp32, you can configure the esp32 by following the instructions below
- Connect yourself to the esp home interface by going to `127.0.0.1/esp` in the web browser of the computer (replace `127.0.0.1` with the ip address of the server)
- Plug the esp32 to the server
- Press the `+ NEW DEVICE` button inside esp home
- Name your device
- Select `ESP32` (on the top of the list)
- Press `INSTALL` and select `Plug into the computer running ESPHome Dashboard` (the 3rd option)
- Select the device with ``/dev/ttyUSB0`` as path
- Wait for the installation to finish\
Be sure to memorize the ip address of the esp32 (you can find it in the logs)
$${\color{gray} \text{[15:39:12]} \color{magenta} \text{[C]\[wifi:416\]: IP Address: 172.16.5.65}}$$
- You can now unplug the esp32 and plug it to any other power source
- Connect yourself to the dashboard from another tab in the web browser of the computer
- Press the ``ajouter un esp`` button on the left and enter the ip address of the esp32 with the name you want it to have in the interface
- Back on the esphome, press `Edit` at the bottom of the logs
- Copy everything from the line 31 of the file `esp32/esp32.yaml` on the server and paste it at the end of your esp32's configuration file
```bash
clear && cat esp32/esp32.yaml | sed -n '31,$p'
```
- Press the ``...`` on the right of the page and press ``Afficher et Copier le Token``
- Replace the XXX... at the end of the code with the token you copied
- Press `INSTALL` and select `Wirelessly` (the 1st option)
- Wait for the installation to finish
- Press `STOP` to exit the logs

25 changes: 25 additions & 0 deletions docs/ESP_installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## ESP 32 Installation
This project uses [esp home](https://github.com/esphome/esphome) to manage the esp32, you can configure the esp32 by following the instructions below
- Connect yourself to the esp home interface by going to `127.0.0.1/esp` in the web browser of the computer (replace `127.0.0.1` with the ip address of the server)
- Plug the esp32 to the server
- Press the `+ NEW DEVICE` button inside esp home
- Name your device
- Select `ESP32` (on the top of the list)
- Press `INSTALL` and select `Plug into the computer running ESPHome Dashboard` (the 3rd option)
- Select the device with ``/dev/ttyUSB0`` as path
- Wait for the installation to finish\
Be sure to memorize the ip address of the esp32 (you can find it in the logs)
$${\color{gray} \text{[15:39:12]} \color{magenta} \text{[C]\[wifi:416\]: IP Address: 172.16.5.65}}$$
- You can now unplug the esp32 and plug it to any other power source
- Connect yourself to the dashboard from another tab in the web browser of the computer
- Press the ``ajouter un esp`` button on the left and enter the ip address of the esp32 with the name you want it to have in the interface
- Back on the esphome, press `Edit` at the bottom of the logs
- Copy everything from the line 31 of the file `esp32/esp32.yaml` on the server and paste it at the end of your esp32's configuration file
```bash
clear && cat esp32/esp32.yaml | sed -n '31,$p'
```
- Press the ``...`` on the right of the page and press ``Afficher et Copier le Token``
- Replace the XXX... at the end of the code with the token you copied
- Press `INSTALL` and select `Wirelessly` (the 1st option)
- Wait for the installation to finish
- Press `STOP` to exit the logs
67 changes: 67 additions & 0 deletions docs/Installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
## Installation
First thing you need to do is to clone the repository from GitHub on the server
```bash
git clone https://github.com/museebolo/climat_guardian.git
cd climat_guardian
```

--
[Info]: <> (
This is the list of all the files that end with .example
)
Once the repository is cloned you can remove the `.example` at the end of the following files:
- .env.example
- esp32/config/secrets.yaml.example
```bash
cp .env.example .env
cp esp32/config/secrets.yaml.example esp32/config/secrets.yaml
```

---
Now you want to generate a secret key for the jwt tokens used by the api
```bash
sed -i '/JWT_SECRET/d' .env
echo "JWT_SECRET=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 32)" >> .env
```

You may also want to generate a random password for the database
```bash
sed -i '/POSTGRES_PASSWORD/d' .env
echo "POSTGRES_PASSWORD=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 32)" >> .env
```

It is recommended to let the other environment variables as they are

---
Then you have to install the project's dependencies, in the nextjs-interface folder
```bash
npm i
```

And also install php, in the php folder
```bash
composer install
```

---
Finally, you **have to** fill the Wi-Fi credentials in `esp32/config/secrets.yaml`\
You also **have to** change the `127.0.0.1` in `esp32/config/secrets.yaml` by the ip address of the server

## Start the project
Once everything is configured on the server, you can start the project by running the docker compose on the server
```bash
docker compose -f docker-compose.prod.yml up -d --remove-orphans --build
```
Once the docker is running you can access the web interface by going to the ip address of the server in the web browser of the computer\
the default user is `admin` and has `admin` as password, it is recommended to create a new user and delete the default one once you are connected, you can do so under the ``Users`` tab

You can check if all the containers are working by using the following command
```bash
docker compose ps
```


![Dashboard](/.assets/dashboard.png)
![Plan](/.assets/plan.png)
![Users](/.assets/users.png)
![Esp page](/.assets/esp.png)

0 comments on commit 280dc77

Please sign in to comment.