tls-xml
Moudle for work with tls socket that receives xml payload.
Last updated 4 years ago by nazar.herman .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install tls-xml 
SYNC missed versions from official npm registry.

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":""
            }
         }
      }
   }
}

Current Tags

  • 0.0.17                                ...           latest (4 years ago)

13 Versions

  • 0.0.17                                ...           4 years ago
  • 0.0.16                                ...           4 years ago
  • 0.0.15                                ...           4 years ago
  • 0.0.13                                ...           4 years ago
  • 0.0.12                                ...           4 years ago
  • 0.0.11                                ...           4 years ago
  • 0.0.10                                ...           4 years ago
  • 0.0.9                                ...           4 years ago
  • 0.0.8                                ...           4 years ago
  • 0.0.7                                ...           4 years ago
  • 0.0.6                                ...           4 years ago
  • 0.0.5                                ...           4 years ago
  • 0.0.4                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 13
Dependencies (3)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |