⚙️ 配置您的 TeslaMate API ⚙️ Configure Your TeslaMate API

前提条件 Prerequisites

您需要已经通过 Docker 成功部署了 TeslaMate。本服务将连接到您现有的数据库。 You must have successfully deployed TeslaMate via Docker. This service connects to your existing database.


服务端安装 Server Installation

您可以通过以下任一方式安装 tmate-api 服务端: You can install the tmate-api service using either of the following methods:

1. 使用 Docker Compose (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"

2. 使用 Docker run 命令快速部署 2. Using Docker Run Command

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

重要环境变量说明: Environment Variables Description:

注意: Note:


App 配置 App Configuration

安装完 App 后,在设置中填写以下信息: In the App Settings, fill in the following:

  1. 服务器地址: Server Address: http://IP:9999
  2. Token: 填入您设置的 API_KEY 的值。 Enter the value of your API_KEY.