Originally posted by dmurphy
View Post
Announcement
Collapse
No announcement yet.
plugextradata - errors retreiving 'SOME' data - no issues setting data
Collapse
X
-
This works thanks spud - addNamed and getNamed have issues.
Code:Dictionary<string, string> changes = new Dictionary<string, string>(); changes.Add("libver", "2.3"); changes.Add("libver1", "2.3.2"); changes.Add("sketch", "Kitchen Monitor"); PlugExtraData ped = dev.PlugExtraData; foreach (KeyValuePair<string, string> change in changes) { //ped.AddNamed(change.Key, change.Value); ped[change.Key] = change.Value; } Hs.UpdatePropertyByRef(refId, EProperty.PlugExtraData, ped); AbstractHsDevice updatedDev = Hs.GetDeviceByRef(refId); PlugExtraData updatedPed = updatedDev.PlugExtraData; string libver = updatedPed["libver"]; string libver1 = updatedPed["libver1"]; string sketch = updatedPed["sketch"];
Leave a comment:
-
Originally posted by alexbk66 View PostThe syntax of your dictionary initialiser looks strange, should id simply be just
seemingly the dictionary initializer was updated in c# 6.....so either variant should work...
https://visualstudiomagazine.com/Blo...tializers.aspx
Leave a comment:
-
Yep, can reproduce the problem. They trim quotes from json string, so JsonConvert becomes confused. WTH???
BTW, that's the reason I always use SDK code, not prebuilt library - so I can debug this mess.
So I guess it's https://github.com/HomeSeer/Plugin-SDK/issues
Leave a comment:
-
I created a test with least amount of code.
Code:Dictionary<string, string> changes = new Dictionary<string, string>(); changes.Add("libver", "2.3"); changes.Add("libver1", "2.3.2"); PlugExtraData ped = dev.PlugExtraData; foreach (KeyValuePair<string, string> change in changes) { ped.AddNamed(change.Key, change.Value); } Hs.UpdatePropertyByRef(refId, EProperty.PlugExtraData, ped); AbstractHsDevice updatedDev = Hs.GetDeviceByRef(refId); PlugExtraData updatedPed = updatedDev.PlugExtraData; string libver = updatedPed.GetNamed<string>("libver"); //This works returns "2.3" as expected. string libver1 = updatedPed.GetNamed<string>("libver1"); // This throws exception previously noted....I'm using strings not numbers....
Leave a comment:
-
What's your object class definition you are trying to Deserialise? Obviously it expects a number (float, which 2.3 is) - but "2.3.2" is not a number - it's a string.
Leave a comment:
-
So I simplified the code......
Code:Dictionary<string, string> peds = new Dictionary<string, string>(); peds.Add("libver", "2.3.2");
+ $exception {"Input string '2.3.2' is not a valid number. Path '', line 1, position 5."} Newtonsoft.Json.JsonReaderException
BUT if I change the 2.3.2 to 2.3 everything is fine?????? Funny the string is being treated as a number?
The PED data returned from HS looks fine, but the sdk GetNamed function throws an error (see pic)
Leave a comment:
-
The syntax of your dictionary initialiser looks strange, should id simply be just
Code:Dictionary<string, string> peds = new Dictionary<string, string>() { {"nodeid", "10"}, {"childid", "1"}, };
Leave a comment:
-
plugextradata - errors retreiving 'SOME' data - no issues setting data
So I store a bunch of PED info.
Code:Dictionary<string, string> peds = new Dictionary<string, string>() { ["nodeid"] = "10", ["childid"] = "1", ["sketch"] = "kitchen monitor", ["libver"] = "2.3", ["sketchver"] = "0.6", ["heartbeat"] = "94129", ["config"] = "Imperial" };
it fails on the string "2.3.2" but "2.3" works fine....are there restrictions on what can be in a string for a PED? is it documented somewhere.Tags: None
Leave a comment: