2.0.6 • Published 2 years ago

vantage-node v2.0.6

Weekly downloads
1
License
ISC
Repository
github
Last release
2 years ago

Vantage-Node

Get Data from Vantage Pro Weatherstation from Davis Instruments via telnet connection

This is not a normal NPM package at the moment, it is rather a finished program for docker

Installation

There are two options: Use the docker image, or the plain nodejs script

Nodejs Usage

  • Copy config.example.json to config.json and change your data
  • Create a MySQL / MariaDB Database with user
  • Install dependencies with npm i and compile project with npm run build
  • Start Programm with npm start

Docker Image

  • Download Docker image from Docker Hub (n404/vantage-node)
  • run docker run -p 3010:3010 --name vantage-node -e VANTAGE_URL=123.123.123.123 -e MYSQL_ENABLED=false n404/vantage-node

  • With Custom config.json file: docker run --rm -v $(pwd)/config.json:/config.json -p 3011:3011 n404/vantage-node The Table on the MYSQL Database will be automatically generated if it is not existed

Config

There are two options for the configuration parameter:

  1. a config.json file in the root directory of the project
  2. Configuration with environment variables (mostly for docker / kubernetes)

config.json

{
    "vantage": {
        "url": "192.168.178.xxx" //REQUIRED, default ""
    }, 
    "mysql": {
        "enabled": true | false, //required, default true
        "ip": "<database-Host>", //default "127.0.0.1"
        "database": "<database>", //default "weather"
        "username": "<databae-User>", //default "weather"
        "password": "<database-Password>" //default ""
    }, 
    "socket": {
        "enabled": true | false, //default true
        "port": 3011 //default 3010
    }, 
    "saveinterval": 60 //default 60, given in seconds
}

List of supported environment variables

Environment VariableDescriptionDefault ValueTypeRequired
VANTAGE_URLThe URL to the Vantage-Pro Telnet adapter""stringyes
VANTAGE_PORTThe Port to the Vantage-Pro telnet adapter22222numberno
MYSQL_ENABLEDIf MYSQL should be usedtruebooleanyes
MYSQL_IPThe MYSQL Host (IP or Hostname)127.0.0.1stringno
MYSQL_PORTThe Mysql Port3306numberno
MYSQL_DBThe MYSQL Database nameweatherstringno
MYSQL_USERNAMEThe MYSQL Database userweatherstringno
MYSQL_PASSWORDThe MYSQL database password""stringno
SOCKET_PORTThe Port the websocket-Server should listen on3010numberno
SOCKET_ENABLEDIf websocket should be enabledtruebooleanno
SAVE_INTERVALthe interval the data should be saved in the MYSQL Database60numberno

Websocket Usage

On the Websocket port there will be sent the packages as soo as they get received from the vantage-pro station. You can use these packages with any socket.io-client (web-client or nodejs-client for example). The Packages have the following structure:

{
    "barometer": 986.8407885386599,
    "dayrain": 0,
    "inhum": 26,
    "intemp": 22.722222222222225, 
    "outhum": 82, 
    "outtemp": 9.722222222222221, 
    "rainrate": 0,
    "winddir": 258, 
    "windspeed": 0
}

REST API

/test =>

{
	"code": 200,
	"message": "Test successful"
}

/healthcheck(used for internal docker checks):

if healthcheck is ok (HTTP Statuscode: 200):

{
    "message": "Packages are valid", 
    "code": 200, 
    "value": 1234 // timestamp of last Telnet package in MS
}

if healthcheck is not valid: (HTTP Statuscode: 500)

{
    "message": "Packages are outdated and invalid!",
    "code": 500, 
    "value": 1234 //timestamp of last Telnet package in MS
}

/lastdata:

Values are -1 if not set (for example after program restart) (like in barometer)

{
  "value": {
    "barometer": -1,
    "dayRain": 0,
    "inHumidity": 29,
    "outHumidity": 71,
    "outTemperature": 17.055555555555557,
    "inTemperature": 22.944444444444443,
    "rainRate": 0,
    "windDirection": 147,
    "windSpeedMax": 0,
    "windSpeed": 0
  },
  "message": "Last Dataset of Weatherstation",
  "code": 200
}

If your have any problems, fell free to create an issue to contact me

2.0.6

2 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.4

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.3.0

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago