Skip to content

Installing t6

mathcoll edited this page Dec 27, 2021 · 26 revisions

Install dependencies

t6 require the following packages running:

  • Influxdb - v1.8.x are known to be working fine.
  • Telegraf optional - v1.[18-19] are known to be working fine.
  • nodejs - the latest available version should be great
  • npm - the latest available version should be great
  • mosquitto - optional - v1.4.15 is known to be working fine.

Note that t6 is able to store Datapoints also to InfluxData Cloud Storage - so influxDb become optional in that context, but still strongly recommanded.

Once t6 is installed and running, please let us know you are using t6 on your server - author email can be found on package file. :-)

Install t6

Do not use sudo/root to install t6, this is not necessary, and so, not recommended.

$ git clone https://github.com/mathcoll/t6.git & cd ./t6
$ npm install

The following files (on ./data/ folder) are based on the environement, according to the server hostname :

✨ On linux, to identify your hostname, you can run the command hostname.

rename "settings-hostname.js" according to your server _hostname_ 
rename "sensors-hostname.js" according to your server _hostname_ - this file is optional and define some server sensors to send data to t6.
rename "*-hostname.js" according to your server _hostname_.

and edit the file settings-hostname.js following detailed settings.

t6 configuration

Please have a look at the options in settings-hostname.js

Mqtt settings

These settings refers to Mqtt configuration. Mqtt refers to Mosquitto installation and remain optional. The purpose of Mqtt on t6 is to publish events that can be consumed for multiple Objects/Devices. The feature is not activated on t6 Saas - but can be configured on Premise.

  • mqttHost: is the host IP or domain name to connect Mosquitto
  • mqttPort: is the port (unsigned integer), usually 1883
  • mqttRoot: is the default mosquitto topic root where messages should be published to
  • mqttInfo: is the relative (to root) where t6 is publishing it self messages

Session settings

All the settings related to server sessions:

  • secret: a keyboard-cat secret string that should remain secret to you only. :-)
  • sessionDuration: duration (seconds) of cookie persistence
  • store: configuration of the cookie storage
  • sessionSettings: configuration of the session
  • cookie: configuration of the cookie
  • staticOptions: duration (days) of static files persistence

JWT

All the settings related to server JsonWebToken:

  • expiresInSeconds: Jwt duration (seconds)
  • refreshExpiresInSeconds: Jwt refresh-token duration (seconds)
  • secret: a keyboard-cat secret string that should remain secret to you only. :-)
  • algorithms: a list of algorithms to be used in the jwt ciphering

Http settings

All the settings related to http(s) server:

  • timeoutDuration: server timeout duration - in seconds

Logs settings

  • logFormat: Output format of logs in the console/files. It can take the following values : "combined", "common", "dev", "combined", "tiny" or "short"
  • logLevel: The level of output log ; A string that contains all expected levels separated with a pipe (|) char. The values can be combined from the following: "WARNING|ERROR|LOG|INFO";
  • logAccessFile: Absolute or relative path to log file for Access
  • logErrorFile: Absolute or relative path to log file for Errors
  • logDateFormat: log date format using a momentjs syntax : e.g.: "DD/MMM/YYYY:H:mm:ss ZZ"
  • logAudit: Boolean to activate/disable the audit logs on events measurements

Email settings

t6 can send email to users, using the following parameters:

  • from: The default sender email address
  • bcc: The default BCC adress to receive New account in your Admin inbox
  • mailhost: Your Smtp server - e.g.: "smtp.domain.com.invalid"
  • mailauth: Your Smtp credentials
  • mailDKIMCertificate: The DKIM cetificate private file - absolute file is better and hopefully outside t6 directory
  • Note that Dkim might require additional transporter details that are details on the sample setting-hostname.js file.

Database settings - Storage

t6 is storing timeseries data to:

  • influxdb: Hopefully true as you want to store timeseries to local inflluxdb ; note this parameter remain optional and you can configure an external influxdata server for flexibility
  • telegraf: optionally true if you have setup a telegraf server
  • sqlite3: Should remain false as SQLite is deprecated

Quota settings

