# Modules
- Address
- Application
- Client
- Device
- Files
- Measurement
- OmaObject
- OmaResource
- OmaViews
- Scheduler
- SensorResource
- Sensor
- User
# External
- OmaObjects
Oma Object References.
- OmaResources
Oma Resources References.
# Address
Properties
Name | Type | Description |
---|---|---|
id | string | Database generated ID |
street | string | |
streetName | string | |
streetNumber | string | |
postalCode | number | |
city | string | |
coordinates | object | |
verified | boolean | |
public | boolean |
- Address
- static
- .verifyAddress(address) ⇒
Promise.<object>
- .search(filter) ⇒
Promise.<array>
- .geoLocate(filter) ⇒
Promise.<array>
- .verifyAddress(address) ⇒
- inner
- ~geoCode() ⇒
Promise.<object>
- ~onAfterSave(ctx) ⇒
Promise.<object>
- ~onBeforeRemote(ctx) ⇒
Promise.<object>
- "create" (ctx, user) ⇒
Promise.<function()>
- ["before find" (ctx)](#event_before find) ⇒
Promise.<function()>
- ~geoCode() ⇒
- static
# Address.verifyAddress(address) ⇒ Promise.<object>
Validate input address; get coordinates and update address instance
Kind: static method of Address
Returns: Promise.<object>
- address
Param | Type | Description |
---|---|---|
address | any | Instance address |
# Address.search(filter) ⇒ Promise.<array>
Search address by keyword
Kind: static method of Address
Returns: Promise.<array>
- addresses
Param | Type | Description |
---|---|---|
filter | object | Requested filter |
# Address.geoLocate(filter) ⇒ Promise.<array>
Search addresses by location ( GPS coordinates )
Kind: static method of Address
Returns: Promise.<array>
- addresses
Param | Type | Description |
---|---|---|
filter | object | Requested filter |
# Address~geoCode() ⇒ Promise.<object>
Promise wrapper to verify address
Kind: inner method of Address
# Address~onAfterSave(ctx) ⇒ Promise.<object>
Validate input address; get coordinates and update address instance
Kind: inner method of Address
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
# Address~onBeforeRemote(ctx) ⇒ Promise.<object>
Hook executed before every remote methods
Kind: inner method of Address
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
# "create" (ctx, user) ⇒ Promise.<function()>
Event reporting that a new user instance has been created.
Kind: event emitted by Address
Returns: Promise.<function()>
- onAfterSave
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
user | object | User new instance |
# "before find" (ctx) ⇒ Promise.<function()>
Event reporting that an address instance / collection is requested
Kind: event emitted by Address
Returns: Promise.<function()>
- onBeforeRemote
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
# Application
Properties
Name | Type | Description |
---|---|---|
id | String | Database generated ID. |
name | String | Unique name defined by user required. |
description | String | Define Application purpose. |
collaborators | Array | A list of users ids who have permissions to use this application |
clients | Array | A list of client ids authentified as this application |
- Application
- static
- .publish(application, method, [client]) ⇒
Promise.<(object|null)>
- .refreshToken(appId, ownerId) ⇒
Promise.<object>
- .onPublish(packet, client, pattern) ⇒
Promise.<function()>
- .updateStatus(client, status) ⇒
Promise.<object>
- .authenticate(applicationId, key) ⇒
Promise.<object>
- .getState(applicationId) ⇒
Promise.<object>
- .find(filter) ⇒
Promise.<object>
- .count(where) ⇒
Promise.<number>
- .findById(id, filter) ⇒
Promise.<object>
- .create(application) ⇒
Promise.<object>
- .updateById(id, filter) ⇒
Promise.<object>
- .deleteById(id, filter) ⇒
Promise.<object>
- .publish(application, method, [client]) ⇒
- inner
- ~detector(packet, client) ⇒
Promise.<(object|null)>
- ~onBeforeSave(ctx) ⇒
Promise.<object>
- ~createKeys(application) ⇒
Promise.<object>
- ~createProps(app, instance) ⇒
Promise.<function()>
- ~updateProps(app, instance) ⇒
Promise.<function()>
- ~onAfterSave(ctx) ⇒
Promise.<object>
- ~deleteProps(app, instance) ⇒
Promise.<function()>
- ~onBeforeDelete(ctx) ⇒
Promise.<object>
- ~onBeforeRemote(app, ctx) ⇒
Promise.<object>
- ~parseMessage(app, packet, pattern, client)
- "client" (message) ⇒
Promise.<(function()|null)>
- "publish" (message) ⇒
Promise.<(function()|null)>
- "stopped"
- "before_save" (ctx) ⇒
Promise.<function()>
- "after_save" (ctx) ⇒
Promise.<function()>
- "before_delete" (ctx) ⇒
Promise.<function()>
- "before_*" (ctx) ⇒
Promise.<function()>
- ~detector(packet, client) ⇒
- static
# Application.publish(application, method, [client]) ⇒ Promise.<(object|null)>
Format packet and send it via MQTT broker
Kind: static method of Application
Returns: Promise.<(object|null)>
- application
Emits: Server.event:publish
Param | Type | Description |
---|---|---|
application | object | Application instance |
method | string | Publish method |
[client] | object | MQTT client target |
# Application.refreshToken(appId, ownerId) ⇒ Promise.<object>
Create new keys, and update Application instance
Kind: static method of Application
Returns: Promise.<object>
- application
Param | Type | Description |
---|---|---|
appId | string | Application instance id |
ownerId | string | Application owner id |
# Application.onPublish(packet, client, pattern) ⇒ Promise.<function()>
Dispatch incoming MQTT packet
Kind: static method of Application
Returns: Promise.<function()>
- Application~parseMessage
Param | Type | Description |
---|---|---|
packet | object | MQTT bridge packet |
client | object | MQTT client |
pattern | object | Pattern detected by Iot-Agent |
# Application.updateStatus(client, status) ⇒ Promise.<object>
Update application status from MQTT conection status
Kind: static method of Application
Returns: Promise.<object>
- application
Param | Type | Description |
---|---|---|
client | object | MQTT client |
status | boolean | MQTT connection status |
# Application.authenticate(applicationId, key) ⇒ Promise.<object>
Endpoint for application authentification with APIKey
Kind: static method of Application
Returns: Promise.<object>
- matched The matching application and key; one of:
- clientKey
- apiKey
- javaScriptKey
- restApiKey
- windowsKey
- masterKey
Param | Type |
---|---|
applicationId | any |
key | string |
# Application.getState(applicationId) ⇒ Promise.<object>
Endpoint to get resources attached to an application
Kind: static method of Application
Returns: Promise.<object>
- application
Param | Type |
---|---|
applicationId | string |
# Application.find(filter) ⇒ Promise.<object>
Find applications
Kind: static method of Application
Param | Type |
---|---|
filter | object |
# Application.count(where) ⇒ Promise.<number>
Returns applications length
Kind: static method of Application
Param | Type |
---|---|
where | object |
# Application.findById(id, filter) ⇒ Promise.<object>
Find application by id
Kind: static method of Application
Param | Type |
---|---|
id | any |
filter | object |
# Application.create(application) ⇒ Promise.<object>
Create application
Kind: static method of Application
Param | Type |
---|---|
application | object |
# Application.updateById(id, filter) ⇒ Promise.<object>
Update application by id
Kind: static method of Application
Param | Type |
---|---|
id | any |
filter | object |
# Application.deleteById(id, filter) ⇒ Promise.<object>
Delete application by id
Kind: static method of Application
Param | Type |
---|---|
id | any |
filter | object |
# Application~detector(packet, client) ⇒ Promise.<(object|null)>
Detect application known pattern and load the application instance
Kind: inner method of Application
Returns: Promise.<(object|null)>
- pattern
Param | Type | Description |
---|---|---|
packet | object | MQTT packet |
client | object | MQTT client |
# Application~onBeforeSave(ctx) ⇒ Promise.<object>
Validate instance before creation
Kind: inner method of Application
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
# Application~createKeys(application) ⇒ Promise.<object>
Keys creation helper - update application attributes
Kind: inner method of Application
Returns: Promise.<object>
- application
Param | Type | Description |
---|---|---|
application | object | Application instance |
# Application~createProps(app, instance) ⇒ Promise.<function()>
Init application dependencies ( token )
Kind: inner method of Application
Returns: Promise.<function()>
- Application.publish
Param | Type | Description |
---|---|---|
app | object | Loopback app |
instance | object | Application instance |
# Application~updateProps(app, instance) ⇒ Promise.<function()>
Update application depencies
Kind: inner method of Application
Returns: Promise.<function()>
- Application.publish
Param | Type | Description |
---|---|---|
app | object | Loopback app |
instance | object | Application instance |
# Application~onAfterSave(ctx) ⇒ Promise.<object>
Create relations on instance creation
Kind: inner method of Application
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
# Application~deleteProps(app, instance) ⇒ Promise.<function()>
Remove application dependencies
Kind: inner method of Application
Returns: Promise.<function()>
- Application.publish
Param | Type | Description |
---|---|---|
app | object | Loopback app |
instance | object |
# Application~onBeforeDelete(ctx) ⇒ Promise.<object>
Delete relations on instance(s) deletetion
Kind: inner method of Application
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
# Application~onBeforeRemote(app, ctx) ⇒ Promise.<object>
Called when a remote method tries to access Application Model / instance
Kind: inner method of Application
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
app | object | Loopback App |
ctx | object | Express context |
ctx.req | object | Request |
ctx.res | object | Response |
# Application~parseMessage(app, packet, pattern, client)
Find properties and dispatch to the right function
Adding device and sensor context to raw incoming data
Kind: inner method of Application
Emits: Device.event:publish
, Sensor.event:publish
Param | Type | Description |
---|---|---|
app | object | Loopback app |
packet | object | MQTT packet |
pattern | object | Pattern detected by IotAgent |
client | object | MQTT client |
# "client" (message) ⇒ Promise.<(function()|null)>
Event reporting that an application client connection status has changed.
Kind: event emitted by Application
Returns: Promise.<(function()|null)>
- Application.updateStatus
Param | Type | Description |
---|---|---|
message | object | Parsed MQTT message. |
Properties
Name | Type | Description |
---|---|---|
message.client | object | MQTT client |
message.status | boolean | MQTT client status. |
# "publish" (message) ⇒ Promise.<(function()|null)>
Event reporting that an application client sent a message.
Kind: event emitted by Application
Returns: Promise.<(function()|null)>
- Application.onPublish
Param | Type | Description |
---|---|---|
message | object | Parsed MQTT message. |
Properties
Name | Type | Description |
---|---|---|
message.packet | object | MQTT packet. |
message.pattern | object | Pattern detected |
message.client | object | MQTT client |
# "stopped"
Event reporting that application stopped
Trigger Application stopping routine
Kind: event emitted by Application
# "before_save" (ctx) ⇒ Promise.<function()>
Event reporting that an application instance will be created or updated.
Kind: event emitted by Application
Returns: Promise.<function()>
- Application~onBeforeSave
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
ctx.instance | object | Application instance |
# "after_save" (ctx) ⇒ Promise.<function()>
Event reporting that a device instance has been created or updated.
Kind: event emitted by Application
Returns: Promise.<function()>
- Application~onAfterSave
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
ctx.instance | object | Application instance |
# "before_delete" (ctx) ⇒ Promise.<function()>
Event reporting that an application instance will be deleted.
Kind: event emitted by Application
Returns: Promise.<function()>
- Application~onBeforeDelete
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
ctx.where.id | object | Application instance |
# "before_*" (ctx) ⇒ Promise.<function()>
Event reporting that an Application instance / collection is requested
Kind: event emitted by Application
Returns: Promise.<function()>
- Application~onBeforeRemote
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
# Client
Properties
Name | Type | Description |
---|---|---|
id | string | Client ID |
ip | string | Client IP |
user | string | Username attribute ( once client authenthified ) |
status | boolean | Client status |
model | string | Aloes model ( Application, Device, ... ) |
[type] | string | Client type ( MQTT, WS , ... ) |
[devEui] | string | device DevEui |
[appEui] | string | application AppEui |
- Client
- static
- .find(filter) ⇒
Promise.<Array.<object>>
- .remove(filter) ⇒
Promise.<Array.<string>>
- .get(key, [cb]) ⇒
Promise.<(object|null)>
- .set(key, value, [ttl], [cb]) ⇒
Promise.<undefined>
- .delete(key, [cb]) ⇒
Promise.<undefined>
- .expire(key, [ttl], [cb]) ⇒
Promise.<undefined>
- .keys([filter], [cb]) ⇒
Promise.<Array.<string>>
- .iterateKeys([filter]) ⇒
AsyncIterator
- .find(filter) ⇒
- inner
- ~onBeforeRemote(ctx, [Model]) ⇒
Promise.<object>
- ~getAll(Model, [filter]) ⇒
Promise.<Array.<object>>
- ~deleteAll(Model, [filter]) ⇒
Promise.<Array.<string>>
- "before_*" (ctx) ⇒
function
- "stopped"
- ~errorCallback :
function
- ~resultCallback :
function
- ~onBeforeRemote(ctx, [Model]) ⇒
- static
# Client.find(filter) ⇒ Promise.<Array.<object>>
Find clients in the cache
Kind: static method of Client
Returns: Promise.<Array.<object>>
- clients
Param | Type | Description |
---|---|---|
filter | object | Client filter |
# Client.remove(filter) ⇒ Promise.<Array.<string>>
Find clients in the cache
Kind: static method of Client
Returns: Promise.<Array.<string>>
- clients keys
Param | Type | Description |
---|---|---|
filter | object | Client filter |
# Client.get(key, [cb]) ⇒ Promise.<(object|null)>
Get client by key
Use callback or promise
Kind: static method of Client
Promise: result
Param | Type | Description |
---|---|---|
key | string | |
[cb] | resultCallback | Optional callback |
# Client.set(key, value, [ttl], [cb]) ⇒ Promise.<undefined>
Set client by key, with optional TTL
Use callback or promise
Kind: static method of Client
Promise: undefined
Param | Type | Description |
---|---|---|
key | string | |
value | string | |
[ttl] | number | |
[cb] | errorCallback | Optional callback |
# Client.delete(key, [cb]) ⇒ Promise.<undefined>
Delete Client by key
Use callback or promise
Kind: static method of Client
Promise: undefined
Param | Type | Description |
---|---|---|
key | string | |
[cb] | errorCallback | Optional callback |
# Client.expire(key, [ttl], [cb]) ⇒ Promise.<undefined>
Set the TTL (time to live) in ms (milliseconds) for a given key
Use callback or promise
Kind: static method of Client
Promise: undefined
Param | Type | Description |
---|---|---|
key | string | |
[ttl] | number | |
[cb] | errorCallback | Optional callback |
# Client.keys([filter], [cb]) ⇒ Promise.<Array.<string>>
Get all client keys
Use callback or promise
Kind: static method of Client
Param | Type | Description |
---|---|---|
[filter] | object | |
filter.match | object | Glob string used to filter returned keys (i.e. userid.*) |
[cb] | function |
# Client.iterateKeys([filter]) ⇒ AsyncIterator
Iterate over all client keys
Use callback or promise
Kind: static method of Client
Returns: AsyncIterator
- An Object implementing next(cb) -> Promise function that can be used to iterate all keys.
Param | Type | Description |
---|---|---|
[filter] | object | |
filter.match | object | Glob string used to filter returned keys (i.e. userid.*) |
# Client~onBeforeRemote(ctx, [Model]) ⇒ Promise.<object>
Called when a remote method tries to access Client Model / instance
Kind: inner method of Client
Returns: Promise.<object>
- context
Param | Type | Description |
---|---|---|
ctx | object | Express context |
[Model] | object | Response |
# Client~getAll(Model, [filter]) ⇒ Promise.<Array.<object>>
Find clients in the cache
Kind: inner method of Client
Returns: Promise.<Array.<object>>
- clients
Param | Type | Description |
---|---|---|
Model | object | Client model |
[filter] | object | Client filter |
# Client~deleteAll(Model, [filter]) ⇒ Promise.<Array.<string>>
Delete clients stored in cache
Kind: inner method of Client
Returns: Promise.<Array.<string>>
- clients keys
Param | Type | Description |
---|---|---|
Model | object | Client model |
[filter] | object | Client filter |
# "before_*" (ctx) ⇒ function
Event reporting that a Client method is requested
Kind: event emitted by Client
Returns: function
- Client~onBeforeRemote
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
# "stopped"
Event reporting that application stopped
Trigger Client stopping routine
Kind: event emitted by Client
# Client~errorCallback : function
Optional error callback
Kind: inner typedef of Client
Param | Type |
---|---|
ErrorObject | error |
# Client~resultCallback : function
Optional result callback
Kind: inner typedef of Client
Param | Type |
---|---|
ErrorObject | error |
result | string |
# Device
Properties
Name | Type | Description |
---|---|---|
id | String | Database generated ID. |
name | String | Unique name defined by user required. |
description | String | Define device purpose. |
devEui | String | hardware generated Device Id required. |
devAddr | String | randomly generated non unique Device Id required. |
apiKey | String | key to access Aloes as client. |
clientKey | String | key to access Aloes as client. |
lastSignal | Date | |
frameCounter | Number | Number of messages since last connection |
type | String | Device type ( /initial-data/device-types.json ) |
icons | Array | automatically set based on device type |
accessPointUrl | String | |
qrCode | String | Filled URL containing device access point |
transportProtocol | String | Framework used for message transportation |
transportProtocolVersion | String | Framework version |
messageProtocol | String | Framework used for message encoding |
messageProtocolVersion | String | Framework version |
collaborators | Array | A list of users ids who have permissions to use this device |
clients | Array | A list of client ids authentified as this device |
applications | Array | A list of application ids who have rights to listen device events |
ownerId | String | User ID of the user who has registered the device. |
- Device
- instance
- .__get__sensors() ⇒
Promise.<Array.<object>>
- .__findById__sensors(id) ⇒
Promise.<object>
- .__get__sensors() ⇒
- static
- .publish(device, method, [client]) ⇒
Promise.<(object|null)>
- .refreshToken(deviceId, ownerId) ⇒
Promise.<object>
- .findByPattern(pattern, attributes) ⇒
Promise.<object>
- .search(filter) ⇒
Promise.<array>
- .geoLocate(filter) ⇒
Promise.<array>
- .export(devices, [format]) ⇒
Promise.<(string|null)>
- .updateStatus(client, status) ⇒
Promise.<function()>
- .onPublish(packet, pattern, client) ⇒
Promise.<function()>
- .authenticate(deviceId, key) ⇒
Promise.<object>
- .getState(deviceId) ⇒
Promise.<object>
- .getFullState(deviceId) ⇒
Promise.<object>
- .getOTAUpdate(ctx, deviceId, [version]) ⇒
Promise.<function()>
- .find(filter) ⇒
Promise.<Array.<object>>
- .count(where) ⇒
Promise.<object>
- .findById(id, filter) ⇒
Promise.<object>
- .create(device) ⇒
Promise.<(object|Array.<object>)>
- .updateById(id, filter) ⇒
Promise.<object>
- .deleteById(id, filter) ⇒
Promise.<object>
- .publish(device, method, [client]) ⇒
- inner
- ~detector(packet, client) ⇒
object
|null
- ~transportProtocolValidator(err)
- ~messageProtocolValidator(err)
- ~typeValidator(err)
- ~setDeviceIcons(device) ⇒
object
- ~createKeys(device) ⇒
Promise.<object>
- ~setDeviceQRCode(device) ⇒
object
- ~publishToDeviceApplications(app, device, packet)
- ~onBeforeSave(ctx) ⇒
Promise.<object>
- ~createProps(app, instance) ⇒
Promise.<function()>
- ~updateProps(app, instance) ⇒
Promise.<function()>
- ~onAfterSave(ctx) ⇒
Promise.<object>
- ~deleteProps(app, instance) ⇒
Promise.<boolean>
- ~onBeforeDelete(ctx) ⇒
Promise.<object>
- ~onBeforeRemote(app, ctx) ⇒
Promise.<object>
- ~parseMessage(app, packet, pattern, client) ⇒
Promise.<object>
- ~patternDetector(packet, client) ⇒
object
|null
- "client" (message) ⇒
Promise.<(function()|null)>
- "publish" (message) ⇒
Promise.<(functions|null)>
- "stopped"
- "before_save" (ctx) ⇒
Promise.<function()>
- "after_save" (ctx) ⇒
Promise.<function()>
- "before_delete" (ctx) ⇒
Promise.<function()>
- "before_*" (ctx) ⇒
Promise.<function()>
- ~errorCallback :
function
- ~detector(packet, client) ⇒
- instance
# device.__get__sensors() ⇒ Promise.<Array.<object>>
Get device sensors
Kind: instance method of Device
# device.__findById__sensors(id) ⇒ Promise.<object>
Get device sensor by id
Kind: instance method of Device
Param | Type |
---|---|
id | string |
# Device.publish(device, method, [client]) ⇒ Promise.<(object|null)>
Format packet and send it via MQTT broker
Kind: static method of Device
Returns: Promise.<(object|null)>
- device
Emits: Server.event:publish
Param | Type | Description |
---|---|---|
device | object | Device instance |
method | string | MQTT method |
[client] | object | MQTT client target |
# Device.refreshToken(deviceId, ownerId) ⇒ Promise.<object>
Create new keys, and update Device instance
Kind: static method of Device
Returns: Promise.<object>
- device
Param | Type | Description |
---|---|---|
deviceId | object | Device instance id |
ownerId | object | Device owner id |
# Device.findByPattern(pattern, attributes) ⇒ Promise.<object>
Find device and / or sensor related to incoming MQTT packet
Kind: static method of Device
Returns: Promise.<object>
- device
Param | Type | Description |
---|---|---|
pattern | object | IotAgent parsed pattern |
attributes | object | IotAgent parsed message |
# Device.search(filter) ⇒ Promise.<array>
Search device by keywords ( name, address, type )
Kind: static method of Device
Returns: Promise.<array>
- devices
Param | Type | Description |
---|---|---|
filter | object | Requested filter |
# Device.geoLocate(filter) ⇒ Promise.<array>
Search devices by location ( GPS coordinates )
Kind: static method of Device
Returns: Promise.<array>
- devices
Param | Type | Description |
---|---|---|
filter | object | Requested filter |
# Device.export(devices, [format]) ⇒ Promise.<(string|null)>
Export devices list from JSON to {format}
Kind: static method of Device
Param | Type |
---|---|
devices | array |
[format] | string |
# Device.updateStatus(client, status) ⇒ Promise.<function()>
Update device status from MQTT connection status
Kind: static method of Device
Returns: Promise.<function()>
- device.updateAttributes
Param | Type | Description |
---|---|---|
client | object | MQTT client |
status | boolean | MQTT connection status |
# Device.onPublish(packet, pattern, client) ⇒ Promise.<function()>
Dispatch incoming MQTT packet
Kind: static method of Device
Returns: Promise.<function()>
- Device~parseMessage
Param | Type | Description |
---|---|---|
packet | object | MQTT bridge packet |
pattern | object | Pattern detected by Iot-Agent |
client | object | MQTT client |
# Device.authenticate(deviceId, key) ⇒ Promise.<object>
Endpoint for device authentification with APIKey
Kind: static method of Device
Returns: Promise.<object>
- matched The matching device and key; one of:
- clientKey
- apiKey
- javaScriptKey
- restApiKey
- windowsKey
- masterKey
Param | Type |
---|---|
deviceId | any |
key | string |
# Device.getState(deviceId) ⇒ Promise.<object>
Endpoint for device requesting their own state ( small memory )
Kind: static method of Device
Returns: Promise.<object>
- device
Param | Type | Description |
---|---|---|
deviceId | string | Device instance id |
# Device.getFullState(deviceId) ⇒ Promise.<object>
Endpoint for device requesting their own state, including relations
Kind: static method of Device
Returns: Promise.<object>
- device
Param | Type | Description |
---|---|---|
deviceId | string | Device instance id |
# Device.getOTAUpdate(ctx, deviceId, [version]) ⇒ Promise.<function()>
Update OTA if a firmware is available
Kind: static method of Device
Returns: Promise.<function()>
- Device~updateFirmware
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
deviceId | string | Device instance id |
[version] | string | Firmware version requested |
# Device.find(filter) ⇒ Promise.<Array.<object>>
Find devices
Kind: static method of Device
Param | Type |
---|---|
filter | object |
# Device.count(where) ⇒ Promise.<object>
Returns devices length
Kind: static method of Device
Param | Type |
---|---|
where | object |
# Device.findById(id, filter) ⇒ Promise.<object>
Find device by id
Kind: static method of Device
Param | Type |
---|---|
id | any |
filter | object |
# Device.create(device) ⇒ Promise.<(object|Array.<object>)>
Create device
Kind: static method of Device
Param | Type |
---|---|
device | object |
# Device.updateById(id, filter) ⇒ Promise.<object>
Update device by id
Kind: static method of Device
Param | Type |
---|---|
id | any |
filter | object |
# Device.deleteById(id, filter) ⇒ Promise.<object>
Delete device by id
Kind: static method of Device
Param | Type |
---|---|
id | any |
filter | object |
# Device~detector(packet, client) ⇒ object
| null
Detect device known pattern and load the application instance
Kind: inner method of Device
Returns: object
| null
- pattern
Param | Type | Description |
---|---|---|
packet | object | MQTT packet |
client | object | MQTT client |
# Device~transportProtocolValidator(err)
Validate device transportProtocol before saving instance
Kind: inner method of Device
Param | Type |
---|---|
err | ErrorCallback |
# Device~messageProtocolValidator(err)
Validate device messageProtocol before saving instance
Kind: inner method of Device
Param | Type |
---|---|
err | ErrorCallback |
# Device~typeValidator(err)
Validate device type before saving instance
Kind: inner method of Device
Param | Type |
---|---|
err | ErrorCallback |
# Device~setDeviceIcons(device) ⇒ object
Set device icons ( urls ) based on its type
Kind: inner method of Device
Returns: object
- device
Param | Type | Description |
---|---|---|
device | object | Device instance |
# Device~createKeys(device) ⇒ Promise.<object>
Keys creation helper - update device attributes
Kind: inner method of Device
Returns: Promise.<object>
- device
Param | Type | Description |
---|---|---|
device | object | Device instance |
# Device~setDeviceQRCode(device) ⇒ object
Set device QRcode access based on declared protocol and access point url
Kind: inner method of Device
Returns: object
- device
Param | Type | Description |
---|---|---|
device | object | Device instance |
# Device~publishToDeviceApplications(app, device, packet)
Check if a Device instance is attached to any Application instance
Publish message to each of these Application instance
Kind: inner method of Device
Emits: Server.event:publish
Param | Type | Description |
---|---|---|
app | object | Loopback app |
device | object | Device instance |
packet | object | MQTT packet to send |
# Device~onBeforeSave(ctx) ⇒ Promise.<object>
Validate instance before creation
Kind: inner method of Device
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
# Device~createProps(app, instance) ⇒ Promise.<function()>
Init device dependencies ( token, address )
Kind: inner method of Device
Returns: Promise.<function()>
- Device.publish
Param | Type | Description |
---|---|---|
app | object | Loopback app |
instance | object | Device instance |
# Device~updateProps(app, instance) ⇒ Promise.<function()>
Update device depencies ( token, sensors )
Kind: inner method of Device
Returns: Promise.<function()>
- Device.publish
Param | Type | Description |
---|---|---|
app | object | Loopback app |
instance | object | Device instance |
# Device~onAfterSave(ctx) ⇒ Promise.<object>
Create relations on instance creation
Kind: inner method of Device
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
# Device~deleteProps(app, instance) ⇒ Promise.<boolean>
Remove device dependencies
Kind: inner method of Device
Param | Type | Description |
---|---|---|
app | object | Loopback app |
instance | object |
# Device~onBeforeDelete(ctx) ⇒ Promise.<object>
Delete relations on instance(s) deletetion
Kind: inner method of Device
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
# Device~onBeforeRemote(app, ctx) ⇒ Promise.<object>
Called when a remote method tries to access Device Model / instance
Kind: inner method of Device
Returns: Promise.<object>
- context
Param | Type | Description |
---|---|---|
app | object | Loopback App |
ctx | object | Express context |
ctx.req | object | Request |
ctx.res | object | Response |
# Device~parseMessage(app, packet, pattern, client) ⇒ Promise.<object>
Find properties and dispatch to the right function
Adding device and sensor context to raw incoming data
Kind: inner method of Device
Returns: Promise.<object>
- device
Emits: Device.event:publish
, Sensor.event:publish
Param | Type | Description |
---|---|---|
app | object | Loopback app |
packet | object | MQTT packet |
pattern | object | Pattern detected by IotAgent |
client | object | MQTT client |
# Device~patternDetector(packet, client) ⇒ object
| null
Detect device known pattern and load the application instance
Kind: inner method of Device
Returns: object
| null
- pattern
Param | Type | Description |
---|---|---|
packet | object | MQTT packet |
client | object | MQTT client |
# "client" (message) ⇒ Promise.<(function()|null)>
Event reporting that an device client connection status has changed.
Kind: event emitted by Device
Returns: Promise.<(function()|null)>
- Device.updateStatus
Param | Type | Description |
---|---|---|
message | object | Parsed MQTT message. |
Properties
Name | Type | Description |
---|---|---|
message.client | object | MQTT client |
message.status | boolean | MQTT client status. |
# "publish" (message) ⇒ Promise.<(functions|null)>
Event reporting that a device client sent a message.
Kind: event emitted by Device
Returns: Promise.<(functions|null)>
- Device.onPublish | Device.execute
Param | Type | Description |
---|---|---|
message | object | Parsed MQTT message. |
Properties
Name | Type | Description |
---|---|---|
message.packet | object | MQTT packet. |
message.pattern | object | Pattern detected by Iot-Agent |
message.device | object | Found Device instance |
[message.client] | object | MQTT client |
# "stopped"
Event reporting that application stopped
Trigger Device stopping routine
Kind: event emitted by Device
# "before_save" (ctx) ⇒ Promise.<function()>
Event reporting that a device instance will be created or updated.
Kind: event emitted by Device
Returns: Promise.<function()>
- Device~onBeforeSave
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
ctx.instance | object | Device instance |
# "after_save" (ctx) ⇒ Promise.<function()>
Event reporting that a device instance has been created or updated.
Kind: event emitted by Device
Returns: Promise.<function()>
- Device~onAfterSave
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
ctx.instance | object | Device instance |
# "before_delete" (ctx) ⇒ Promise.<function()>
Event reporting that one or several device instance(s) will be deleted.
Kind: event emitted by Device
Returns: Promise.<function()>
- Device~onBeforeDelete
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
ctx.where.id | object | Device instance |
# "before_*" (ctx) ⇒ Promise.<function()>
Event reporting that a Device instance / collection is requested
Kind: event emitted by Device
Returns: Promise.<function()>
- Device~onBeforeRemote
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
# Device~errorCallback : function
Error callback
Kind: inner typedef of Device
Param | Type |
---|---|
ErrorObject | error |
# Files
Properties
Name | Type | Description |
---|---|---|
id | string | Database generated ID |
name | string | |
type | string | |
size | string | |
role | string | |
url | string |
- Files
- static
- .upload(ctx, ownerId, [name]) ⇒
Promise.<object>
- .uploadBuffer(buffer, ownerId, name) ⇒
Promise.<object>
- .download(ctx, ownerId, name) ⇒
Promise.<object>
- .createContainer(userId) ⇒
Promise.<function()>
- .getContainers(userId) ⇒
Promise.<function()>
- .getContainer(userId, name) ⇒
Promise.<function()>
- .removeContainer(userId, name) ⇒
Promise.<function()>
- .getFilesFromContainer(userId) ⇒
Promise.<function()>
- .getFileFromContainer(userId, name) ⇒
Promise.<function()>
- .removeFileFromContainer(userId, name) ⇒
Promise.<function()>
- .upload(ctx, ownerId, [name]) ⇒
- inner
- ~onBeforeSave(ctx) ⇒
Promise.<object>
- ~onBeforeDelete(ctx) ⇒
Promise.<object>
- "before_save" (ctx, user) ⇒
Promise.<function()>
- "before_delete" (ctx) ⇒
Promise.<function()>
- "before_*" (ctx) ⇒
Promise.<function()>
- ~onBeforeSave(ctx) ⇒
- static
# Files.upload(ctx, ownerId, [name]) ⇒ Promise.<object>
Request to upload file in userId container via multipart/form data
Kind: static method of Files
Returns: Promise.<object>
- file
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
ownerId | string | Container owner and path |
[name] | string | File name |
# Files.uploadBuffer(buffer, ownerId, name) ⇒ Promise.<object>
Request to upload file in userId container via raw buffer
Kind: static method of Files
Returns: Promise.<object>
- fileMeta
Param | Type | Description |
---|---|---|
buffer | buffer | Containing file data |
ownerId | string | Container owner and path |
name | string | File name |
# Files.download(ctx, ownerId, name) ⇒ Promise.<object>
Request to download file in ownerId container
Kind: static method of Files
Returns: Promise.<object>
- fileMeta
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
ownerId | string | Container owner and path |
name | string | File name |
# Files.createContainer(userId) ⇒ Promise.<function()>
Create a new file container
Kind: static method of Files
Returns: Promise.<function()>
- createContainer
Param | Type |
---|---|
userId | string |
# Files.getContainers(userId) ⇒ Promise.<function()>
Get a list of file containers info
Kind: static method of Files
Returns: Promise.<function()>
- getContainers
Param | Type |
---|---|
userId | string |
# Files.getContainer(userId, name) ⇒ Promise.<function()>
Get a file container info
Kind: static method of Files
Returns: Promise.<function()>
- getContainer
Param | Type |
---|---|
userId | string |
name | string |
# Files.removeContainer(userId, name) ⇒ Promise.<function()>
Remove a file container
Kind: static method of Files
Returns: Promise.<function()>
- removeContainer
Param | Type |
---|---|
userId | string |
name | string |
# Files.getFilesFromContainer(userId) ⇒ Promise.<function()>
Get files info from a container
Kind: static method of Files
Returns: Promise.<function()>
- getFilesFromContainer
Param | Type |
---|---|
userId | string |
# Files.getFileFromContainer(userId, name) ⇒ Promise.<function()>
Get a file info from a container
Kind: static method of Files
Returns: Promise.<function()>
- getFileFromContainer
Param | Type |
---|---|
userId | string |
name | string |
# Files.removeFileFromContainer(userId, name) ⇒ Promise.<function()>
Remove a file info from a container
Kind: static method of Files
Returns: Promise.<function()>
- removeFileFromContainer
Param | Type |
---|---|
userId | string |
name | string |
# Files~onBeforeSave(ctx) ⇒ Promise.<object>
Validate instance before creation
Kind: inner method of Files
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
# Files~onBeforeDelete(ctx) ⇒ Promise.<object>
Delete relations on instance(s) deletetion
Kind: inner method of Files
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
# "before_save" (ctx, user) ⇒ Promise.<function()>
Event reporting that a new Files instance will be created.
Kind: event emitted by Files
Returns: Promise.<function()>
- Files~onBeforeSave
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
user | object | Files new instance |
# "before_delete" (ctx) ⇒ Promise.<function()>
Event reporting that a / several File instance(s) will be deleted.
Kind: event emitted by Files
Returns: Promise.<function()>
- Files~onBeforeDelete
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
ctx.where.id | object | File meta instance |
# "before_*" (ctx) ⇒ Promise.<function()>
Event reporting that a file instance / collection is requested
Kind: event emitted by Files
Returns: Promise.<function()>
- Files~onBeforeRemote
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
# Measurement
Properties
Name | Type | Description |
---|---|---|
id | String | Generated ID. |
value | Number | required. |
timestamp | Date | |
type | String | OMA object ID |
resource | String | OMA resource ID |
ownerId | String | User ID of the developer who registers the application. |
deviceId | String | Device instance Id which has sent this measurement |
sensorId | String | Device instance Id which has generated this measurement |
- Measurement
- static
- .publish(deviceId, measurement, [method], [client])
- .compose(sensor) ⇒
object
- .create(measurement) ⇒
Promise.<object>
- .findById(id) ⇒
Promise.<(object|null)>
- .find(filter) ⇒
Promise.<(Array.<object>|null)>
- .replaceById(id, attributes) ⇒
Promise.<(object|null)>
- .replace(filter, attributes) ⇒
Promise.<(Array.<object>|null)>
- .destroyById(id) ⇒
Promise.<boolean>
- .delete(filter) ⇒
Promise.<boolean>
- .destroyAll(filter) ⇒
Promise.<boolean>
- inner
- ~buildQuery(app, filter, [rp]) ⇒
Promise.<string>
- ~updatePoint(app, attributes, instance) ⇒
Promise.<array>
- ~getRetentionPolicies(app, filter) ⇒
Array.<string>
- ~findMeasurements(app, filter) ⇒
Promise.<(Array.<object>|null)>
- ~updateMeasurements(app, attributes, instances) ⇒
Promise.<(Array.<object>|null)>
- ~deleteMeasurements(app, filter) ⇒
Promise.<boolean>
- ~onBeforeRemote(app, ctx) ⇒
Promise.<object>
- "before_*" (ctx) ⇒
Promise.<function()>
- ~buildQuery(app, filter, [rp]) ⇒
- static
# Measurement.publish(deviceId, measurement, [method], [client])
Format packet and send it via MQTT broker
Kind: static method of Measurement
Emits: Server.event:publish
Param | Type | Description |
---|---|---|
deviceId | object | Device instance id |
measurement | object | Measurement instance |
[method] | string | MQTT method |
[client] | object | MQTT client target |
# Measurement.compose(sensor) ⇒ object
On sensor update, if an OMA resource is of float or integer type
Kind: static method of Measurement
Returns: object
- measurement
Param | Type | Description |
---|---|---|
sensor | object | updated Sensor instance |
# Measurement.create(measurement) ⇒ Promise.<object>
Create measurement
Kind: static method of Measurement
Param | Type |
---|---|
measurement | object |
# Measurement.findById(id) ⇒ Promise.<(object|null)>
Find measurement by id
Kind: static method of Measurement
Param | Type |
---|---|
id | string |
# Measurement.find(filter) ⇒ Promise.<(Array.<object>|null)>
Find measurements
Kind: static method of Measurement
Param | Type |
---|---|
filter | object |
# Measurement.replaceById(id, attributes) ⇒ Promise.<(object|null)>
Update measurement by id
Kind: static method of Measurement
Param | Type |
---|---|
id | any |
attributes | object |
# Measurement.replace(filter, attributes) ⇒ Promise.<(Array.<object>|null)>
Update many Measurement instances
Kind: static method of Measurement
Param | Type | Description |
---|---|---|
filter | object | Where filter |
attributes | object |
# Measurement.destroyById(id) ⇒ Promise.<boolean>
Delete measurement by id
Kind: static method of Measurement
Param | Type |
---|---|
id | any |
# Measurement.delete(filter) ⇒ Promise.<boolean>
Delete measurements
Kind: static method of Measurement
Param | Type |
---|---|
filter | object |
# Measurement.destroyAll(filter) ⇒ Promise.<boolean>
Delete many Measurement instances
Kind: static method of Measurement
Param | Type | Description |
---|---|---|
filter | object | Where filter |
# Measurement~buildQuery(app, filter, [rp]) ⇒ Promise.<string>
Build influxDB query
Kind: inner method of Measurement
Param | Type | Description |
---|---|---|
app | object | Loopback app |
filter | object | Where filter |
[rp] | object | retention policy |
# Measurement~updatePoint(app, attributes, instance) ⇒ Promise.<array>
Build influxDB query
Kind: inner method of Measurement
Param | Type | Description |
---|---|---|
app | object | Loopback app |
attributes | object | |
instance | object |
# Measurement~getRetentionPolicies(app, filter) ⇒ Array.<string>
Retrieve retention policies in a where filter for Influx
Kind: inner method of Measurement
Param | Type | Description |
---|---|---|
app | object | Loopback application |
filter | object |
# Measurement~findMeasurements(app, filter) ⇒ Promise.<(Array.<object>|null)>
Find Measurement instances with filter
Kind: inner method of Measurement
Param | Type | Description |
---|---|---|
app | object | Loopback app |
filter | object | Where filter |
# Measurement~updateMeasurements(app, attributes, instances) ⇒ Promise.<(Array.<object>|null)>
Update Measurement instances with filter
Kind: inner method of Measurement
Param | Type | Description |
---|---|---|
app | object | Loopback app |
attributes | object | Measurement attributes |
instances | object | Array.<object> |
# Measurement~deleteMeasurements(app, filter) ⇒ Promise.<boolean>
Delete Measurement instances with filter
Kind: inner method of Measurement
Param | Type | Description |
---|---|---|
app | object | Loopback app |
filter | object | Where filter |
# Measurement~onBeforeRemote(app, ctx) ⇒ Promise.<object>
Called when a remote method tries to access Measurement Model / instance
Kind: inner method of Measurement
Returns: Promise.<object>
- context
Param | Type | Description |
---|---|---|
app | object | Loopback App |
ctx | object | Express context |
ctx.req | object | Request |
ctx.res | object | Response |
# "before_*" (ctx) ⇒ Promise.<function()>
Event reporting that a measurement method is requested
Kind: event emitted by Measurement
Returns: Promise.<function()>
- Measurement~onBeforeRemote
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
# OmaObject
Properties
Name | Type | Description |
---|---|---|
id | String | OmaObject ID |
name | String | OmaObject name |
description | String | Define OmaObject purpose. |
resourceIds | string | OmaResource references contained in this OmaObjectId |
resources | object | OmaResource default key : value object |
# OmaResource
Properties
Name | Type | Description |
---|---|---|
id | String | OmaResource ID |
name | String | OmaResource name |
description | String | Define OmaResource purpose. |
type | string | value type ( string, integer, float, ...) |
[operations] | string | authorized operation ( read, write ) |
[unit] | string | OmaResource unit ( meter, second, volt ... ) |
[range] | array | OmaResource value range |
# OmaViews
Properties
Name | Type | Description |
---|---|---|
id | String | OmaObject ID |
name | String | OmaObject name |
icons | array | List of icons url to assign in widgets |
resources | object | { [OmaViewssId] : "color" } |
# Scheduler
Properties
Name | Type | Description |
---|---|---|
id | String | Scheduler ID |
[name] | String | Scheduler name |
[model] | String | Aloes model ( Application, Device, ... ) |
- Scheduler
- static
- .getAll([filter]) ⇒
Promise.<Array.<object>>
- .deleteAll([filter]) ⇒
Promise.<Array.<string>>
- .publish(device, measurement, [method], [client]) ⇒
Promise.<(object|null)>
- .onTimeout(body) ⇒
Promise.<function()>
- .createOrUpdate(sensor, [client]) ⇒
Promise.<object>
- .onTick(data) ⇒
Promise.<(function()|null)>
- .onTickHook(body) ⇒
Promise.<boolean>
- .setExternalClock(interval) ⇒
Promise.<object>
- .setInternalClock(callback, interval) ⇒
function
- .setClock(interval)
- .get(key, [cb]) ⇒
Promise.<(object|null)>
- .set(key, value, [ttl], [cb]) ⇒
Promise.<object>
- .delete(key, [cb]) ⇒
Promise.<undefined>
- .expire(key, [ttl], [cb]) ⇒
Promise.<undefined>
- .keys([filter], [cb]) ⇒
Promise.<Array.<string>>
- .iterateKeys([filter]) ⇒
AsyncIterator
- .getAll([filter]) ⇒
- inner
- ~onBeforeRemote(ctx) ⇒
Promise.<object>
- ~resetClock(app, [scheduler], timeout, data) ⇒
Promise.<object>
- ~startTimer(Scheduler, sensor, resources, client, mode) ⇒
Promise.<object>
- ~stopTimer(Scheduler, sensor, resources, client, mode) ⇒
Promise.<object>
- ~parseTimerEvent(Scheduler, sensor, client) ⇒
Promise.<object>
- ~parseTimerState(Scheduler, sensor, client) ⇒
Promise.<object>
- ~onTimeout(Scheduler, sensorId) ⇒
Promise.<boolean>
- ~syncRunningTimers(Scheduler, delay) ⇒
Array.<object>
- "started" ⇒
Promise.<(functions|null)>
- "stopped" ⇒
Promise.<(functions|null)>
- "tick" ⇒
Promise.<functions>
- "before_*" (ctx) ⇒
Promise.<function()>
- ~errorCallback :
function
- ~resultCallback :
function
- ~onBeforeRemote(ctx) ⇒
- static
# Scheduler.getAll([filter]) ⇒ Promise.<Array.<object>>
Find schedulers in the cache and add to device instance
Kind: static method of Scheduler
Returns: Promise.<Array.<object>>
- schedulers
Param | Type | Description |
---|---|---|
[filter] | object | Scheduler filter |
# Scheduler.deleteAll([filter]) ⇒ Promise.<Array.<string>>
Delete schedulers stored in cache
Kind: static method of Scheduler
Returns: Promise.<Array.<string>>
- schedulers keys
Param | Type | Description |
---|---|---|
[filter] | object | Scheduler filter |
# Scheduler.publish(device, measurement, [method], [client]) ⇒ Promise.<(object|null)>
Format packet and send it via MQTT broker
Kind: static method of Scheduler
Returns: Promise.<(object|null)>
- scheduler
Emits: Server.event:publish
Param | Type | Description |
---|---|---|
device | object | found Device instance |
measurement | object | Scheduler instance |
[method] | string | MQTT method |
[client] | object | MQTT client target |
# Scheduler.onTimeout(body) ⇒ Promise.<function()>
Scheduler timeout callback / webhook ( sensor timer )
Kind: static method of Scheduler
Returns: Promise.<function()>
- Scheduler~onTimeout
Param | Type | Description |
---|---|---|
body | object | Timer callback body |
# Scheduler.createOrUpdate(sensor, [client]) ⇒ Promise.<object>
Create or update scheduler stored in cache
Kind: static method of Scheduler
Returns: Promise.<object>
- scheduler
Param | Type | Description |
---|---|---|
sensor | object | found Sensor instance |
[client] | object | MQTT client |
# Scheduler.onTick(data) ⇒ Promise.<(function()|null)>
Scheduler tick event ( scheduler clock )
Update every sensor having an active scheduler
Kind: static method of Scheduler
Returns: Promise.<(function()|null)>
- Scheduler~syncRunningTimers
Emits: Scheduler.event:publish
Param | Type | Description |
---|---|---|
data | object | Timer event data |
# Scheduler.onTickHook(body) ⇒ Promise.<boolean>
Endpoint for Scheduler external timeout callback
validate webhook content before dispatch
Kind: static method of Scheduler
Emits: Scheduler.event:tick
Param | Type | Description |
---|---|---|
body | object | Timer callback data |
# Scheduler.setExternalClock(interval) ⇒ Promise.<object>
Initialize external Clock to keep every active schedulers synchronized
Kind: static method of Scheduler
Returns: Promise.<object>
- scheduler
Param | Type | Description |
---|---|---|
interval | number | Interval between each tick |
# Scheduler.setInternalClock(callback, interval) ⇒ function
Initialize internal Clock to insure external clock is alive
Kind: static method of Scheduler
Returns: function
- DeltaTimer
Param | Type |
---|---|
callback | function |
interval | number |
# Scheduler.setClock(interval)
Init clock to synchronize with every active schedulers
Scheduler will use Skyring external timer handler
Kind: static method of Scheduler
Param | Type | Description |
---|---|---|
interval | number | Timeout interval |
# Scheduler.get(key, [cb]) ⇒ Promise.<(object|null)>
Get Scheduler by key Use callback or promise
Kind: static method of Scheduler
Param | Type | Description |
---|---|---|
key | string | |
[cb] | resultCallback | Optional callback |
# Scheduler.set(key, value, [ttl], [cb]) ⇒ Promise.<object>
Set Scheduler by key, with optional TTL
Use callback or promise
Kind: static method of Scheduler
Param | Type | Description |
---|---|---|
key | string | |
value | string | |
[ttl] | number | |
[cb] | ErrorCallback | Optional callback |
# Scheduler.delete(key, [cb]) ⇒ Promise.<undefined>
Delete Scheduler by key
Use callback or promise
Kind: static method of Scheduler
Param | Type | Description |
---|---|---|
key | string | |
[cb] | ErrorCallback | Optional callback |
# Scheduler.expire(key, [ttl], [cb]) ⇒ Promise.<undefined>
Set the TTL (time to live) in ms (milliseconds) for a given key
Use callback or promise
Kind: static method of Scheduler
Param | Type | Description |
---|---|---|
key | string | |
[ttl] | number | |
[cb] | ErrorCallback | Optional callback |
# Scheduler.keys([filter], [cb]) ⇒ Promise.<Array.<string>>
Get all Scheduler keys
Use callback or promise
Kind: static method of Scheduler
Param | Type | Description |
---|---|---|
[filter] | object | |
filter.match | object | Glob string used to filter returned keys (i.e. userid.*) |
[cb] | function |
# Scheduler.iterateKeys([filter]) ⇒ AsyncIterator
Iterate over all Scheduler keys
Use callback or promise
Kind: static method of Scheduler
Returns: AsyncIterator
- An Object implementing next(cb) -> Promise function that can be used to iterate all keys.
Param | Type | Description |
---|---|---|
[filter] | object | |
filter.match | object | Glob string used to filter returned keys (i.e. userid.*) |
# Scheduler~onBeforeRemote(ctx) ⇒ Promise.<object>
Called when a remote method tries to access Scheduler Model / instance
Kind: inner method of Scheduler
Returns: Promise.<object>
- context
Param | Type | Description |
---|---|---|
ctx | object | Express context |
# Scheduler~resetClock(app, [scheduler], timeout, data) ⇒ Promise.<object>
Create a new Skyring timer and update Scheduler instance
Kind: inner method of Scheduler
Returns: Promise.<object>
- scheduler
Param | Type | Description |
---|---|---|
app | object | Loopback application |
[scheduler] | object | Scheduler instance |
timeout | number | delay |
data | object | data contained when timeout wille be executed |
# Scheduler~startTimer(Scheduler, sensor, resources, client, mode) ⇒ Promise.<object>
Start a timer instance based on sensor resources ( startInternalTimer | startExternalTimer )
Update Sensor resources
Kind: inner method of Scheduler
Returns: Promise.<object>
- scheduler
Param | Type | Description |
---|---|---|
Scheduler | object | Scheduler Model |
sensor | object | Sensor instance |
resources | object | Sensor instance resources |
client | object | MQTT client |
mode | number | Timer mode |
# Scheduler~stopTimer(Scheduler, sensor, resources, client, mode) ⇒ Promise.<object>
Stop a timer instance based on sensor resources ( stopInternalTimer | stopExternalTimer )
Update Sensor resources
Kind: inner method of Scheduler
Returns: Promise.<object>
- scheduler
Param | Type | Description |
---|---|---|
Scheduler | object | Scheduler Model |
sensor | object | Sensor instance |
resources | object | Sensor instance resources |
client | object | MQTT client |
mode | number | Timer mode |
# Scheduler~parseTimerEvent(Scheduler, sensor, client) ⇒ Promise.<object>
Parse a timer event and dispatch to the proper function
( startTimer | stopTimer )
Kind: inner method of Scheduler
Returns: Promise.<object>
- scheduler
Param | Type | Description |
---|---|---|
Scheduler | object | Scheduler Model |
sensor | object | Sensor instance |
client | object | MQTT client |
# Scheduler~parseTimerState(Scheduler, sensor, client) ⇒ Promise.<object>
Parse a timer state and dispatch to the proper function
( startTimer | stopTimer )
Kind: inner method of Scheduler
Returns: Promise.<object>
- scheduler
Param | Type | Description |
---|---|---|
Scheduler | object | Scheduler Model |
sensor | object | Sensor instance |
client | object | MQTT client |
# Scheduler~onTimeout(Scheduler, sensorId) ⇒ Promise.<boolean>
Method called by a timer instance at timeout
( startTimer | stopTimer )
Kind: inner method of Scheduler
Returns: Promise.<boolean>
- status
Param | Type | Description |
---|---|---|
Scheduler | object | Scheduler Model |
sensorId | object | Sensor instance id |
# Scheduler~syncRunningTimers(Scheduler, delay) ⇒ Array.<object>
Method called by a timer instance at timeout
Update active Scheduler and related Sensor instances
Kind: inner method of Scheduler
Returns: Array.<object>
- sensors
Param | Type | Description |
---|---|---|
Scheduler | object | Scheduler Model |
delay | object |
# "started" ⇒ Promise.<(functions|null)>
Event reporting that application started
Trigger Scheduler starting routine
Kind: event emitted by Scheduler
Returns: Promise.<(functions|null)>
- Scheduler.setClock
# "stopped" ⇒ Promise.<(functions|null)>
Event reporting that application stopped
Trigger Scheduler stopping routine
Kind: event emitted by Scheduler
Returns: Promise.<(functions|null)>
- Scheduler.delClock
# "tick" ⇒ Promise.<functions>
Event reporting tick
Trigger Scheduler.onTick routine
Kind: event emitted by Scheduler
Returns: Promise.<functions>
- Scheduler.onTick
# "before_*" (ctx) ⇒ Promise.<function()>
Event reporting that a Scheduler method is requested
Kind: event emitted by Scheduler
Returns: Promise.<function()>
- Scheduler~onBeforeRemote
Param | Type | Description |
---|---|---|
ctx | object | Express context |
ctx.req | object | Request |
ctx.res | object | Response |
# Scheduler~errorCallback : function
Optional error callback
Kind: inner typedef of Scheduler
Param | Type |
---|---|
ErrorObject | error |
# Scheduler~resultCallback : function
Optional result callback
Kind: inner typedef of Scheduler
Param | Type |
---|---|
ErrorObject | error |
result | object |
# SensorResource
Properties
Name | Type | Description |
---|---|---|
resource | String | Stringified Sensor resource instance |
- SensorResource
- static
- .getAll([filter]) ⇒
Promise.<Array.<object>>
- .deleteAll([filter]) ⇒
Promise.<Array.<string>>
- .find(deviceId, sensorId, [resourceId]) ⇒
Promise.<(Array.<object>|null)>
- .save(deviceId, sensorId, resources, [ttl]) ⇒
Promise.<(Array.<object>|null)>
- .remove(deviceId, sensorId, [resourceId]) ⇒
Promise.<boolean>
- .expireCache(deviceId, sensorId, resourceId, [ttl]) ⇒
Promise.<boolean>
- .get(key, [cb]) ⇒
Promise.<(object|null)>
- .set(key, value, [ttl], [cb]) ⇒
Promise.<undefined>
- .delete(key, [cb]) ⇒
Promise.<undefined>
- .expire(key, [ttl], [cb]) ⇒
Promise.<undefined>
- .keys([filter], [cb]) ⇒
Promise.<Array.<string>>
- .iterateKeys([filter]) ⇒
AsyncIterator
- .getAll([filter]) ⇒
- inner
- ~errorCallback :
function
- ~resultCallback :
function
- ~errorCallback :
- static
# SensorResource.getAll([filter]) ⇒ Promise.<Array.<object>>
Get SensorResource instances stored in cache
Kind: static method of SensorResource
Returns: Promise.<Array.<object>>
- resources
Param | Type | Description |
---|---|---|
[filter] | object | Key filter |
# SensorResource.deleteAll([filter]) ⇒ Promise.<Array.<string>>
Delete SensorResource instance(s) stored in cache
Kind: static method of SensorResource
Returns: Promise.<Array.<string>>
- resources keys
Param | Type | Description |
---|---|---|
[filter] | object | Key filter |
# SensorResource.find(deviceId, sensorId, [resourceId]) ⇒ Promise.<(Array.<object>|null)>
Find SensorResource instance(s) from the cache
Kind: static method of SensorResource
Returns: Promise.<(Array.<object>|null)>
- resources
Param | Type | Description |
---|---|---|
deviceId | string | Device Id owning the sensor |
sensorId | string | Sensor instance Id |
[resourceId] | string | OMA Resource key |
# SensorResource.save(deviceId, sensorId, resources, [ttl]) ⇒ Promise.<(Array.<object>|null)>
Create or update SensorResource instance(s) into the cache memory
Kind: static method of SensorResource
Returns: Promise.<(Array.<object>|null)>
- resources
Param | Type | Description |
---|---|---|
deviceId | string | Device Id owning the sensor |
sensorId | string | Sensor Id owning the resource |
resources | object | Resource(s) instance to save |
[ttl] | number | Expire delay |
# SensorResource.remove(deviceId, sensorId, [resourceId]) ⇒ Promise.<boolean>
Delete a SensorResource instance(s) stored in cache
Kind: static method of SensorResource
Returns: Promise.<boolean>
- success
Param | Type | Description |
---|---|---|
deviceId | string | Device Id owning the sensor |
sensorId | string | Sensor instance Id |
[resourceId] | string | OMA Resource key |
# SensorResource.expireCache(deviceId, sensorId, resourceId, [ttl]) ⇒ Promise.<boolean>
Set TTL for a sensor stored in cache
Kind: static method of SensorResource
Returns: Promise.<boolean>
- success
Param | Type | Description |
---|---|---|
deviceId | string | Device Id owning the sensor |
sensorId | string | Sensor instance Id |
resourceId | string | OMA Resource key |
[ttl] | number | Sensor instance Id |
# SensorResource.get(key, [cb]) ⇒ Promise.<(object|null)>
Get SensorResource by key
Use callback or promise
Kind: static method of SensorResource
Promise: result
Param | Type | Description |
---|---|---|
key | string | |
[cb] | resultCallback | Optional callback |
# SensorResource.set(key, value, [ttl], [cb]) ⇒ Promise.<undefined>
Set SensorResource by key, with optional TTL
Use callback or promise
Kind: static method of SensorResource
Promise: undefined
Param | Type | Description |
---|---|---|
key | string | |
value | string | |
[ttl] | number | |
[cb] | ErrorCallback | Optional callback |
# SensorResource.delete(key, [cb]) ⇒ Promise.<undefined>
Delete SensorResource by key
Use callback or promise
Kind: static method of SensorResource
Promise: undefined
Param | Type | Description |
---|---|---|
key | string | |
[cb] | ErrorCallback | Optional callback |
# SensorResource.expire(key, [ttl], [cb]) ⇒ Promise.<undefined>
Set the TTL (time to live) in ms (milliseconds) for a given key
Use callback or promise
Kind: static method of SensorResource
Promise: undefined
Param | Type | Description |
---|---|---|
key | string | |
[ttl] | number | |
[cb] | ErrorCallback | Optional callback |
# SensorResource.keys([filter], [cb]) ⇒ Promise.<Array.<string>>
Get all SensorResource keys
Use callback or promise
Kind: static method of SensorResource
Param | Type | Description |
---|---|---|
[filter] | object | |
filter.match | object | Glob string used to filter returned keys (i.e. userid.*) |
[cb] | function |
# SensorResource.iterateKeys([filter]) ⇒ AsyncIterator
Iterate over all SensorResource keys
Use callback or promise
Kind: static method of SensorResource
Returns: AsyncIterator
- An Object implementing next(cb) -> Promise function that can be used to iterate all keys.
Param | Type | Description |
---|---|---|
[filter] | object | |
filter.match | object | Glob string used to filter returned keys (i.e. userid.*) |
# SensorResource~errorCallback : function
Optional error callback
Kind: inner typedef of SensorResource
Param | Type |
---|---|
ErrorObject | error |
# SensorResource~resultCallback : function
Optional result callback
Kind: inner typedef of SensorResource
Param | Type |
---|---|
ErrorObject | error |
result | string |
# Sensor
Properties
Name | Type | Description |
---|---|---|
id | string | Database generated ID. |
name | string | required. |
devEui | string | hardware generated Device Id required. |
createdAt | date | |
lastSignal | date | |
frameCounter | number | Number of messages since last connection |
type | string | OMA object ID, used to format resources schema |
resource | string | OMA resource ID used for last message |
resources | array | OMA Resources ( formatted object where sensor value and settings are stored ) |
icons | array | OMA Object icons URL |
colors | bject | OMA Resource colors |
transportProtocol | string | Framework used for message transportation |
transportProtocolVersion | string | Framework version |
messageProtocol | string | Framework used for message encoding |
messageProtocolVersion | string | Framework version |
nativeSensorId | string | Original sensor id ( stringified integer ) |
[nativeNodeId] | string | Original node id ( stringified integer ) |
nativeType | string | Original sensor type identifier |
nativeResource | string | Original sensor variables identifier |
ownerId | string | User ID of the developer who registers the application. |
deviceId | string | Device instance Id which has sent this measurement |
- Sensor
- instance
- .__get__resources() ⇒
Promise.<object>
- .__findById__resources(id) ⇒
Promise.<object>
- .__create__resources(resources) ⇒
Promise.<object>
- .__replace__resources(resources) ⇒
Promise.<object>
- .__delete__resources() ⇒
Promise.<Array.<string>>
- .__get__measurements(filter) ⇒
Promise.<Array.<object>>
- .__findById__measurements(id) ⇒
Promise.<object>
- .__create__measurements(measurement) ⇒
Promise.<object>
- .__replace__measurements(attributes, filter) ⇒
Promise.<(Array.<object>|null)>
- .__delete__measurements(filter) ⇒
Promise.<boolean>
- .__get__resources() ⇒
- static
- .createOrUpdate(device, [client]) ⇒
Promise.<object>
- .publish(device, sensor, [method], [client]) ⇒
Promise.<(object|null)>
- .compose(device, attributes) ⇒
Promise.<object>
- .handlePresentation(sensor, [client]) ⇒
Promise.<function()>
- .createOrUpdate(sensor, resourceKey, resourceValue, [client]) ⇒
Promise.<object>
- .getInstance(sensor, [client]) ⇒
Promise.<object>
- .onPublish(device, attributes, [sensor], client) ⇒
Promise.<function()>
- .search(filter) ⇒
Promise.<array>
- .export(sensors, [format]) ⇒
Promise.<(string|null)>
- .find(filter) ⇒
Promise.<object>
- .count(where) ⇒
Promise.<object>
- .findById(id, filter) ⇒
Promise.<object>
- .create(sensor) ⇒
Promise.<object>
- .updateById(id, filter) ⇒
Promise.<object>
- .deleteById(id, filter) ⇒
Promise.<object>
- .createOrUpdate(device, [client]) ⇒
- inner
- ~typeValidator(err)
- ~resourceValidator(err)
- ~transportProtocolValidator(err)
- ~messageProtocolValidator(err)
- ~compose(device, attributes, isNewInstance) ⇒
object
- ~getPersistingMethod(sensorType, resource, type) ⇒
number
- ~saveFile(app, sensor) ⇒
Promise.<object>
- ~saveMeasurement(app, sensor, client) ⇒
Promise.<(object|null)>
- ~saveScheduler(app, sensor, client) ⇒
Promise.<object>
- ~persistingResource(app, sensor, [client]) ⇒
Promise.<object>
- ~onBeforeSave(ctx) ⇒
Promise.<object>
- ~onAfterSave(ctx) ⇒
Promise.<object>
- ~deleteProps(app, instance) ⇒
Promise.<boolean>
- ~onBeforeDelete(ctx) ⇒
Promise.<object>
- ~onBeforeRemote(app, ctx) ⇒
Promise.<object>
- "publish" (message) ⇒
Promise.<(function()|null)>
- "before_save" (ctx) ⇒
Promise.<function()>
- "after_save" (ctx) ⇒
Promise.<function()>
- "before_delete" (ctx) ⇒
Promise.<function()>
- "before_*" (ctx) ⇒
Promise.<function()>
- ~errorCallback :
function
- instance
# sensor.__get__resources() ⇒ Promise.<object>
Get sensor resources from key/value store
Kind: instance method of Sensor
# sensor.__findById__resources(id) ⇒ Promise.<object>
Get sensor resources from key/value store by key
Kind: instance method of Sensor
Param | Type | Description |
---|---|---|
id | string | Resource key |
# sensor.__create__resources(resources) ⇒ Promise.<object>
Create sensor resources in key/value store
Kind: instance method of Sensor
Param | Type | Description |
---|---|---|
resources | object | Resources key/value object |
# sensor.__replace__resources(resources) ⇒ Promise.<object>
Replace sensor resources in key/value store
Kind: instance method of Sensor
Param | Type | Description |
---|---|---|
resources | object | Resources key/value object |
# sensor.__delete__resources() ⇒ Promise.<Array.<string>>
Delete sensor resources from key/value store
Kind: instance method of Sensor
# sensor.__get__measurements(filter) ⇒ Promise.<Array.<object>>
Get sensor measurement from timeseries store
Kind: instance method of Sensor
Param | Type | Description |
---|---|---|
filter | object | Measurement filter |
# sensor.__findById__measurements(id) ⇒ Promise.<object>
Get sensor measurement from timeseries store by id
Kind: instance method of Sensor
Param | Type | Description |
---|---|---|
id | string | Resource key |
# sensor.__create__measurements(measurement) ⇒ Promise.<object>
Create sensor measurement in timeseries store
Kind: instance method of Sensor
Param | Type |
---|---|
measurement | object |
# sensor.__replace__measurements(attributes, filter) ⇒ Promise.<(Array.<object>|null)>
Replace sensor measurement in timeseries store
Kind: instance method of Sensor
Param | Type |
---|---|
attributes | object |
filter | object |
# sensor.__delete__measurements(filter) ⇒ Promise.<boolean>
Delete sensor measurement from timeseries store
Kind: instance method of Sensor
Param | Type |
---|---|
filter | object |
# Sensor.createOrUpdate(device, [client]) ⇒ Promise.<object>
When POST or PUT method detected, update device instance
Kind: static method of Sensor
Returns: Promise.<object>
- device
Param | Type | Description |
---|---|---|
device | object | detected Device instance |
[client] | object | MQTT client |
# Sensor.publish(device, sensor, [method], [client]) ⇒ Promise.<(object|null)>
Format packet and send it via MQTT broker
Kind: static method of Sensor
Returns: Promise.<(object|null)>
- sensor
Emits: Server.event:publish
Param | Type | Description |
---|---|---|
device | object | found Device instance |
sensor | object | Sensor instance |
[method] | string | MQTT API method |
[client] | object | MQTT client target |
# Sensor.compose(device, attributes) ⇒ Promise.<object>
When device found,validate sensor instance produced by IoTAgent
Kind: static method of Sensor
Returns: Promise.<object>
- sensor
Param | Type | Description |
---|---|---|
device | object | found device instance |
attributes | object | IotAgent parsed message |
# Sensor.handlePresentation(sensor, [client]) ⇒ Promise.<function()>
When HEAD method detected, update sensor instance ( not the value )
Kind: static method of Sensor
Returns: Promise.<function()>
- Sensor.publish
Param | Type | Description |
---|---|---|
sensor | object | Incoming sensor instance |
[client] | object | MQTT client |
# Sensor.createOrUpdate(sensor, resourceKey, resourceValue, [client]) ⇒ Promise.<object>
When POST or PUT method detected, validate sensor.resource and value, then save sensor instance
Kind: static method of Sensor
Returns: Promise.<object>
- sensor
Param | Type | Description |
---|---|---|
sensor | object | Incoming Densor instance |
resourceKey | number | Sensor resource name ( OMA ) |
resourceValue | object | Sensor resource value to save |
[client] | object | MQTT client |
# Sensor.getInstance(sensor, [client]) ⇒ Promise.<object>
When GET method detected, find and publish instance
Kind: static method of Sensor
Returns: Promise.<object>
- sensor
Param | Type | Description |
---|---|---|
sensor | object | Incoming sensor instance |
[client] | object | MQTT client |
# Sensor.onPublish(device, attributes, [sensor], client) ⇒ Promise.<function()>
Dispatch incoming MQTT packet
Kind: static method of Sensor
Returns: Promise.<function()>
- Sensor.execute
Param | Type | Description |
---|---|---|
device | object | Found Device instance |
attributes | object | Sensor attributes detected by Iot-Agent |
[sensor] | object | Found Sensor instance |
client | object | MQTT client |
# Sensor.search(filter) ⇒ Promise.<array>
Search sensor by keywords ( name, type, )
Kind: static method of Sensor
Returns: Promise.<array>
- sensors
Param | Type | Description |
---|---|---|
filter | object | Requested filter |
# Sensor.export(sensors, [format]) ⇒ Promise.<(string|null)>
Export sensors list from JSON to {format}
Kind: static method of Sensor
Param | Type |
---|---|
sensors | array |
[format] | string |
# Sensor.find(filter) ⇒ Promise.<object>
Find sensors
Kind: static method of Sensor
Param | Type |
---|---|
filter | object |
# Sensor.count(where) ⇒ Promise.<object>
Returns sensors length
Kind: static method of Sensor
Param | Type |
---|---|
where | object |
# Sensor.findById(id, filter) ⇒ Promise.<object>
Find sensor by id
Kind: static method of Sensor
Param | Type |
---|---|
id | any |
filter | object |
# Sensor.create(sensor) ⇒ Promise.<object>
Create sensor
Kind: static method of Sensor
Param | Type |
---|---|
sensor | object |
# Sensor.updateById(id, filter) ⇒ Promise.<object>
Update sensor by id
Kind: static method of Sensor
Param | Type |
---|---|
id | any |
filter | object |
# Sensor.deleteById(id, filter) ⇒ Promise.<object>
Delete sensor by id
Kind: static method of Sensor
Param | Type |
---|---|
id | any |
filter | object |
# Sensor~typeValidator(err)
Validate sensor type before saving instance
Kind: inner method of Sensor
Param | Type |
---|---|
err | ErrorCallback |
# Sensor~resourceValidator(err)
Validate sensor resource before saving instance
Kind: inner method of Sensor
Param | Type |
---|---|
err | ErrorCallback |
# Sensor~transportProtocolValidator(err)
Validate sensor transportProtocol before saving instance
Kind: inner method of Sensor
Param | Type |
---|---|
err | ErrorCallback |
# Sensor~messageProtocolValidator(err)
Validate sensor messageProtocol before saving instance
Kind: inner method of Sensor
Param | Type |
---|---|
err | ErrorCallback |
# Sensor~compose(device, attributes, isNewInstance) ⇒ object
Compose a sensor instance from a device and retrieved attributes
Kind: inner method of Sensor
Returns: object
- sensor
Param | Type | Description |
---|---|---|
device | object | Device instance |
attributes | object | Sensor attributes |
isNewInstance | object | Flag to indicate that the sensor is a new instance |
# Sensor~getPersistingMethod(sensorType, resource, type) ⇒ number
Define the way to persist data based on OMA resource type
SaveMethods : buffer: 10, location: 20, log: 30, measurement: 40, scheduler: 50,
Kind: inner method of Sensor
Returns: number
- method
Param | Type | Description |
---|---|---|
sensorType | string | OMA object Id |
resource | number | OMA resource ID |
type | string | OMA resource type |
# Sensor~saveFile(app, sensor) ⇒ Promise.<object>
Save a sensor resource as a file
Kind: inner method of Sensor
Returns: Promise.<object>
- fileMeta
Param | Type | Description |
---|---|---|
app | object | Loopback app |
sensor | object | Sensor instance |
# Sensor~saveMeasurement(app, sensor, client) ⇒ Promise.<(object|null)>
Save a sensor resource as a measurement
Kind: inner method of Sensor
Returns: Promise.<(object|null)>
- measurement
Param | Type | Description |
---|---|---|
app | object | Loopback app |
sensor | object | Sensor instance |
client | object | MQTT client |
# Sensor~saveScheduler(app, sensor, client) ⇒ Promise.<object>
Save a sensor resource as a timer
Kind: inner method of Sensor
Returns: Promise.<object>
- scheduler
Param | Type | Description |
---|---|---|
app | object | Loopback app |
sensor | object | Sensor instance |
client | object | MQTT client |
# Sensor~persistingResource(app, sensor, [client]) ⇒ Promise.<object>
Persist data based on OMA resource type
use influxdb for integers and floats
use filestorage for strings and buffers
Kind: inner method of Sensor
Returns: Promise.<object>
- result - saved value
Param | Type | Description |
---|---|---|
app | object | Loopback app |
sensor | object | Sensor instance |
[client] | object | MQTT client |
# Sensor~onBeforeSave(ctx) ⇒ Promise.<object>
Validate instance before creation
Kind: inner method of Sensor
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
# Sensor~onAfterSave(ctx) ⇒ Promise.<object>
Create relations on instance creation
Kind: inner method of Sensor
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
# Sensor~deleteProps(app, instance) ⇒ Promise.<boolean>
Remove sensor dependencies
Kind: inner method of Sensor
Param | Type | Description |
---|---|---|
app | object | Loopback app |
instance | object |
# Sensor~onBeforeDelete(ctx) ⇒ Promise.<object>
Delete relations on instance(s) deletetion
Kind: inner method of Sensor
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
# Sensor~onBeforeRemote(app, ctx) ⇒ Promise.<object>
Called when a remote method tries to access Sensor Model / instance
Kind: inner method of Sensor
Returns: Promise.<object>
- context
Param | Type | Description |
---|---|---|
app | object | Loopback App |
ctx | object | Express context |
ctx.req | object | Request |
ctx.res | object | Response |
# "publish" (message) ⇒ Promise.<(function()|null)>
Event reporting that a device client sent sensors update.
Kind: event emitted by Sensor
Returns: Promise.<(function()|null)>
- Sensor.onPublish
Param | Type | Description |
---|---|---|
message | object | Parsed MQTT message. |
Properties
Name | Type | Description |
---|---|---|
message.device | object | found device instance. |
message.pattern | object | Pattern detected by Iot-Agent |
message.attributes | object | IotAgent parsed message |
[message.sensor] | object | Found sensor instance |
message.client | object | MQTT client |
# "before_save" (ctx) ⇒ Promise.<function()>
Event reporting that a sensor instance will be created or updated.
Kind: event emitted by Sensor
Returns: Promise.<function()>
- Sensor~onBeforeSave
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
ctx.instance | object | Sensor instance |
# "after_save" (ctx) ⇒ Promise.<function()>
Event reporting that a sensor instance has been created or updated.
Kind: event emitted by Sensor
Returns: Promise.<function()>
- Sensor~onAfterSave
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
ctx.instance | object | Sensor instance |
# "before_delete" (ctx) ⇒ Promise.<function()>
Event reporting that a/several sensor instance(s) will be deleted.
Kind: event emitted by Sensor
Returns: Promise.<function()>
- Sensor~onBeforeDelete
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
ctx.where.id | object | Sensor id |
# "before_*" (ctx) ⇒ Promise.<function()>
Event reporting that a sensor method is requested
Kind: event emitted by Sensor
Returns: Promise.<function()>
- Sensor~onBeforeRemote
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
# Sensor~errorCallback : function
Error callback
Kind: inner typedef of Sensor
Param | Type |
---|---|
ErrorObject | error |
# User
Properties
Name | Type | Description |
---|---|---|
id | string | Database generated ID |
firstName | string | |
lastName | string | |
fullName | string | |
fullAddress | string | |
avatarImgUrl | string | |
headerImgUrl | string | |
status | boolean | |
roleName | string | admin or user |
- User
- static
- .findByEmail(email) ⇒
Promise.<object>
- .verifyEmail(user) ⇒
Promise.<object>
- .updatePasswordFromToken(accessToken, newPassword) ⇒
Promise.<boolean>
- .setNewPassword(ctx, oldPassword, newPassword) ⇒
Promise.<object>
- .sendContactForm(form) ⇒
Promise.<boolean>
- .sendInvite(options) ⇒
Promise.<boolean>
- .updateStatus(client, status) ⇒
Promise.<object>
- .find(filter) ⇒
Promise.<object>
- .count(where) ⇒
Promise.<number>
- .findById(id) ⇒
Promise.<object>
- .create(user) ⇒
Promise.<object>
- .updateById(id) ⇒
Promise.<object>
- .deleteById(id) ⇒
Promise.<object>
- .findByEmail(email) ⇒
- inner
- ~detector(packet, client) ⇒
object
|null
- ~createProps(app, user) ⇒
Promise.<(object|null)>
- ~onBeforeSave(ctx) ⇒
Promise.<object>
- ~onAfterSave(ctx) ⇒
Promise.<object>
- ~onBeforeLogin(ctx) ⇒
Promise.<object>
- ~deleteProps(app, user) ⇒
Promise.<boolean>
- ~onBeforeDelete(ctx) ⇒
Promise.<object>
- ~onBeforeRemote(ctx) ⇒
Promise.<object>
- "attached"
- "verifyEmail" (user) ⇒
Promise.<function()>
- "sendContactForm" (options) ⇒
Promise.<function()>
- "sendMailInvite" (options) ⇒
Promise.<function()>
- "resetPasswordRequest" (options) ⇒
Promise.<function()>
- "client" (message) ⇒
Promise.<(function()|null)>
- "before_save" (ctx, user) ⇒
Promise.<function()>
- "after_save" (ctx, user) ⇒
Promise.<function()>
- "before_delete" (ctx) ⇒
Promise.<function()>
- "before_*" (ctx) ⇒
Promise.<function()>
- ~detector(packet, client) ⇒
- static
# User.findByEmail(email) ⇒ Promise.<object>
Find a user by its email address and send a confirmation link
Kind: static method of User
Returns: Promise.<object>
- user
Param | Type | Description |
---|---|---|
string | User email address |
# User.verifyEmail(user) ⇒ Promise.<object>
Send a confirmation link to confirm signup
Kind: static method of User
Returns: Promise.<object>
- user
Param | Type | Description |
---|---|---|
user | object | User instance |
# User.updatePasswordFromToken(accessToken, newPassword) ⇒ Promise.<boolean>
Updating user password using an authorization token
Kind: static method of User
Returns: Promise.<boolean>
- result
Param | Type | Description |
---|---|---|
accessToken | object | User instance |
newPassword | string | User new password |
# User.setNewPassword(ctx, oldPassword, newPassword) ⇒ Promise.<object>
Updating user password
Kind: static method of User
Returns: Promise.<object>
- user
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
oldPassword | string | |
newPassword | string |
# User.sendContactForm(form) ⇒ Promise.<boolean>
Sending a request to admin
Kind: static method of User
Emits: User.event:sendContactForm
Param | Type | Description |
---|---|---|
form | object | Client form options |
# User.sendInvite(options) ⇒ Promise.<boolean>
Sending a mail invitation to a new user
Kind: static method of User
Emits: User.event:sendMailInvite
Param | Type |
---|---|
options | object |
# User.updateStatus(client, status) ⇒ Promise.<object>
Update client (as the user) status from MQTT connection status
Kind: static method of User
Returns: Promise.<object>
- client
Param | Type | Description |
---|---|---|
client | object | MQTT parsed client |
status | boolean | MQTT connection status |
# User.find(filter) ⇒ Promise.<object>
Find users
Kind: static method of User
Param | Type |
---|---|
filter | object |
# User.count(where) ⇒ Promise.<number>
Returns users length
Kind: static method of User
Param | Type |
---|---|
where | object |
# User.findById(id) ⇒ Promise.<object>
Find user by id
Kind: static method of User
Param | Type |
---|---|
id | any |
# User.create(user) ⇒ Promise.<object>
Create user
Kind: static method of User
Param | Type |
---|---|
user | object |
# User.updateById(id) ⇒ Promise.<object>
Update user by id
Kind: static method of User
Param | Type |
---|---|
id | any |
# User.deleteById(id) ⇒ Promise.<object>
Delete user by id
Kind: static method of User
Param | Type |
---|---|
id | any |
# User~detector(packet, client) ⇒ object
| null
Detect device known pattern and load the application instance
Kind: inner method of User
Returns: object
| null
- pattern
Param | Type | Description |
---|---|---|
packet | object | MQTT packet |
client | object | MQTT client |
# User~createProps(app, user) ⇒ Promise.<(object|null)>
Create dependencies after a new user has been created
Kind: inner method of User
Returns: Promise.<(object|null)>
- user
Param | Type | Description |
---|---|---|
app | object | Loopback app |
user | object | New user instance |
# User~onBeforeSave(ctx) ⇒ Promise.<object>
Validate instance before creation
Kind: inner method of User
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
# User~onAfterSave(ctx) ⇒ Promise.<object>
Create relations on instance creation
Kind: inner method of User
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
# User~onBeforeLogin(ctx) ⇒ Promise.<object>
Control access validity and limit access if needed before login request
Incrementing counter on failure and resetting it on success
Kind: inner method of User
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
# User~deleteProps(app, user) ⇒ Promise.<boolean>
Delete relations on instance(s) deletion
Kind: inner method of User
Returns: Promise.<boolean>
- ctx
Param | Type | Description |
---|---|---|
app | object | Loopback app |
user | object | user to delete |
# User~onBeforeDelete(ctx) ⇒ Promise.<object>
Delete registered user
Kind: inner method of User
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
# User~onBeforeRemote(ctx) ⇒ Promise.<object>
Hook executed before every remote methods
Kind: inner method of User
Returns: Promise.<object>
- ctx
Param | Type | Description |
---|---|---|
ctx | object | Loopback context |
# "attached"
Event reporting that User model has been attached to the application
Kind: event emitted by User
# "verifyEmail" (user) ⇒ Promise.<function()>
Event reporting to trigger mails.verifyEmail
Kind: event emitted by User
Returns: Promise.<function()>
- Mails.verifyEmail
Param | Type | Description |
---|---|---|
user | object | User instance |
# "sendContactForm" (options) ⇒ Promise.<function()>
Event reporting to trigger mails.send
Kind: event emitted by User
Returns: Promise.<function()>
- Mails.sendContactForm
Param | Type | Description |
---|---|---|
options | object | Form properties |
# "sendMailInvite" (options) ⇒ Promise.<function()>
Event reporting to trigger mails.send
Kind: event emitted by User
Returns: Promise.<function()>
- Mails.sendMailInvite
Param | Type | Description |
---|---|---|
options | object | Form properties |
# "resetPasswordRequest" (options) ⇒ Promise.<function()>
Event reporting to send password reset link when requested
Kind: event emitted by User
Returns: Promise.<function()>
- Mails.sendResetPasswordMail
Param | Type | Description |
---|---|---|
options | object | Mail options |
# "client" (message) ⇒ Promise.<(function()|null)>
Event reporting that a client ( as the user ) connection status has changed.
Kind: event emitted by User
Returns: Promise.<(function()|null)>
- User.updateStatus
Param | Type | Description |
---|---|---|
message | object | Parsed MQTT message. |
Properties
Name | Type | Description |
---|---|---|
message.client | object | MQTT client |
message.status | boolean | MQTT client status. |
# "before_save" (ctx, user) ⇒ Promise.<function()>
Event reporting that a new user instance will be created.
Kind: event emitted by User
Returns: Promise.<function()>
- User~onBeforeSave
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
user | object | User new instance |
# "after_save" (ctx, user) ⇒ Promise.<function()>
Event reporting that a new user instance has been created.
Kind: event emitted by User
Returns: Promise.<function()>
- User~onAfterSave
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
user | object | User new instance |
# "before_delete" (ctx) ⇒ Promise.<function()>
Event reporting that a user instance will be deleted.
Kind: event emitted by User
Returns: Promise.<function()>
- User~onBeforeDelete
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
ctx.req | object | Request |
ctx.res | object | Response |
ctx.where.id | object | User instance id |
# "before_*" (ctx) ⇒ Promise.<function()>
Event reporting that a remote user method has been requested
Kind: event emitted by User
Returns: Promise.<function()>
- User~onBeforeRemote
Param | Type | Description |
---|---|---|
ctx | object | Express context. |
# OmaObjects
Oma Object References.
Kind: global external
See: https://aloes.io/app/api/omaObjects
# OmaResources
Oma Resources References.
Kind: global external
See: https://aloes.io/app/api/omaResources