Community Blog Buy Now
Blog

Misty Community Forum

misty.Get("key") not working in JS other skill

Hello, I am having a problem using misty.Get in a 2nd running skill. Skills code below.

–testSet.js–

_loopTest = 0;
misty.Set("test", 0, false);
misty.Pause(100);
misty.RunSkill("49a5e29b-551f-4d1d-bafb-78cd638a37be");

misty.RegisterTimerEvent("TimerEvent", 2000, true);

// TimerEvent callback
function _TimerEvent() {
    _loopTest += 10;
    misty.Set("test", _loopTest, false);

    misty.Debug(`testSet.js data _loopTest = ${_loopTest}, misty.Set(test) = ${misty.Get("test")}`); //This works
};

–testSet.json–

{
  "Name": "testSet",
  "UniqueId": "62901e3a-2937-4064-894d-5c69e11f9442",
  "Description": "My skill is amazing!",
  "StartupRules": [
    "Manual",
    "Robot"
  ],
  "Language": "javascript",
  "BroadcastMode": "debug",
  "TimeoutInSeconds": 600,
  "CleanupOnCancel": true,
  "WriteToLog": false,
  "Parameters": {
    "int": 10,
    "double": 20.5,
    "string": "twenty"
  },
  "ReadPermissions": [
    "49a5e29b-551f-4d1d-bafb-78cd638a37be"
  ],
  "WritePermissions": [
    "49a5e29b-551f-4d1d-bafb-78cd638a37be"
  ]
}

–testGet.js–

misty.Pause(250);
misty.RegisterTimerEvent("TimerEvent", 2000, true);

// TimerEvent callback
function _TimerEvent() {
    misty.Debug(`**testGet.js data misty.Set(test) = ${misty.Get("test")}`);
};

–testGet.json–

{
  "Name": "testGet",
  "UniqueId": "49a5e29b-551f-4d1d-bafb-78cd638a37be",
  "Description": "My skill is amazing!",
  "StartupRules": [
    "Manual",
    "Robot"
  ],
  "Language": "javascript",
  "BroadcastMode": "verbose",
  "TimeoutInSeconds": 600,
  "CleanupOnCancel": true,
  "WriteToLog": false,
  "Parameters": {
    "int": 10,
    "double": 20.5,
    "string": "twenty"
  }
}

Debug from misty.Get("test") in testGet.js is

{"Language":null,"Message":"Failed to get store data using key 'test' and skill namespace '49a5e29b-551f-4d1d-bafb-78cd638a37be'","Details":null}

Any suggestions?
Thanks
Jeff

Hey, @2Alpha – thanks for the question.

I spent a few minutes digging into this and it looks like we have a documentation gap around sharing data across skills. The misty.Get method takes an undocumented second argument, skillUniqueId, which (I assume) indicates which skill to “read” the shared data from.

Here’s my understanding: by default, when you call the misty.Get method, the skill attempts to read from the stored data written by the skill from which the method was called. I think that’s why you’re seeing the “failed to get data” message associated with the “namespace” for the Unique ID of the testGet skill. Try updating your testGet.js skill code to include a second argument of the skill ID for the testSet skill when you call misty.Get (like this):

misty.Pause(250);
misty.RegisterTimerEvent("TimerEvent", 2000, true);

// TimerEvent callback
function _TimerEvent() {
    misty.Debug(`**testGet.js data misty.Set(test) = ${misty.Get("test", "62901e3a-2937-4064-894d-5c69e11f9442")}`);
};

It looks like the misty.Set method has an undocumented skillUniqueId argument, too, which I assume you can use to “write” data to another skill’s pool of stored data. I’ll do some more research on this and we’ll update the documentation ASAP. I’m sorry for the confusion, and thanks very much for helping us find the gap!

Works like a charm. Awesome Sauce!

I tested the misty.Set command in the secondary skill.


function _TimerEvent() {
    _loopTest += 10;
    misty.Set("test", _loopTest, false, "62901e3a-2937-4064-894d-5c69e11f9442");
};

I then changed the primary skill to:


function _TimerEvent() {
    misty.Debug(`testSet.js data misty.Set(test) = ${misty.Get("test")}`);
};

That worked also.

Thanks for the speedy solution. I emailed before I went to work and had it working 10 minutes after I got home.

Thanks
Jeff

2 Likes

Glad to hear it!

The documentation should be accurate now. Let us know if anything is unclear or if you run into other issues. We have a few updates related to sharing skill data planned for Misty’s next system update :robot: