npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lx-gwbuilder

v1.0.2

Published

Submission tool for gWeather protocol weather data submission

Downloads

2

Readme

GW Builder - Weather Data Submission Tool

This package is purposed to submit weather data to a weather server using the gWeather protocol. It supports data sorting on a minutely basis and a few basic field types the weather data can stored into.

Usage

Installation

You can install the package in the usual way by running

> yarn add lx-gwbuilder

or

> npm i lx-gwbuilder

Make sure that needle is installed as project dependency.

Integration

First, create a builder instance:

const GwBuilder = require('lx-gwbuilder');

const builder = new GwBuilder(
	"<client-id>",
	"<client-secret>",
	"<host>", // Optional, defaults to "localhost"
	"<path>"  // Optional, defaults to "/gweather"
);

The builder now can be filled with sensor data and measurements. The following describes a general workflow:

builder.CreateSensor(builder.SensorType.Out, "My Outdoor Sensor")
	.AddMeasurement(builder.FieldType.Temperature,		12.0)	// 12.0°C
	.AddMeasurement(builder.FieldType.Humidity,			22  )	// 22%
	.AddMeasurement(builder.FieldType.WindSpeed,		 6.3)	// 6.3 km/h
	// Above defaults to sensor creation minute. 
	// Other identical fields will overwrite the value

	// Below inserts into the full minute at a given UNIX timestamp.
	// Different minute signatures will NOT overwrite each other.
	.AddMeasurement(builder.FieldType.Temperature,		-2.5, 1641819658)

Notice: Values should be unit normalized with the gWeather Protocol. See field reference for unit details

If the data injection is complete, the results can be submitted to the server by simply calling

builder.Submit()

Alternatively, you can submit or work with the data yourself by getting the serialized struct with builder.Serialize()

Class Reference

GwBuilder

Constructor

const builder = new GwBuilder(client_id, client_secret, host, path)

| Parameter | Description | |--|--| | client_id: string | The assigned client ID on the wather server | | client_secret: string | The assigned client secret on the weather server | | host: string | HTTPS weather server host name.Defaults to localhost | | path: string | HTTPS weather server path on given hostDefaults to /gweather |

Methods

| builder. | Params | Description | |--|--|--| | CreateSensor(...) | type: SensorTypename: stringreturns :GwSensor | Creates a new sensor The sensor variant typeDisplay Name of the sensorThe newly created sensor | | Serialize() | returns :object | Serializes the structure to regular JS object Serialized object | | Submit() | returns :Promise | Submits the struct to the provided serverResolves with the submission result |

Fields

| builder. | | Description | |--|--|--| | SensorType | .In | Indoor Sensor | | | .Out | Outdoor Sensor | | | .Water | Water Sensor | | FieldType | .Temperature | Unit: °C | | | .Light | Unit: LUX | | | .Humidity | Unit: % | | | .BarometerAbsolute | Unit: mb/hPa | | | .BarometerRelative | Unit: mb/hPa | | | .WindDirection | Unit: ° | | | .WindSpeed | Unit: km/h | | | .WindGust | Unit: km/h | | | .UV | Unit: UVi | | | .RainRate | Unit: mm | | | .RainRateDaily | Unit: mm | | | .SolarRadiation | Unit: W/m² | | | .SoilMoisture | Unit: % |

GwSensor

Methods

| sensor. | Params | Description | |--|--|--| | AddMeasurement(...) | field: FieldTypevalue: number* time: numberreturns :GwSensor | Inserts or updates new sensor information The field information typeNumeric value matching the field unit(Optional) Timestamp of the data set.The newly created sensor | | Serialize() | returns :object | Serializes the sensor to regular JS object Serialized object |

Dependencies