0.0.17 • Published 9 years ago

tls-xml v0.0.17

Weekly downloads
1
License
MIT
Repository
bitbucket
Last release
9 years ago

TLS-XML Library

This library is used to work with tls connection that sends and receives payload of format:

0-4 Bytes: Payload Length \ 4-8 Bytes: CommandID \ 8- remaining: Payload

API

new SecurifiSocket(options)

  • options Object
    • host String
    • port Number
    • rejectUnauthorized Boolean

Construct a new socket object.

socket.send(commandName, data)

  • commandName String
  • data Object

Sends command with commandName and data through tls connection. data is JSON object.

Available commands:

  • login
  • almond_list
  • device_value
  • device_data
  • mobile_command

JSON commands:

  • update_index
  • device_list

Command: "update_index":

 {
    "MobileInternalIndex":689,
    "CommandType":"UpdateDeviceIndex",
    "ID":<device_id>,
    "Index":<value_index>,
    "Value":<value>,
    "AlmondMAC": <almond_mac>
 }

Command "device_list"

 {
    "MobileInternalIndex":355,
    "CommandType":"DeviceList" ,
    "AlmondMAC":<almond_mac>,
    "Action": "get"
 }

Event: 'data'

function(data) { }

When this event emitted JSON object is passed to data variable.

Event: 'error'

function (error) { }

If the internal tls socket emits an error, this event is emitted.

Event: 'open'

function () { }

Emitted when the tls connection is established.

Example

var SecurifiSocket = require('tls-xml');

Options is used to connect to server thhrough tls connection.

var options = {
      host: '102.13.54.134',
      port: 5000,
      rejectUnauthorized:false		
}

var socket = new SecurifiSocket(options):

socket.on('open', function() {
	console.log('Connection opened');
})

Lock example:

securifi.lock('full', {
    macAddress:"25117621634324",
    devices: ["1","2","3"],
    lockout: {
      coolingSetpoint:{
        min: 40,
        max: 50
      },
      heatingSetpoint: {
        min: 60,
        max:70
      },
      duration: 360,
      pin: 1111,
      allowedModes:{}
    }
  })

Unlock example:

securifi.unlock({
    macAddress:"25117621634324",
    devices: ["1","2","3"]
  })

"device_list" response:

{
   "CommandType":"DeviceList",
   "Success":true,
   "Reason":null,
   "AlmondMAC":251176216341111,
   "Devices":{
      "1":{
         "Data":{
            "ID":1,
            "Type":62,
            "Name":"Zen Thermostat #1",
            "AssociationTimeStamp":null,
            "FriendlyDeviceType":null,
            "Location":"Default"
         },
         "DeviceValues":{
            "1":{
               "Name":"SENSOR MULTILEVEL",
               "Value":"83.3"
            },
            "2":{
               "Name":"THERMOSTAT MODE",
               "Value":"Heat"
            },
            "3":{
               "Name":"THERMOSTAT OPERATING STATE",
               "Value":""
            },
            "4":{
               "Name":"THERMOSTAT SETPOINT HEATING",
               "Value":"49"
            },
            "5":{
               "Name":"THERMOSTAT SETPOINT COOLING",
               "Value":"40"
            },
            "6":{
               "Name":"THERMOSTAT FAN MODE",
               "Value":"Auto Low"
            },
            "7":{
               "Name":"THERMOSTAT FAN STATE",
               "Value":""
            },
            "8":{
               "Name":"BATTERY",
               "Value":""
            },
            "9":{
               "Name":"UNITS",
               "Value":""
            },
            "10":{
               "Name":"CUSTOM_MESSAGE",
               "Value":""
            }
         }
      }
   }
}
0.0.17

9 years ago

0.0.16

9 years ago

0.0.15

9 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago