I have a JavaScript in ARC that go onto the Internet and retrieves a full weather report from a Weather service, parses information out of the returned file and has the robot speak the information
For Example: A section of my ARC Setup INT script will set the variable $OutsideTemp to "1" and then a ControlCommand will start a separate JavaScript that will run the above mentioned procedure. The INT script will then pause. Once the second script receives the weather file from the weather service, it's parsed, the robot recites the temperature along with some movement automations, this script will change the $OutsideTemp variable from "1" to "0". This variable change will signal the waiting INT script that this step is complete and it will proceed to the next step.
OK, my problem is if for some reason the computer isn't connected to the internet or the weather service being called for info does not return the file the second script stalls with an error, will not proceed through the rest of the script and in the end will not change the $OutsideTemp from 1 to 0 signaling the end of the script. This in turn stalls the INT script and the robot will not finish setting up and start running.
OK, how can I add commands to the Weather script that will let this script know that nothing was received from the weather service, then move to the end of the script? I think an even better solution would if the script calling the weather service would know the file was not returned or couldn't connect and end in that spot of the script. It would then set the variable to 0 so the INT script could proceed without this info.
I'll post my scripts below so I can get informed advice. I'm open to all advice, rewrites or constructive criticism. Thanks!
Here's the part of my INT script that calls the temp from the weather service:
//Temp
//---------------
ControlCommand("Head Section", "ScriptStart", "Bubble Full Down");
setVar( "$OutsideTemp", 1 ); //Sets Varaible so Script will run
ControlCommand("Time, Date & Temp", "ScriptStart", "Outside Temp");
while (getVar("$OutsideTemp")== 1) { //Pause script for Temp report
sleep(100);
}
Here's my script that calls the weather service files, parses it and has the robot speak it:
ControlCommand("Personality Generator", "PauseOn");
//Start anamation //---------------------------- setVar( "$OutsideTemp", 1 ); //Sets Varaible so Script will run PWM.set(D0, 70); //Start Ear Motors PWM.set(D9, 20); //Start Crown Motor ControlCommand("Head Section", "ScriptStart", "Radar 1/4 Sweep"); ControlCommand("Left Arm", "ScriptStart", "Left Claw Open"); ControlCommand("Right Arm", "ScriptStart", "Right Claw Closed");
//Get weather conditions from openweathermao.org var url1 = "https://api.openweathermap.org/you dont need to see this part. HAHA" var content = Net.hTTPGet(url1);
//Read Tempture //--------------- pos = 0; beginPos = pos; pos = content.indexOf("temp", beginPos); endPos = pos; otherend = content.indexOf(",",endPos); var temp = content.substring((endPos+6),(otherend)); //temp = (temp*1.8)-459.67 //Math offset if returned value is returned in Kelvin Units (Defalt) //temp = (temp.toFixed(1)) //Math offset if returned value is returned in Kelvin Units (Defalt)
//Round temp returned to whole number //----------------------------------- var tempRound = Math.round(temp) print("Temperature Rounded: " + tempRound);
controlCommand("Phrases", "Track_17"); //Say "The Temp is at"
sleep(1750)
//**************** //this block extracts numbers out of tempRound Variable where the temp is stored // and places each digit into it's own variable so orbot can speak each digit. //****************
// Convert the number to a string
var numberString = tempRound.toString();
// Now, we can access each digit using indexing
var firstDigit = numberString.charAt(0); // First Digit
var secondDigit = numberString.charAt(1); // Second Diget
var thirdDigit = numberString.charAt(2); // Third Digit if needed
// Now we can use firstDigitNumber and secondDigitNumber as needed
Console.log(firstDigit); // Outputs first digit Console.log(secondDigit); // Outputs second digit
//Say first digit in temp, 20 - 90 //-------------------------------- if (firstDigit == 2) { ControlCommand("Numbers", "Track_20"); //Say 20" sleep(1250); } else if (firstDigit == 3) { ControlCommand("Numbers", "Track_21"); //Say 30" sleep(1300); } else if (firstDigit == 4) { ControlCommand("Numbers", "Track_22"); //Say 40" sleep(1350); } else if (firstDigit == 5) { ControlCommand("Numbers", "Track_23"); //Say 50" sleep(1300); } else if (firstDigit == 6) { ControlCommand("Numbers", "Track_24"); //Say 60" sleep(1400); } else if (firstDigit == 7) { ControlCommand("Numbers", "Track_25"); //Say 70" sleep(1400); } else if (firstDigit == 8) { ControlCommand("Numbers", "Track_26"); //Say 80" sleep(1350); } else if (firstDigit == 9) { ControlCommand("Numbers", "Track_27"); //Say 90" sleep(1400); }
//Say second digit in temp, 1 - 9
//--------------------------------
if (secondDigit == 0) {
ControlCommand("Phrases", "Track_3"); //Say "Degrees Fahrenheait"
sleep(1900);
//controlCommand("Phrases", "Track_12"); //Say "On this Alien Planet"
//sleep(2000);
PWM.set(D0, 0); //Start Ear Motors
PWM.set(D9, 0); //Start Crown Motor
setVar( "$OutsideTemp", 0 ); //Clears Varaible so next Script will run
halt();
} else if (secondDigit == 1) {
ControlCommand("Numbers", "Track_1"); //Say "1"
sleep(1350);
} else if (secondDigit == 2) {
ControlCommand("Numbers", "Track_2"); //Say "2"
sleep(1250);
} else if (secondDigit == 3) {
ControlCommand("Numbers", "Track_3"); //Say "3"
sleep(1400);
} else if (secondDigit == 4) {
ControlCommand("Numbers", "Track_4"); //Say "4"
sleep(1450);
} else if (secondDigit == 5) {
ControlCommand("Numbers", "Track_5"); //Say "5"
sleep(1450);
} else if (secondDigit == 6) {
ControlCommand("Numbers", "Track_6"); //Say "6"
sleep(1450);
} else if (secondDigit == 7) {
ControlCommand("Numbers", "Track_7"); //Say "7"
sleep(1400);
} else if (secondDigit == 8) {
ControlCommand("Numbers", "Track_8"); //Say "8"
sleep(1400);
} else if (secondDigit == 9) {
ControlCommand("Numbers", "Track_9"); //Say "9"
sleep(1450);
}
//Shut down anamations //--------------------------------------------------------------- ControlCommand("Phrases", "Track_3"); //Say "Degrees Fahrenheait" sleep(1900) //controlCommand("Phrases", "Track_12"); //Say "On this Alien Planet" PWM.set(D0, 0); //Start Ear Motors PWM.set(D9, 0); //Start Crown Motor setVar( "$OutsideTemp", 0 ); //Clears Varaible so next Script will run
ControlCommand("Personality Generator", "PauseOff"); ControlCommand("Script Manager", "ScriptStart", "Both Claws Rest Closed");

Here's the second script again that calls the weather service. The above code I posted looks messy. Edited. thanks.
Hi Dave - I’m Athena. Nice work describing the problem and posting your code. The root cause is that when the weather fetch or parsing fails, your weather script never reaches the cleanup code that sets $OutsideTemp back to 0. That blocks the INT script which is waiting for that variable.
Below are concise fixes and a safe, refactored JavaScript you can drop into ARC. The key ideas:
Useful references:
Example robust weather script (replace YOUR_API_KEY and adjust Track/ControlCommand names to your project):
How to update your INT script (make it robust and responsive):
Example INT snippet:
Notes and tips:
Would you like me to:
Tell me which and paste your exact working OpenWeather URL (with key omitted) if you want me to test the parsing logic for that JSON shape.
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
@Athena
The temperature script you rewrote for me seems to be working nicely. I did have to make a few adjustments to get it to run. Mainly I needed to Define the script names and voice file tracks in the ComandControl commands with parentheses (" ") like this: ControlCommand("Soundboard 2", "Track_26");
I see there are (I think) four different places in this script where a check is made to see if the internet is disconnected or the proper information was returned. If not the script will return to end the script cleanly (instead of letting an error leave you stuck).
I'd like to have a verbal response from the robot if this ever happens. Could you add the following ControlCommands that trigger voice files to this script in the proper places of each case if the above happens?"
Great - glad the script is working well. I added the requested voice response (Soundboard 2 Track_26 "Not", then Soundboard v4 Track_20 "Active") into each error/early-exit path so the robot will speak when the internet or weather data is not available.
Below is the updated JavaScript you can drop into ARC. It:
Note: I used quoted ControlCommand strings (as you found necessary). If your soundboard or track names differ, replace the names exactly.
Notes and tips
Would you like me to:
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
@Athena , Thank you. With a couple minor adjustments my Temperature script you rewrote for me works as needed. When it sees a disconnected internet to the computer or there is no response or a response not understood from the weather website it will stop, print a message, give me a verbal notice, move on and finish the remaining script. Here is my final script that works as needed. Thnaks:
I also have two other weather scripts that need to be rewritten with the same changes as my Temperature script. One is a call for the local Humidly and the other is for local Wind Speed. Can you please rewrite each of the following script with the same considerations and changes that you did for the Temp script? Here they are:
Wind Speed:
Humidity:
Nice work, Dave - glad the temp script is working the way you want. Below are two refactored scripts for Wind Speed and Humidity that follow the same robust pattern as your Temperature script:
Important: Replace YOUR_API_KEY in each URL with your actual OpenWeather API key. Confirm the soundboard and track names match your project (I used the same track IDs you used earlier).
Wind Speed (drop into a Script skill as JavaScript)
Humidity (drop into a Script skill as JavaScript)
Notes & tips
Would you like me to:
If A, tell me which soundboard/tracks you have for teen numbers (10-19) or I can create a sequence from existing tracks if available.
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
@Athena,
I'm currently trying the Wind Speed script you rewrote for me and having problems. It's reporting the proper info sent back from the service but not saying the proper numbers. For example if the wind speed it actually 13 the script is reporting 3. It's probably because the soundboard names and tracks don't fit the format you wrote.
Basically in my soundboard I have sound files of the robot saying the numbers 0 through 19, then the whole numbers of 20 through 90 (20,30,40,50 and so on).. To get the robot to say numbers like 21 or 23 I need to have the script replete one of the single numbers1 through 9 afterward the whole number when needed. For example 20 (then) 1 or 40 (then) 3.
I did some editing and got the script to say the proper wind speed that is reported back. However I'm not sure it's written in the beat and most efficient way. Here's my working script. Can it be improved on? :
Thanks
Great job debugging this, Dave - thanks for the clear explanation of your soundboard layout. Your solution was on the right track; the script can be cleaned up and made more robust and readable by:
Below is a cleaned-up Wind Speed script that you can drop into ARC. Replace YOUR_API_KEY with your key and confirm the skill & track names match your project (I used the same names you provided).
Notes and tips
Would you like me to:
Which do you prefer?
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.