Quota is an object defining quantoties of each resources allowed to be set by users depending on their role. See the example on the sample file.

Localization settings

Localization is an object with only 2 attributes: latitude, and longitude. They are used on rule engine to calaculate dafault daylight on t6.

pushSubscription

  • gcmAPIKey: this is the GCM Api key provided by Google in order to send push notifications
  • vapidDetails: an object to customize the sender private+public keys as well as the subject (usually the sender email adress)
  • TTL: default Time To Live for notification sent

Trackings

IFTTT settings

🆘 💥 Please note Ifttt is on beta and not fully implemented.

  • apiUrl: t6 callback url
  • realtimeApi: an object containing default Ifttt api parameters
  • serviceKey: Your own Ifttt service Key provided by Ifttt
  • serviceClientId: Your own Ifttt service ClientId provided by Ifttt
  • serviceSecret: Your own Ifttt service Secret provided by Ifttt

OTA settings

  • build_dir: usually an absolute path where the Arduino file are being build before sent Over The Air
  • arduino_binary_cli: absolute path of the ̀arduino-cli executable
  • python3: absolute path of the ̀python3 executable
  • espota_py: absolute path of the ̀espota.py python file
  • config: absolute path of the ̀.arduino15/arduino-cli.yaml file
  • fqbn: default fqbn string
  • defaultPort: default Ota port number

Image processing

This section is defining an object with 2 attributes: image_dirand models_dir.

  • image_dir: The folder where images can be stored, must be writable by t6
  • models_dir: the folder containing the models

t6queue

:collision deprecated

  • db: absolute path to the queue database (a SQLite file)

custom units

  • db: absolute path to the custom units database

Data Fusion

  • activated: a boolean to activate or disable the fusion

Twilio

t6 as a startup service (Linux)

There are probably better way and more modern service implementation. Please share any alternative options.

Note: ✨ Any more elegant way to manage server enviroment is welcome. :-)

You can add the server running as a service, tested with Ubuntu and Debian:

  • First: edit the service config file for systemd and the install t6 as a service:
$ vi t6/etc/systemd/system/t6.service
$ sudo ln -s /var/www/t6/etc/systemd/system/t6.service /etc/systemd/system/
$ systemctl enable t6
  • Finally, start t6 using:
$ systemctl start t6

t6 timeseries settings

Once the setting are done, you can initialize the influxDb databases:

CREATE DATABASE "t6"
Then opt 1:
CREATE RETENTION POLICY "quota7d" on "t6" DURATION 7d REPLICATION 1 SHARD DURATION 1d

or opt 2:
CREATE RETENTION POLICY "quota4w" on "t6" DURATION 4w REPLICATION 1 SHARD DURATION 1d

You can also add some other usefull Retention Policies
CREATE RETENTION POLICY "retention1d" on "t6" DURATION 1d REPLICATION 1 SHARD DURATION 1h
CREATE RETENTION POLICY "retention1w" on "t6" DURATION 1w REPLICATION 1 SHARD DURATION 1d
CREATE RETENTION POLICY "retention4w" on "t6" DURATION 4w REPLICATION 1 SHARD DURATION 1d
CREATE RETENTION POLICY "retention1y" on "t6" DURATION 365d REPLICATION 1 SHARD DURATION 7d

Database will contains the following measurements:

  • data: All timeseries for measures;
  • events: events happening in t6 Api; not really used, except for few logs;
  • requests: Allows to manage quotas and limits; this is the one using the quota7d or quota4w retention policy. The appropriate setting must be set on the influxSettings.retentionPolicies enviroment variable.

t6 Troobleshooting after installation

Q: sudo /etc/init.d/t6 start does not return any output, what should I do?

A: deprecated question as the service should be now started using systemd. BTW, try to set chmod +x to file /var/www/t6/bin/www and then, have a look at log files. Please note "logLevel" should be "LOG|DEBUG|INFO|WARNING|ERROR" to turn on ALL debug mode.

Q: Do I need to install sqlite3?

A: Well, NO. Sqlite3 is deprecated. You can't use it anymore since b93fb1a449f19427dc82ba815368cb39ab43a429.