1. Home
  2. Sorce Documentation
  3. Integration – for advanced
  4. Integration

Integration

This is probably not the page You are looking for

I’m describing here what action should be taken to write your own application (android, desktop ) to integrate with the system.

To use your application user have to login first, to Interact with RemoteMe.org you are using special RESTs and weboscket

All RESTs start with:

Or

 

Taking token

Header:
username:  username of user
password: md5(username password in md5 format)

Then you can use this token at other request by putting in header “ARLiteToken” and as value the response of rest:

 

It will automatically authenticate your requests

Other possibility of authentication request is to put this token in request itself after /arLite/ for example

All rests function you can use are describe here and choose in right top combo box ZZ_Arduino_Lite. The functions are doubled because of ** which can be replaces by userToken

when Token is generated next message you should call is ‘ register message ‘ it will register your device in the system itself as a new device.

 

https://app.remoteme.org/arLite/{yourtoken}/rest/v1/register/ as POST and body:

niceName – is the name displayed in user interface and smartPhoneId is an id of your device it has to be unique and stay the same between every single launching of the application

this function will create new mechanism, or use already created mechanism if there is already device with smartPhoneId you send. Function will return deviceId.

DeviceId is then used in websocket communication, calling rests etc. So should be remembered after its retrieve.

 

WebSocket

to connect websocket just simply connect to URL:

so in javascript it will looks like that:

using this websocket you can send messages to the system, and also receive messages.

After connect websocket icon of your device at user interface will change to connected.

Also to keep websocket connection alive, you have to send at not more than 2minutes ( 90seconds recommend ) special message:

Otherwise system  will close connection after two minutes.

You don’t have to use websocket to send messages you can also use rest:

as PUT and in body json to send.

Messages

all messages implementation can be found here . All messages in JSON format has to have special field “type” which tells what type of message are sent.

I will describe more important messages

CreateVariablesMessage

Create Variables at the system, later other devices can listen to them

Example:

  • “type” : “CreateVariablesMessage”,
  • “variables” -variables to create
    • name – variable name
    • type – more in variable types section
    • persistent – if value should be saved in database and notify with current value just after device starts observed variable
    • history – remember historical values- useful for temperature

Variable name and type pair has to be unique, if there will be duplicated variable will not be created

VariableObserveMessage

Notify remoteme.org that this device is listening of changes at given variables. Then when one of registered variables are changed application will be notified by websocket message. When Device is reconnected variables to observe has to be registered again.

When we start to observe persistent variables and there is value already set then after register callback function for these variables will be called.

Example:

  • “type” : “VariableRegisterMessage”,
  • “deviceId” – your deviceId
  • “variables” array of variables to observe. Observe has  (more in variables section)
    • type for example BOOLEAN, INTEGER
    • name

Variable name and type pair has to be unique, if there will be duplicated variable will not be registered

VariableChangePropagateMessage

This message You don’t send by yourself its only to receive example:

  • type : “VariableChangePropagateMessage”,
  • senderDeviceId – what device made changes
  • receiveDeviceId – target devices in most cases its your deviceId ( its different if your device is registered as network proxy device with leafs)
  • states ; array of changed variables
    • type : type of variable
    • name : name of variable
    • data : based on variable type there is data – more in variables data section
VariableChangeMessage

You send this message when You want to change variable state

  • “type” : “VariableChangeMessage”,
  • “senderDeviceId” : your deviceId
  • ignoreReceivers : devices which should NOT be notify about this change – in most cases you put your deviceId, so it will not notify itself about change the device itself made. But You can also made this field empty and then your device will be also notifed (of course if its observing this variable)
  • states; array of changed variables
    • type : type of variable
    • name : name of variable
    • data : based on variable type there is data – more in variables data section
VariableRenameMessage

To rename already register variable.

  • “type” : “VariableRenameMessage”,
  • deviceId your deviceId
  • data variable data to change
    • oldName ; old name of variable
    • newName : new name of variable
    • type – variable type – types in variable option
VariableRemoveMessage

Stops observe variable

  • “type” : “VariableRemoveMessage”,
  • deviceId your deviceId
  • data variable data to change
    • name – name of variable
    • type – variable type – types in variable option
NotifyAboutVariablesMessage

sends Persistent observed variables data into websocket as  VariableChangePropagateMessage. Its useful when you want to refresh variables data manually.

  • “type” : “NotifyAboutVariablesMessage”,
  • identifiers – identifiers of variables we want to receive values from

if there is no persistent value no message back for variable will be sent

 

Variables

There are several types of variables:

always up to date lists ob variables can be found here

States -ts used as data as variables for example in VariableChangeMessage or VariableChangePropagateMessage

all implementation of Messages can be found here : in *State files

all state has:

  • name of variable
  • type of variable
  • data – based on type

below some examples: