Created
November 21, 2019 07:42
-
-
Save sunnyeyez123/f4dd5db9fbce47534132a4aa6d2884c3 to your computer and use it in GitHub Desktop.
Triggering a Misty Skill using the bump sensors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
misty.Debug("Starting my skill"); | |
let yesnoURL = "https://yesno.wtf/api" | |
// Parse the response data to get the current condition in _params.city | |
// and print this in a string to the dev console in the Skill Runner | |
// web page. | |
function _SendExternalRequest(data) { | |
_data = JSON.parse(data.Result.ResponseObject.Data) | |
_answer = _data.answer.toLowerCase(); | |
_image = _data.image; | |
misty.Debug("Misty here! Just letting you know the answer is " + _answer); | |
misty.ChangeLED(100, 70, 160); | |
// misty.DisplayImage(_image); | |
misty.PlayAudio("s_Disapproval.wav"); | |
if(_answer == "yes"){ | |
misty.Debug("Said Yes"); | |
yesColor(); | |
}else if (_answer == "no"){ | |
misty.Debug("Said No"); | |
noColor(); | |
} | |
misty.Pause(10000); | |
misty.DisplayImage("e_DefaultContent.jpg", 1); | |
} | |
misty.AddPropertyTest("BumpSensor", "isContacted", "==", true, "boolean"); | |
misty.AddReturnProperty("BumpSensor", "sensorName"); | |
misty.RegisterEvent("checkWeather", "BumpSensor", 200, true); | |
function _checkWeather(data) { | |
misty.SendExternalRequest( "GET",yesnoURL); | |
} | |
function yesColor(){ | |
misty.ChangeLED(0, 250, 35); | |
misty.DisplayImage("e_Joy.jpg"); | |
} | |
function noColor(){ | |
misty.ChangeLED(250, 55, 28); | |
misty.DisplayImage("e_Anger.jpg"); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Name": "YesNo_ExternalRequest", | |
"UniqueId": "4825015d-1d56-4ae6-b997-e5757861d0a8", | |
"Description": "Displays the answer from yes no site.", | |
"StartupRules": [ | |
"Manual", | |
"Robot" | |
], | |
"Language": "javascript", | |
"BroadcastMode": "verbose", | |
"TimeoutInSeconds": 31540000, | |
"CleanupOnCancel": false, | |
"WriteToLog": false, | |
"Parameters": { | |
"int": 10, | |
"double": 20.5, | |
"string": "twenty" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment