SDK? C#?

Hello

Is there an SDK that will allow me to create a basic c# app to controll my z-wave devices? I don’t want to do anything crazy/fancy…mostly just want to play around - lights on/lights off.
BTW: My coding skills are super rusty.

Thanks in advance.

All Z-Wave devices connected to your Vera can be controlled via UPnP and HTTP.

For low level Z-Wave programming: ThinkEssentials

You can control Vera through web requests. In C# that means you can use WebClient to make those.

static void DoGet(string URL)
{
WebClient c = new WebClient();
byte[] response = c.DownloadData(URL);
}

Now you can interact with Vera like this:

DoGet(“http://192.168.1.200/data_request?id=lu_action&output_format=xml&DeviceNum=9&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1”);

Search for data_request on this forum and the wiki for some other examples.

Now I know about the SDK etc. I will dig around for more examples. Maybe I will be able to figure something out. Thanks for pointing me in the right direction.

http://wiki.micasaverde.com/index.php/Luup_Scenes_Events

Thanks. I was able to create a simple little app to do mostly what I wanted by doing the following.
private void LibraryLamp_CheckedChanged(object sender, EventArgs e)
{
if (LibraryLamp.Checked.Equals(true))
{
Uri myUriOn = new Uri(“http://10.10.1.100:3480/data_request?id=lu_action&output_format=xml&DeviceNum=9&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1”);
WebRequest myWebRequest = WebRequest.Create(myUriOn);
WebResponse myWebResponse = myWebRequest.GetResponse();
myWebResponse.Close();
}
else
{
Uri myUriOff = new Uri(“http://10.10.1.100:3480/data_request?id=lu_action&output_format=xml&DeviceNum=9&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0”);
WebRequest myWebRequestOff = WebRequest.Create(myUriOff);
WebResponse myWebResponseOff = myWebRequestOff.GetResponse();
myWebResponseOff.Close();
}

    }

Now I am trying to determine the status of the lights when the app loads. I have tried and tried to do it by looking at the XML data. I probably have 50 IE tabs open to different XML docs and articles and no joy.
I am able to access the XML info but I can’t search it. It is driving me crazy. LOL. I am not a real programming and the XML learning curve is pretty high. Is there another way to get device status without parsing the XML? My guess is no…

Thanks

I just found this in the doc that I was already referred to…
variableset

http://ip:3480/data_request?id=variableset&DeviceNum=6&serviceId=urn:micasaverde-com:serviceId:DoorLock1&Variable=Status&Value=1

If you leave off the DeviceNum and serviceID, then this sets a top-level json tag called “Variable” with the value.

variableget

http://ip:3480/data_request?id=variableget&DeviceNum=6&serviceId=urn:micasaverde-com:serviceId:DoorLock1&Variable=Status

If you leave off the DeviceNum and serviceID, then this gets a top-level json tag called “Variable”.

Should the Variableget work? I will test that later today.

Glad to see you made some progress and came up with something. Are you able to use json parsing in c#? This is the default of what vera uses as xml requires additional cpu time to process. So for your url you would use:

http://10.10.1.100:3480/data_request?id=lu_action&output_format=json&DeviceNum=9&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1

You would substitute the output_format=xml with output_format=json

If you feel like giving json parsing a try (should be easier to read and understand) use the following:

http://ip:3480/data_request?id=lu_sdata

Here is a link for a good read on communicating with vera:

http://wiki.micasaverde.com/index.php/UI_Simple

I think there is a way of getting a status of a device via http request. Hopefully someone can chime in here and provide an answer. I know you can get the status via luup code, I do not see why you can not via http request.

  • Garrett

[quote=“digitalgun, post:7, topic:168834”]I just found this in the doc that I was already referred to…
variableset

http://ip:3480/data_request?id=variableset&DeviceNum=6&serviceId=urn:micasaverde-com:serviceId:DoorLock1&Variable=Status&Value=1

If you leave off the DeviceNum and serviceID, then this sets a top-level json tag called “Variable” with the value.

variableget

http://ip:3480/data_request?id=variableget&DeviceNum=6&serviceId=urn:micasaverde-com:serviceId:DoorLock1&Variable=Status

If you leave off the DeviceNum and serviceID, then this gets a top-level json tag called “Variable”.

Should the Variableget work? I will test that later today. [/quote]

I tried this before replying and I got an error. I had the same assumption as you did.

  • Garrett

Here is your answer:

This will get the status of your doorlock:

http://ip:3480/data_request?id=lu_variableget&serviceId=urn:micasaverde-com:serviceId:DoorLock1&Variable=Status&DeviceNum=27

This will get status of a light switch:

http://ip:3480/data_request?id=lu_variableget&serviceId=urn:upnp-org:serviceId:SwitchPower1&Variable=Status&DeviceNum=7

This will get the status of a dimmable light:

http://ip:3480/data_request?id=lu_variableget&serviceId=urn:upnp-org:serviceId:Dimming1&Variable=LoadLevelStatus&DeviceNum=20

Substitute DeviceNum with your id of your device. And the ip with your ip.

  • Garrett

Thanks Garrett!! I think this might do the trick. I was just able to use the HTTP links to query one of my lamps and get the proper response code in C#. Now I am off to integrate it into my app. Maybe at a later date I will look at Json if I decide to do something more difficult.

Thanks!

Fantastic Garret/digitalgun.

So this seem to work: Get Status
http://myhome:3480/data_request?id=lu_variableget&serviceId=urn:upnp-org:serviceId:Dimming1&Variable=LoadLevelStatus&DeviceNum=8

What about Setting?
For instance I tried this:

http://myhome:3480/data_request?id=lu_action&serviceId=urn:upnp-org:serviceId:Dimming1&DeviceNum=8&action=SetTarget&newTargetValue=1

I’m assuming the culprit is the action I’m using for the Dimmable switch - Where did you guys find the ref docs for this? Any help would be appreciated :slight_smile:

BTW the response I get is the following:
ERROR: Device does not handle service/action

This should be:

http://vera.lan:3480/data_request?id=lu_action&DeviceNum=8&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget=

Where is between 0 (off) and 100 (fully on).

You can find this by going to “Mios Developers” → “Luup Files” tag → view “S_Dimming1.xml”

Then look at the tags. Hope that makes sense? You might have to poke around yourself a little bit. :slight_smile:

@radarengineer: Thanks :slight_smile: Worked like a charm!! here’s the response I got.

<u:SetLoadLevelTargetResponse xmlns:u=“urn:schemas-upnp-org:service:Dimming:1”>
299
</u:SetLoadLevelTargetResponse>

I was wanting to Parse Vera’s user Data to be loadable as .NET Dataset - this is what I came up with…Any inputs please?

[url=http://wiki.micasaverde.com/index.php/Parsing_Vera_User_Data_-_Loadable_as_.NET_Dataset]http://wiki.micasaverde.com/index.php/Parsing_Vera_User_Data_-_Loadable_as_.NET_Dataset[/url]