Skip to content

VeraLuupNet Integration

entrodus edited this page Aug 4, 2015 · 6 revisions

Integration of VeraLuupNet

Integrate VeraLuupNet to your project using the following steps

  • Add a reference to VeraLuupNet.Framework Project

  • Create a local vera instance of VeraMasterClass providing the following parameters

    • a ISessionInterface object implementation
    • a Callback for all messages

var vera = new VeraMasterClass(new SessionHolder(), this.VeraMessagesCallBack);

  • Obtain the hashed password
    Vera authentication requires a specific format of the users password. In order to obtain this, call the FrameworkHelpers.GetHashedPassword static method providing both the username and password of your vera account.

var hashedPassword = FrameworkHelpers.GetHashedPassword(username, password);

  • Initialize the vera instance (create session in vera Servers) by using the Initialize method providing the following parameters
    • username
    • hashedPassword

vera.Initialize(username, hashedPassword);

  • Call any luup request by using the LuupRequest method of your vera instance.

vera.LuupRequest("status");

ISessionInterface implementation

Use this interface to provide an object that stores all needed session variables.
All calls to luup request use stored session variables and do not require re-authentication procedures. (as proposed by Vera Support Team)
You can find an implementation of this interface in the Utils\SessionHolder.cs unit in the main VeraLuupNet project.

VeraMessagesCallBack Action

Provide a callback in order to receive thorough information on all states of VeraLuupNet. If you do not require any user you can just trace this information using the following example:

private void VeraMessagesCallBack(MessageTypeEnum messageType, string message)
{
var str = string.Format("{0} - {1}", messageType, message);
Trace.WriteLine(str);
}