This Eliona app for Glutz Devices allows the opening and closing of doors fitted with Glutz devices by enabling the data transfer between these devices and the Eliona environment.
The app needs environment variables and database tables for configuration. To edit the database tables the app provides its own API access.
To start and initialize an app in an Eliona environment, the app has to registered in Eliona. For this, an entry in the database table public.eliona_app
is necessary.
-
CONNECTION_STRING
: configures the Eliona database. Otherwise, the app can't be initialized and started (e.g.postgres://user:pass@localhost:5432/iot
). -
INIT_CONNECTION_STRING
: configures the Eliona database for app initialization like creating schema and tables (e.g.postgres://user:pass@localhost:5432/iot
). Default is content ofCONNECTION_STRING
. -
API_ENDPOINT
: configures the endpoint to access the Eliona API v2. Otherwise, the app can't be initialized and started. (e.g.http://api-v2:3000/v2
) -
API_TOKEN
: defines the secret to authenticate the app and access the API. -
API_SERVER_PORT
(optional): define the port the API server listens. The default value is Port3000
. -
LOG_LEVEL
(optional): defines the minimum level that should be logged. Not defined the default level isinfo
.
The app requires configuration data that remains in the database. In order to store the data, the app creates its own database schema glutz
during initialization. To modify and handle the configuration data the app provides an API access. Take a look at the API specification to see how the configuration tables should be used.
-
glutz.config
: contains the Glutz API endpoints. Each row contains the specification of one endpoint (i.e config id, username, password, polling interval etc.) -
glutz.spaces
: contains the mapping from each device (uniquely defined by its configuration-, project- and device- id) to an eliona asset. Each row contains the specification of one endpoint(i.e config id, username, password, polling interval etc.) The app collects and writes data separately for each configured project. The mapping is created automatically by the app.
Generation: to generate access method to database see Generation section below.
The Glutz app provides its own API to access configuration data and other functions. The full description of the API is defined in the openapi.yaml
OpenAPI definition file.
- API Reference shows details of the API
Generation: to generate api server stub see Generation section below.
The app creates necessary asset types and attributes during initialization. See eliona/asset-type-glutz_device.json for details.
Each Glutz device is automatically mapped to an asset with atrributes of the subtype Input
, Info
and Output
. The Glutz app writes input (e.g battery level, number of openings) and info (e.g building, room, openable) data for each Glutz device to the eliona database and reads output data (open) from Eliona.
For the API server the OpenAPI Generator for go-server is used to generate a server stub. The easiest way to generate the server files is to use one of the predefined generation scripts, which use the OpenAPI Generator Docker image.
.\generate-api-server.cmd # Windows
./generate-api-server.sh # Linux
For the database access SQLBoiler is used. The easiest way to generate the database files is to use one of the predefined generation scripts, which use the SQLBoiler implementation. Please note that the database connection in the sqlboiler.toml
file have to be configured.
.\generate-db.cmd # Windows
./generate-db.sh # Linux