Possible bug in /api/updatedevicemetadata

kmeurer
Posts: 18
Joined: Thu Sep 10, 2015 9:28 pm
Location: Oregon
Contact:

Possible bug in /api/updatedevicemetadata

Postby kmeurer » Fri Sep 11, 2015 4:35 pm

Hi,

Working through the API, and I can't get UpdateDeviceMetaData to work. It returns success, but does not change the name or location.

Thanks for the help on this. The API is very nice to use.

Code: Select all

using System;
using System.Net;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

class MainClass
{
   const string zcommandUrl = "https://192.168.2.160";

   public static int Main(string[] args)
   {
      // this is to allow the default certificate on the ZCommand module to pass. otherwise we'll keep getting exceptions.
      ServicePointManager.ServerCertificateValidationCallback
         = ((sender, cert, chain, errors) => cert.Subject.ToLower().Contains("zcommand"));

      WebClient ZCommandWebClient = GetAuthenticatedWebClient();
      var form = JsonConvert.SerializeObject(new { name = "Office Tester", location = "In the Office" });
      var response = ZCommandWebClient.UploadString(string.Format("{0}/api/updatedevicemetadata/4", zcommandUrl), form);

      Console.WriteLine("Response: {0}", response);
      Console.ReadLine();

      return 0;
   }

   private static WebClient GetAuthenticatedWebClient()
   {
      WebClient webClient = new WebClient();
      webClient.Headers.Set(HttpRequestHeader.UserAgent, "zcommand");

      var form = JsonConvert.SerializeObject(new { Username = "admin", Password = "admin" });
      var response = webClient.UploadString(zcommandUrl + "/api/tokenauth", form);
      var obj = JObject.Parse(response);

      webClient = createAuthorizedWebClient(obj["responseObject"].ToString());
      return webClient;
   }

   private static WebClient createAuthorizedWebClient(string token)
   {
      WebClient webClient = new WebClient();
      webClient.Headers.Set(HttpRequestHeader.UserAgent, "zcommand");
      webClient.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
      webClient.Headers.Add(HttpRequestHeader.Authorization, "Token " + token);
      return webClient;
   }

}

admin
Site Admin
Posts: 50
Joined: Sun Dec 14, 2014 2:05 pm
Location: Washington
Contact:

Re: Possible bug in /api/updatedevicemetadata

Postby admin » Mon Sep 14, 2015 6:16 pm

Can you post the complete response?

kmeurer
Posts: 18
Joined: Thu Sep 10, 2015 9:28 pm
Location: Oregon
Contact:

Re: Possible bug in /api/updatedevicemetadata

Postby kmeurer » Mon Sep 14, 2015 6:43 pm

It appears to have been accepted, but it does not make the change. I can change it with the admin panel just fine.

Code: Select all

{
   "isSuccess":true,
   "message":null,
   "responseObject": {
                  "cssClass":"zwavedevice device has-level listening  binary-level switch binary-switch",
                  "isLevelBinary":true,
                  "userSelectedMinLevelForDisplay":null,
                  "userSelectedMaxLevelForDisplay":null,
                  "level":0,
                  "minLevelForDisplay":0,
                  "maxLevelForDisplay":255,
                  "lastHeard":"2015-09-14T18:35:20.1596570-07:00",
                  "queuedCommandsCount":0,
                  "wakeupInterval":-1,
                  "isSecure":false,
                  "nodeId":"4",
                  "nodeId2":"4",
                  "deviceType":"On/Off Power Switch Device Type",
                  "name":"Office Test",
                  "location":"Office",
                  "typeString":"com.Intulon.ZCommand.Models.ZWave.BinarySwitch",
                  "deviceSignature":"008600030006",
                  "associations":[],
                  "deviceModel":"Aeon Labs DSC06106-ZWUS Binary Switch"
                 },
   "responseObject2":null,
   "responseObject3":null
}

admin
Site Admin
Posts: 50
Joined: Sun Dec 14, 2014 2:05 pm
Location: Washington
Contact:

Re: Possible bug in /api/updatedevicemetadata

Postby admin » Sun Nov 15, 2015 11:06 am

This issue has been resolved in the latest release of Z-Command.
https://z-command.intulon.com/version-1-1-7024/


Return to “Bug report”

Who is online

Users browsing this forum: No registered users and 0 guests

cron