We have moved at community.getvera.com

Author Topic: .NET (C#) Library for Vera  (Read 4542 times)

Offline Ercant

  • Newbie
  • *
  • Posts: 19
  • Karma: +2/-0
.NET (C#) Library for Vera
« on: February 20, 2014, 11:25:57 pm »
Hi All,
I have uploaded the first version of my .NET Library for Vera to Codeplex.

You can find it here: http://veradotnet.codeplex.com/

I developed a tool to generate some parts of the source code. As soon as I finish up a few minor touches in the tool, I am also planning to release that tool at Codeplex.

I really appreciate your feedback.

Regards,
Ercan

http://www.linkedin.com/in/ercanturkarslan
ErcanT

Offline Ercant

  • Newbie
  • *
  • Posts: 19
  • Karma: +2/-0
Re: .NET (C#) Library for Vera
« Reply #1 on: March 03, 2014, 07:37:50 pm »
I have uploaded a newer version of the library.

This new version provides incremental polling functionality using SDATA or USER_DATA/STATUS.

Simply by calling Poll method of MiosEngine class, you can update the variables that have changed since last update.
ErcanT

guest15496

  • Guest
Re: .NET (C#) Library for Vera
« Reply #2 on: March 26, 2014, 08:50:00 pm »
I have not used this C# API - however you might want to release a built EXE command-line wrapper for it (I realize not all use cases will fit neatly into a single commandline, perhaps figure out the 90/10 cases) also as part of your source, either as a C# console app or perhaps some sample PowerShell scripts - there are probably a lot of people who want to do some automation on Windows via CMD shell scripts but don't know C# or want to get involved with the VS IDE. I haven't searched extensively but I am not aware of any simple command-line interface on Windows (other than curl with URLs, other scripting langs, etc.)


Offline fhreid

  • Sr. Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Re: .NET (C#) Library for Vera
« Reply #3 on: April 21, 2014, 06:30:14 am »
Hi Ercant,

Great DLL for Vera!  I'm getting a parsing error when I call the Poll() method.

"An unhandled exception of type 'Mios.MiosFormatException' occurred in Mios.dll
Additional information: Could not parse returned value [1449.0790] to UInt32!"

Looking through my XML, I find:

"<state service="urn:micasaverde-com:serviceId:EnergyMetering1" variable="KWH" id="21" value="1449.0790"/>"

I believe this is due to the precision level of data type UInt32.

Any advice?


Offline RichardTSchaefer

  • Community Beta
  • Master Member
  • ******
  • Posts: 10091
  • Karma: +764/-143
Re: .NET (C#) Library for Vera
« Reply #4 on: April 21, 2014, 08:47:14 am »
I have not used his interface ... but on the face of things:

      UInt32 is an unsigned 32 bit integer ... i.e. NO decimal point.


Offline electricessence

  • Sr. Member
  • ****
  • Posts: 251
  • Karma: +0/-0
Re: .NET (C#) Library for Vera
« Reply #5 on: April 26, 2014, 02:28:47 am »
I have added to the open source veradotnet project a fork that includes an easy to use command line tool. :)
https://veradotnet.codeplex.com/SourceControl/network/forks/electricessence/revisions

The app is called MiosConsole and can take commands directly as parameters or it will parse commands in a console mode if run without parameters.

This then allows me to create shortcuts for the desktop (or a toolbar) that send Vera commands to alter device states or launch scenes.
Example usage:
>MiosConsole -h [ipaddress]:3480 -d [id] -x /toggle

You can of course type MiosConsole /? to get more information.
If you type MiosConsole<enter> it will continue to accept commands until you type exit.

Enjoy.  Critiques, opinions, advice, info, bug details, are all welcome.  It's an open source world. :)

And... of course a HUGE thanks to Ercant who really did something impressive here.  Exposing the API in an auto generated way along with some useful methods that really expose the Luup API as it is. 

Offline electricessence

  • Sr. Member
  • ****
  • Posts: 251
  • Karma: +0/-0
Re: .NET (C#) Library for Vera
« Reply #6 on: April 26, 2014, 02:31:17 am »
One thing Ercant.  I've commented on codeplex in the discussion areas.  I've run into a few bugs...
Mainly, that SCamera1 is sending a string back as "m" when it's expecting something else.
Secondly, there's another case where I'm seeing 'floats' or 'doubles' but it thinks it should be an UInt32.  Please see the details.  I'd like to get that fixed so I can use your core DLL instead of my revised version.

Offline wessiack

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Re: .NET (C#) Library for Vera
« Reply #7 on: December 03, 2014, 02:15:30 am »
Hi Ercan!

Great Lib!!

Is it possible to do the mms authentication against the MCV secure servers so that i can use the library when i'm not in the local LAN?

:: Paul

Offline konstsch

  • Sr. Newbie
  • *
  • Posts: 22
  • Karma: +0/-2
Re: .NET (C#) Library for Vera
« Reply #8 on: September 20, 2016, 01:46:07 am »
I try to use this lib.
I decide the problem with float ant int32.
But I have bigger problem.

I try to know status all binarylight switches:

Code: [Select]
var miosData = new SummaryData(miosEngine);

foreach (MiosDevice element in miosData.Engine.Devices)
        {
            if (element.DeviceType == "urn:schemas-upnp-org:device:BinaryLight:1")
            {
                var a = (BinaryLight1)element;
                Console.WriteLine(String.Format("Switch: {0}, {1}", a.SSwitchPower1.Status, element.Name));
            }
        }

I see that this code:
Code: [Select]
Console.WriteLine(String.Format("Switch: {0}, {1}", a.SSwitchPower1.Status, element.Name));every time create http request to the controller or to the mios server, but I had alredy get this data before:
Code: [Select]
var miosData = new SummaryData(miosEngine);
How can I know all switchces status via only one request to the controller?
« Last Edit: September 20, 2016, 03:01:06 am by konstsch »