Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
node-sitewhere
Advanced tools
Readme
Library and inline docs in progress and subject to change...
const Sitewhere = require('node-sitewhere');
let config = {
url: 'http://localhost:8080/sitewhere/api',
username: 'admin',
password: 'password',
mqttServer: 'localhost',
mqttPort: '1883'
};
let sitewhere = new Sitewhere(config);
sitewhere.mqtt.connect()
.then(mqtt => mqtt.sendAlert('DEVICE001', 'Test', 'This is a test.'))
.catch(err => console.log(err.message));
sitewhere.http.getTenants()
.then(tenants => console.log(tenants))
.catch(err => console.log(err.message));
object
Creates an instance of Sitewhere class.
object
Acknowledge Object
object
Alert Object
object
Locaton Object
object
Measurements Object
object
Registration Object
object
Creates an instance of DeviceCommander class.
This utility class attempts to extend some of the basic API features of node-sitewhere to allow the creation, execution, and response acknowlegement of Sitewhere to Device to Sitewhere communications over MQTT.
object
Creates an instance of Sitewhere class.
Kind: global namespace
Param | Type | Description |
---|---|---|
config | Object | Configuration object containing Sitewhere config settings. |
object
object
Object
Object
Object
Promise.<mqtt>
Promise.<mqtt>
Promise.<mqtt>
Promise.<mqtt>
Promise.<mqtt>
Promise.<mqtt>
Promise.<mqtt>
Promise.<mqtt>
Promise.<mqtt>
Object
Promise.<EngineConfig>
Promise
Promise
Promise.<Array.Tenant>
Promise.<Tenant>
Promise.<Tenant>
Promise.<Tenant>
Promise.<Site>
Promise.<Zone>
Promise.<AssetCategory>
Promise.<HardwareAsset>
Promise.<PersonAsset>
Promise.<LocationAsset>
Promise.<Array.DeviceSpecification>
Promise.<DeviceSpec>
Promise.<Array.Device>
Promise.<Array.User>
Promise.<Array.Template>
object
Options Object
Kind: instance namespace of Sitewhere
Properties
Name | Type | Default | Description |
---|---|---|---|
url | string | "http://localhost:8080/sitewhere/api" | Sitewhere API URL |
username | string | "admin" | Sitewhere API Username |
password | string | "password" | Sitewhere API Password |
mqttServer | string | "localhost" | hostname/ip of MQTT Server (i.e 1.2.3.4 or mqtt.example.com) |
mqttPort | string | 1883 | Port for MQTT Server |
tenantAuthenticationToken | string | "sitewhere1234567890" | Tenant AuthenticationToken that defaults to the "default" tenant included with sitewhere install (optional) |
mqttPrefixTopic | string | "Sitewhere" | Default Topic Prefix that is used to construct mqttTopic, mqttCommandsTopicPrefix, mqttSystemTopicPrefix if not speficied in config (optional) |
mqttTopic | string | "mqttPrefixTopic+'/input/json'" | Default Sitewhere publish topic (optional) |
mqttCommandsTopicPrefix | string | "mqttPrefixTopic+'/commands/'" | Used to subscribe to device Sitewhere 'commands' topic (optional) |
mqttSystemTopicPrefix | string | "mqttPrefixTopic+'/system/'" | Used to subscribe to Sitewhere 'system' topic (optional) |
Object
Mqtt Object
Kind: static property of Sitewhere
Object
Object
Object
Promise.<mqtt>
Promise.<mqtt>
Promise.<mqtt>
Promise.<mqtt>
Promise.<mqtt>
Promise.<mqtt>
Promise.<mqtt>
Promise.<mqtt>
Promise.<mqtt>
Object
Sitewhere inbound Commands messages Emmitter
Kind: static property of mqtt
Object
Sitewhare inbound System messages Emmitter
Kind: static property of mqtt
Promise.<mqtt>
Disconnects mqtt client if connected.
Kind: static method of mqtt
Returns: Promise.<mqtt>
- Sitewhere.mqtt
Promise.<mqtt>
Publish message.
Kind: static method of mqtt
Returns: Promise.<mqtt>
- Sitewhere.mqtt
Param | Type | Default |
---|---|---|
message | String | |
[topic] | String | config.mqttTopic |
Promise.<mqtt>
Subscribe to MQTT topics for commands and system events by Hardware ID
Kind: static method of mqtt
Returns: Promise.<mqtt>
- Sitewhere.mqtt
Param | Type |
---|---|
hardwareId | String |
Promise.<mqtt>
Unsubscribe to MQTT topics for commands and system events by Hardware ID
Kind: static method of mqtt
Returns: Promise.<mqtt>
- Sitewhere.mqtt
Param | Type |
---|---|
hardwareId | String |
Promise.<mqtt>
Send MQTT Acknowledge to Sitewhere. Can also accept Acknowledge object as only argument.
Kind: static method of mqtt
Returns: Promise.<mqtt>
- Sitewhere.mqtt object
Param | Type | Description |
---|---|---|
hardwareId | String | Device Hardware ID |
originatingEventId | String | Originating Event ID that is being acknowledged |
response | String | Response message to send back to Sitewhere. |
Promise.<mqtt>
Send MQTT Alert to Sitewhere. Can also accept Alert object as only argument.
Kind: static method of mqtt
Returns: Promise.<mqtt>
- Sitewhere.mqtt object
Param | Type | Default | Description |
---|---|---|---|
hardwareId | String | Device Hardware ID | |
type | String | Alert type (short name) | |
message | String | Alert message | |
[level] | String | 'Info' | Alert level of content Info |
[metadata] | String | Alert metadata (optional) |
Promise.<mqtt>
Send MQTT Location to Sitewhere. Can also accept Location object as only argument.
Kind: static method of mqtt
Returns: Promise.<mqtt>
- Sitewhere.mqtt object
Param | Type | Default | Description |
---|---|---|---|
hardwareId | String | Device Hardware ID | |
latitude | String | Latitude | |
longitude | String | Longitude | |
[elevation] | String | '0' | Elevation (optional, defaults to '0') |
Promise.<mqtt>
Send MQTT Measuments to Sitewhere. Can also accept Measurements object as only argument.
Kind: static method of mqtt
Returns: Promise.<mqtt>
- Sitewhere.mqtt object
Param | Type | Description |
---|---|---|
hardwareId | String | Device Hardware ID |
measurements | Object | Object containing key / value pairs |
Promise.<mqtt>
Send MQTT Registration to Sitewhere. Can also accept Registration object as only argument.
Kind: static method of mqtt
Returns: Promise.<mqtt>
- Sitewhere.mqtt object
Param | Type | Description |
---|---|---|
hardwareId | String | Device Hardware ID |
specificationToken | String | Device Specification Token |
siteToken | String | Site Token for site under which device is created |
Object
Http Object
Kind: static property of Sitewhere
Object
Promise.<EngineConfig>
Promise
Promise
Promise.<Array.Tenant>
Promise.<Tenant>
Promise.<Tenant>
Promise.<Tenant>
Promise.<Site>
Promise.<Zone>
Promise.<AssetCategory>
Promise.<HardwareAsset>
Promise.<PersonAsset>
Promise.<LocationAsset>
Promise.<Array.DeviceSpecification>
Promise.<DeviceSpec>
Promise.<Array.Device>
Promise.<Array.User>
Promise.<Array.Template>
Promise.<EngineConfig>
Get engine config.
Kind: static method of http
Param | Type |
---|---|
enantId | String |
Promise
Start Tenant Engine.
Kind: static method of http
Param | Type |
---|---|
tenantId | String |
Promise
Stop Tenant Engine.
Kind: static method of http
Param | Type |
---|---|
tenantId | String |
Promise.<Array.Tenant>
Get Sitewhere Tenants.
Kind: static method of http
Returns: Promise.<Array.Tenant>
- Array of Tenant objects.
Promise.<Tenant>
Get Tenant.
Kind: static method of http
Param | Type |
---|---|
tenantId | String |
Promise.<Tenant>
Create Tenant.
Kind: static method of http
Param | Type |
---|---|
tenant | Tenant |
Promise.<Tenant>
Update Tenant.
Kind: static method of http
Param | Type |
---|---|
tenantid | String |
tenant | Tenant |
Promise.<Site>
Create Site.
Kind: static method of http
Param | Type |
---|---|
site | Site |
Promise.<Zone>
Create Zone.
Kind: static method of http
Param | Type |
---|---|
siteToken | string |
zone | Zone |
Promise.<AssetCategory>
Create AssetCategory.
Kind: static method of http
Param | Type |
---|---|
assetCategory | AssetCategory |
Promise.<HardwareAsset>
Create HardwareAsset.
Kind: static method of http
Param | Type |
---|---|
assetCategoryId | string |
hardwareAsset | HardwareAsset |
Promise.<PersonAsset>
Create PersonAsset.
Kind: static method of http
Param | Type |
---|---|
assetCategoryId | string |
personAsset | PersonAsset |
Promise.<LocationAsset>
Create LocationAsset.
Kind: static method of http
Param | Type |
---|---|
assetCategoryId | string |
locationAsset | LocationAsset |
Promise.<Array.DeviceSpecification>
Get Sitewhere Device Specifications.
Kind: static method of http
Returns: Promise.<Array.DeviceSpecification>
- Array of DeviceSpecification objects.
Promise.<DeviceSpec>
Create Device Spec.
Kind: static method of http
Param | Type |
---|---|
deviceSpec | DeviceSpec |
Promise.<Array.Device>
Get Sitewhere Devices.
Kind: static method of http
Returns: Promise.<Array.Device>
- Array of Device objects.
Promise.<Array.User>
Get Sitewhere Users.
Kind: static method of http
Returns: Promise.<Array.User>
- Array of User objects.
Promise.<Array.Template>
Get Sitewhere Templates.
Kind: static method of http
Returns: Promise.<Array.Template>
- Array of Template objects.
object
Acknowledge Object
Kind: global namespace
Properties
Name | Type |
---|---|
hardwareId | String |
type | String |
request | AcknowledgeRequest |
object
Alert Object
Kind: global namespace
Properties
Name | Type |
---|---|
hardwareId | String |
type | String |
request | AlertRequest |
object
Locaton Object
Kind: global namespace
Properties
Name | Type |
---|---|
hardwareId | String |
type | String |
request | LocationRequest |
object
Measurements Object
Kind: global namespace
Properties
Name | Type |
---|---|
hardwareId | String |
type | String |
request | MeasurementsRequest |
object
Registration Object
Kind: global namespace
Properties
Name | Type |
---|---|
hardwareId | String |
type | String |
request | RegistrationRequest |
object
Creates an instance of DeviceCommander class.
This utility class attempts to extend some of the basic API features of node-sitewhere to allow the creation, execution, and response acknowlegement of Sitewhere to Device to Sitewhere communications over MQTT.
Kind: global namespace
Param | Type | Description |
---|---|---|
sitewhere | Sitewhere | initialized sitewhere class instance |
hardwareId | String | hardware id of device to associate the command with. |
Promise
Register a function to a Sitewhere command by namespace and name.
Namespace and name must match a Sitewhere Device Spec command. In the Device Spec Commmand, an optional parameter "args" of type "String" may be defined. When executing the command from Sitewhere, the args string should be a comma seperated string of values. Each value will be passed to the function as individual "string" arguments. The function may return a value or a promise. The returned value/promise will display in sitehwere under "Command Responses". If the function does not produce a return value, or if the return value is not either of type object or type string, the "Command Response" will show "Auto acknowleged".
Note: You must set Tenant Configuration/Device Communication/Device Command Routing/Specification Mapping Router to use a default destination of "json" or create a new mapping for each Device Specification(s) that your devices are assigned to. This mapping should specify a "Destination ID" of "json".
Kind: static method of DeviceCommander
Param | Type | Default |
---|---|---|
[namespace] | String | 'Default' |
name | String | |
fn | function |
Example
const Sitewhere = require('node-sitewhere');
const DeviceCommander = require('node-sitewhere/device-commander');
let sitewhere = new Sitewhere();
let device001 = new DeviceCommander(sitewhere, 'DEVICE001');
device001.register('Add3', function(a, b, c) {
// sitewhere command would use namespace Default (or blank)
// sitewhere command would use name "Add3"
// sitewhere command would have string parameter "args"
// when executing the command args could be "5,4,3"
return a + b + c;
// sitewhere Command Response should should show 12.
});
object
Acknowledge Request Object
Kind: inner namespace
Properties
Name | Type |
---|---|
response | String |
originatingEventId | String |
updateState | String |
eventDate | String |
object
Alert Request Object
Kind: inner namespace
Properties
Name | Type |
---|---|
type | String |
level | String |
message | String |
updateState | String |
eventDate | String |
object
Locaton Request Object
Kind: inner namespace
Properties
Name | Type |
---|---|
latitude | String |
longitude | String |
elevation | String |
updateState | String |
eventDate | String |
object
Measurements Request Object
Kind: inner namespace
Properties
Name | Type |
---|---|
measurements | Object |
updateState | String |
eventDate | String |
object
Registration Request Object
Kind: inner namespace
Properties
Name | Type |
---|---|
hardwareId | String |
specificationToken | String |
siteToken | String |
The MIT License (MIT)
Copyright (c) 2016-2017
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
node-sitewhere
The npm package node-sitewhere receives a total of 0 weekly downloads. As such, node-sitewhere popularity was classified as not popular.
We found that node-sitewhere demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.