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

@greenapsis/greenetwork-attributes

v1.4.1

Published

Data types to greenetwork

Downloads

37

Readme

Greenetwork Atributtes

Javascript library to manipulate attributes in greenetwork.

Description

In greenetwork there are multiple types of attributes, each of one with differents validations and restrictions. This library helps to handle all of them.

The module can be used as a CommonJS and ES

Usage

Installing

npm i @greenapsis/greenetwork-attributes

Create attribute

To use a attribute and validate, create an instance of it

const { AttributeInteger, AttributeLevelState  } = require('@greenapsis/greenetwork-attributes')

try {
    const voltageSupply = new AttributeInteger(150)
    const level = new AttributeLevelState(0)
} catch (error) {
    //The value was invalid for one attribute
    console.log(error)
}

Attribute's value

The actual value can be read and changed

const {
    AttributeInteger,
    AttributeLevelState,
} = require('@greenapsis/greenetwork-attributes')

const voltageSupply = new AttributeInteger(150)

//get the actual value
console.log(voltageSupply.value)

//change value
voltageSupply.value = 170

//get the new value
console.log(voltageSupply.value)

Attributes names list

Get the list of valids attributes importing the default value of the module

CommonJS
const { attributesNames } = require('@greenapsis/greenetwork-attributes')

//Log the array list of the valid attributes
console.log(Attributes)
ES Modules
import Attributes = from '@greenapsis/greenetwork-attributes'

//Log the array list of the valid attributes
console.log(Attributes)

Validate attribute name

There are a function to check if an attribute name is valid

const { validAttribute } = require('@greenapsis/greenetwork-attributes')

const attributeName = 'AttributeInteger'

//Log the array list of the valid attributes
console.log(validAttribute(attributeName))
// true: valid ; false: invalid

Valid Atrributes types

Each function in greenetwork uses different attributes, check the function - attribute relationships to correctly use each of them

AttributeBinary

Attribute that representes the status of ON and OFF

Valid Values:

  • Integer: 0 - 1
  • String: ["ON", "OFF"]

AttributeBoolean

Attribute that stores a boolean value

Valid values:

  • Boolean: any boolean value

AttributeCommandArray

Attribute that contains an array of device's commands

Valid values:

  • Array: Array of commands

AttributeDateTime

Attribute that stores a date time type value

Valid values:

  • Date: Any Date Object

AttributeFloat

Attribute that stores an float number, this attribute can be integer

Valid values:

  • Number: any number

AttributeInteger

Attribute that stores an integer number, dont accept float values

Valid values:

  • Integer: any integer value

AttributeLevelState

Attribute that stores a level state data type

Valid values:

  • Level State Data Type : The level state has to be in the range: [0 - 3]

AttributeLocation

Attribute that stores a Location data type

Valid values:

  • The Location data type: The Location has to have the following structure
{
    longitude: number,
    latitude: number
}

AttributeParkingSlotOccupancyStatus

Attribute that stores a Occupancy Status data type

Valid values:

  • Occupancy Status data type: ['Closed', 'Vacant','Occupied','Partially Occupied','Forbidden Vehicle','Unknown']

The Ocuppancy list of the valids status is avaible in: AttributeParkingSlotOccupancyStatus.occupancyStatus

AttributeString

Attribute that stores a string value

Valid values:

  • String: any string value

AttributeStringDays

Attribute that stores a week days in string

Valid values:

  • String: list if valid days separate by commas 'Mon,Tue,Wed,Thu,Fri,Sat,Sun'

AttributeStringTime

Attribute that stores a time in string

Valid values:

  • String: with the format '00:00:00', with a valid 24 format hours