您需要已经通过 Docker 成功部署了 TeslaMate。本服务将连接到您现有的数据库。 You must have successfully deployed TeslaMate via Docker. This service connects to your existing database.
您可以通过以下任一方式安装 tmate-api 服务端:
You can install the tmate-api service using either of the following methods:
docker-compose.yml)
1. Using Docker Compose (docker-compose.yml)
将以下配置添加到您现有 TeslaMate 文件的 services 部分:
Add the following to the services section of your TeslaMate file:
services:
tmate-api:
image: gdzhujun933/tmate-api:latest
container_name: tmate-api
restart: unless-stopped
environment:
- DB_HOST=database
- DB_PORT=5432
- DB_NAME=teslamate
- DB_USER=teslamate
- DB_PASS=your_password
- MQTT_HOST=mosquitto
- MQTT_PORT=1883
- API_KEY=your_token
ports:
- "9999:8080"
docker run -d \
--name tmate-api \
--network docker_default \
-p 9999:8080 \
--restart unless-stopped \
-e DB_HOST=database \
-e DB_PASS=your_password \
-e API_KEY=your_token \
gdzhujun933/tmate-api:latest
DB_PASS: 必须与您部署 TeslaMate 时的数据库密码完全相同。
DB_PASS: Must match your TeslaMate database password exactly.
API_KEY: 您自定义的 API 密钥(Token)。后续在 App 设置中填入此值。
API_KEY: Your custom API Key (Token). Enter this value in the App settings.
注意: Note:
--network docker_default: 确保此服务与数据库在同一个 Docker 网络中。
--network docker_default: Ensure service and DB are in the same Docker network.
-p 9999:8080: 您可以根据需要修改宿主机端口 9999。
-p 9999:8080: You can change host port 9999 as needed.
安装完 App 后,在设置中填写以下信息: In the App Settings, fill in the following:
http://IP:9999
API_KEY 的值。
Enter the value of your API_KEY.