Sign inSign up

eladbar/torque-api

By eladbar

•Updated almost 5 years ago

Image
2

3.8K

eladbar/torque-api repository overview

⁠Torque API to MQTT

Listens to events from Torque App and publishes to vairous output plugins

GitHub⁠ | Docker Hub⁠

⁠How to use

⁠Run docker container using the following Docker Compose
  torque-api:
    image: eladbar/torque-api:latest
    restart: unless-stopped
    hostname: torque-api
    container_name: torque-api
    ports:
      - 8128:8128
    volumes:
      - ./config/config.json:/usr/src/app/config.json
      - ./data:/data
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro

⁠Setup Tourqe App

In Settings -> Data Logging & Upload

Under the Logging Preferences header:

Touch Select what to log, activate the menu in the upper right, and select Add PID to log. Select items of interest.

Under the Realtime Web Upload header:

Check Upload to web-server.

  • Enter http://HOST:PORT/api/torque⁠ as the Web-server URL, where HOST and PORT are your externally accessible Torque API HTTP host and port.
  • Enter an email address in User Email Address (Same email address as in the devices.yaml)
  • Note that it is recommanded to use HTTP with Torque App
⁠Configuration

Configuration file should be available at /usr/src/app/config.json, example:

{
    "authentication": {
        "apiKey": "APIKEY",
        "devices": {
            "[email protected]": "Name of the Car"
        }
    },
    "output": {
        "influxdb": {
            "host": "127.0.0.1",
            "port": 8086,
            "protocol": "http",
            "bucket": "torque",
            "organization": "org",
            "token": "token",
            "measurement": "device"
        },
        "mqtt": {
            "host": "192.168.2.6",
            "port": 1883,
            "username": "mqtt",
            "password": "Windows",
            "clientId": "TorqueAPIDEV",
            "topic": "torque/device-dev/status"
        },
        "memory": {
            "maximumInMemory": 10000,
            "flushInterval": 60,
            "outputDirectory": "/data"
        }
    }
}
⁠Authentication Section

Represent configurations related to access the API, avoid configuring them will fail the load of the API

⁠API Key
{
    "authentication": {
        "apiKey": "APIKEY"
    }
}
⁠Devices

Key-value pairs of email as configured in the TorqueApp and the desired device name in the output plugins

{
    "authentication": {
        "devices": {
            "[email protected]": "Name of the Car"
        }
    }
}
⁠Output Section

Represents the output plugins configuration, avoid configuring a specific output plugin will disable it

⁠InfluxDB
KeyTypeDescription
hoststringhostname or IP of the InfluxDB server
portintegerport of the InfluxDB server
protocolstringprotocol to connect the InfluxDB server - http or https
bucketstringname of the bucket
organizationstringname of the organization
tokenstringaccess token with write permission to the relevant bucket
measurementstringname of the measurement
⁠MQTT
KeyTypeDescription
hoststringhostname or IP of the MQTT Broker
portintegerport of the MQTT Broker
usernamestringusername
passwordstringpassword
clientIdstringClient ID
topicstringtopic as will be published once event was sent
⁠Memory
KeyTypeDescription
maximumInMemoryintegerNumber of objects in memory
flushIntervalintegerInterval in second to flush to disk
outputDirectorystringpath to store the raw data and data

⁠Endpoints

EndpintMethodDescriptionAPI KeyDepends on output configuration
/GETReadme--
/api/torqueGETReport statistics (For Torque App)--
/api/torque/rawGETRaw event's data+memory
/api/torque/dataGETProcessed events+memory
/api/torque/sensorsGETList all available sensors+-
/api/debugGETGet debug mode+-
/api/debugPOSTSet debug mode+-
/api/debugDELETEStop debug mode+-

Tag summary

Content type

Image

Digest

Size

348.7 MB

Last updated

almost 5 years ago

docker pull eladbar/torque-api