Start building your IoT solution with Itron's SLV Platform Create an Account

 

slv-api is a JavaScript tool that makes sensor integration with SLV quick and easy. slv-api includes a module that connects to SLV for data retrieval, device integration, and data publishing from sensor devices.  slv-api also includes sample programs that illustrate how to perform common operations with the SLV platform. Integration with SLV allows IoT innovators to quickly deploy sensor applications to leading cities and utilities around the world!

 

 

Overview

SLV is the industry-leading Central Management System for Smart Cities and Communities.  SLV manages IoT devices and data, including networked lighting controllers, as well as a variety of IoT sensors delivering key smart cities outcomes, including air quality monitoring, parking management, gunshot detection, pedestrian and vehicle traffic counting, etc.  Itron makes it easy for partners to integrate their sensors and data into SLV using the slv-api module.

Slv_api is a JavaScript module that exposes an easy-to-use interface to integrate devices and data into SLV.  Slv-api accelerates SLV integration by making it easy for application developers to programmatically create devices, geozones, and associated data that stored by SLV.  Developers can either incorporate slv-api into their application, or use the code samples in slv-api to learn the syntax of SLV APIs.  Since slv-api is implemented in JavaScript, it can be run in a web browser, or in Node.js.

Figure 1: slv-api Solution Integration with SLV

 

To get started integrating your solution with SLV, contact Itron to create an account in our partner instance of SLV by sending an email request to developerprogram@itron.com.  Include in your email your preferred location to center your Geozone around, and the type(s) of IoT sensor devices you wish to create. 

Options for sensor device types include:

  • Flood/gulley sensor
  • Air Quality sensor
  • Weather station
  • Smart Parking sensor
  • Gas leak sensor
  • Tilt sensor
  • Waste bin sensor
  • Noise/acoustic monitoring sensor
  • Electricity, gas, or water meter
  • Pedestrian or vehicle count sensor

 

We will be happy to assist you in setting up SLV access so you can start integrating your IoT devices and data into SLV, and join our ecosystem of Smart Communities solution providers to create a more resourceful world!

 

The code samples below show how to perform basic SLV operations using slv_api.  These examples include connecting to SLV, retrieving lists of devices and geozones associated with your account in SLV, creating new sensor devices in SLV, and sending updated data for those devices.  Both static and measured sensor data can be updated for a device, using a single API call.  The code samples also demonstrate extracting data and alarms for devices.

Note: The method for sending updated sensor data to SLV is sendDeviceValues.  The only mandatory parameter is an object representation of the data, which includes key/value pairs for sensor attributes.  These attributes are based on the sensor data type you are using (for example, flood sensor, tilt sensor, waste bin sensor, etc).  Optional parameters include use_current_time, which indicates that sendDeviceValues will use the current UTC time to apply to the supplied sensor data.  If this is false, the caller must provide the eventTime for the sensor data.  The final parameter is utc_offset, which defaults to 0. utc_offset is a signed integer that represents the number of hours (+ or -) to offset from UTC to localize the time zone.

 

 

Connect to SLV and List Geozones

const slv = require ('./slv_api.js');

//First set the SLV user's authorization credentials

slv.setAuthString('username','password');

//Connect to SLV
slv.connect().then((data) => {

        //Retrieve and display a list of Geozones associated with your SLV user account.
        slv.getAllGeozones().then((geozones) => {
            console.log(geozones);
    });
});

List Devices within a Geozone

const slv = require ('./slv_api.js');

const fs = require('fs');
slv.setAuthString('username','password');
slv.connect().then((data) => {
    //retrieve devices from SLV Geozone
    const GEOZONE_ID = 12345;

    //Use the getGeozoneDevices function to retrieve all devices within the supplied Geozone.
    slv.getGeozoneDevices(GEOZONE_ID)
    .then((data) => {

            //Print the JSON data structure listing all devices   
            console.log("Devices retrieved! " + data);
    })
    .catch((err) => {console.error("Unable to retrieve devices from geozone: " + err);})
});

Create a New Device in SLV

const slv = require ('./slv_api.js');
const CONTROLLER_ID = 'OSCPController001';
const DEVICE_NAME = 'NewDeviceName';
const CATEGORY = 'parkingPlace';

//Connect to SLV
slv.setAuthString('username','password');
slv.connect().then((data) => {    
    const GEOZONE_ID = 12345;
    
    //Create a new sensor device
    let parkingPlace = {};
    parkingPlace["controllerStrId"] = CONTROLLER_ID;
    parkingPlace["idOnController"] = DEVICE_NAME;
    parkingPlace["userName"] = DEVICE_NAME;
    parkingPlace["categoryStrId"] = CATEGORY;
    parkingPlace["geoZoneId"] = GEOZONE_ID;
    parkingPlace["lat"] = '29.430844254516185';
    parkingPlace["lng"] = '-98.49308974533695';
    
    
    slv.createDevice(parkingPlace)
    .then((data) => {
            console.log("Device created! " + data);        

    })
    .catch((err) => {console.error("Unable to create new parking place: " + err);})
});

Update Device Data in SLV

    slv.createDevice(parkingPlace)
    .then((data) => {
            console.log("Device created! " + data);        
           
            //Send SLV updated values for both measured and static attributes.
            let parkingData = {};
            parkingData["controllerStrId"] = CONTROLLER_ID;
            parkingData["idOnController"] = DEVICE_NAME;                        
            //The valueName element is set to an array of attribute names,

            //some of which are static (SerialNumber), and some of which are measured (OccupiedSpaces)
            parkingData["valueName"] = ["Manufacturer","SerialNumber","SamplingPeriod","TotalParkingSpaces", "OccupiedSpaces","SpacePercentageAvailable","VehiclesStayLess15Count","VehiclesStayMore15Count","VehiclesStayMore240Count"];
            parkingData["value"] = ['ACME','4652','60','100','20','80%','0','15','5'];
            
            slv.sendDeviceValues(parkingData).then((updateResult) => {
                console.log("Device " + DEVICE_NAME + " updated: " + updateResult);
            })
            .catch((err) => {console.error("Unable to update parking place: " + err);})            
    })