LOGIN  |  REGISTER
Smart Living Made Brilliant!
CASTLEOS FORUM

eahillen

all messages by user

5/10/2015
Topic:
help with my morning wake up weather script

Eric Hillen
Eric Hillen
Hello all,

I know this isn't a program question, its about a script to run so i was hoping some fellow users may have some insight. I am trying to get a script to run every morning that will give me the forecast for the day. with that being said I know nothing about scripting other than what I have learned from other users, youtube tutorials, and stuff from the code forums.

attached below is what I started piecing together, borrowed, and stole... its not finished but i have no idea where to get it going from here.



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
using System.IO;
using System.Web;
using System.Speech.Recognition;
using System.Speech.Synthesis;

namespace WeatherAlarm
{
}


Speechsythensiser WHAT DO I PUT HERE? = new Speechsynthesizer(); <---- so confused....


{
public partial class Form1 : Form
{

string Temperature;
string Condition;
string Humidity;
string WindSpeed;
string Town;
string TFCond;
string TFHigh;
string TFLow;


public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

void _recognizer_SpeechRecognizer(object sender, EventArgs e)
{
string speech = e.Result.Text;
switch (speech)
{
case " ":
GetWeather();
SOMETHING? .Speak("The weather in " + Town + " is " + Condition + " at " + Temperature + " degrees. ",... finish this later)


}
}
private void GetWeather()
{

string query = String.Format("http://weather.yahooapis.com/forecastrss?w=23424583");
XmlDocument wData = new XmlDocument();
wData.Load(query);

XmlNamespaceManager manager = new XmlNamespaceManager (wData.NameTable);
manager.AddNamespace("yweather", "http://xml.weather.yahoo.com/ns/rss/1.0");

XmlNode channel = wData.SelectSingleNode("rss").SelectSingleNode("channel");
XmlNodeList node = wData.SelectNodes("/rss/channel/item/yweather:forecastr", manager);

Temperature = channel.SelectSingleNode("item").SelectSingleNode("yweather:condition", manager).Attributes["temp"].Value;

Condition = channel.SelectSingleNode("item").SelectSingleNode("yweather:condition", manager).Attributes["text"].Value;

Humidity = channel.SelectSingleNode("yweather:atmosphere", manager).Attributes[Humidity].Value;

WindSpeed = channel.SelectSingleNode("yweather:wing", manager).Attributes["speed"].Value;

Town = channel.SelectSingleNode("yweather:location", manager).Attributes["city"].Value;

TFCond = channel.SelectSingleNode("item").SelectSingleNode("yweather:forecast", manager).Attributes["text"].Value;

TFHigh = channel.SelectSingleNode("item").SelectSingleNode("yweather:forecast", manager).Attributes["high"].Value;

TFLow = channel.SelectSingleNode("item").SelectSingleNode("yweather:forecast", manager).Attributes["low"].Value;





}



}
5/15/2015
Topic:
help with my morning wake up weather script

Eric Hillen
Eric Hillen
Thanks for the reply chris- as I know my question is not a castle's question and has nothing to do with your software and is strictly C#. I am trying to get the weather forecast as a "alarm" to wake up when my lights turn on.
5/16/2015
Topic:
help with my morning wake up weather script

Eric Hillen
Eric Hillen
Sure,

Right now I have reoccurring events set up Monday - Friday for 3 different zones (my room and my kids rooms). When the event trip each different zone has its own custom voice announcement along with the lights turning on, reminding my son to take the trash out or my daughter she has softball practice that day, etc etc. I would like to run a script triggered every morning so it will automatically read the forecast for that day also. I know I can just ask the computer for the weather but I never remember until I'm getting out of the shower and have to check my iPhone for the day real quick in the bathroom. I live in NC and this time of year it can be monsoons one day and a breezy 70 the next.
5/16/2015
Topic:
help with my morning wake up weather script

Eric Hillen
Eric Hillen
so basically the "event" would trigger the voice announcment to say the basic daily reminders for the specific zone then would execute the script that would read the daily forecast, which I was originally trying to pull from yahoo's developer weatherAPI.
5/25/2015
Topic:
help with my morning wake up weather script

Eric Hillen
Eric Hillen
Yes exactly! I won't use it to chase hot liberals out of my bed though.
6/21/2015
Topic:
help with my morning wake up weather script

Eric Hillen
Eric Hillen
Hey Chris,

No I haven't haven't had a chance I get it going. I have been out if the country and the software (trail version) expired. I'll tell you what help me make it work and I'll buy the program! I'm kidding I'll buy it anyway, thanks for the follow up though I do appreciate the software and the time you put into helping the consumers out! Eric
6/23/2015
Topic:
help with my morning wake up weather script

Eric Hillen
Eric Hillen
Hey Chris, That's awesome with the 10 devices now! I'm back in the states and downloading the new version now.

As for the script I'm working on I am still stuck and not really sure where to go next. If you don't mind taking a look at it again and seeing what I'm jacked up on that would be much appreciated! I know you're busy as hell man so if not no worries I'll still buy the software 😜
6/29/2015
Topic:
help with my morning wake up weather script

Eric Hillen
Eric Hillen
Paul- I will keep at it until I get it to work and post the final script on here. At this point I've spent to much time trying to learn this stuff to just drop it now.

Chris- couple of quick questions, 1st, do I have to use MSN? I don't care either way just curious if the software is made a certain way. 2nd, When i try and add a new even to see if the script will run I "Add Event" then set the time and select "Run Script" from the available actions menu. Once I add it in the "current actions" a "voice announcement" shows up. Is the a bug or am i missing how to direct the core services to the script file. I have the file saved in the core services folder since i am not trying to voice command run this script.

For anyone that is curious this is where I am at now. my trail of Visual Studio also expired so I've been working out of note pad so I'm sure its a bit sloppy.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
using System.IO;
using System.Web;
using CastleOSKinectService;
using System.Speech.Recognition;


namespace WeatherAlarm


{
public partial class Form1 : Form
{

public class MyScript
{
public void Main(string[] args)
{






string Temperature;
string Condition;
string Humidity;
string WindSpeed;
string Town;
string TFCond;
string TFHigh;
string TFLow;


public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

void _recognizer_SpeechRecognizer(object sender,

EventArgs e)
{
string speech = e.Result.Text;
switch (speech)
{
case " ":
GetWeather();


ScriptingAPI.Speak("The weather in " + Town + " is " +

Condition + " at " + Temperature + " degrees ");

}



}
private void GetWeather()
{

string query = String.Format

("http://weather.yahooapis.com/forecastrss?w=23424583");
XmlDocument wData = new XmlDocument();
wData.Load(query);

XmlNamespaceManager manager = new

XmlNamespaceManager (wData.NameTable);
manager.AddNamespace("yweather",

"http://xml.weather.yahoo.com/ns/rss/1.0");

XmlNode channel = wData.SelectSingleNode

("rss").SelectSingleNode("channel");
XmlNodeList node = wData.SelectNodes

("/rss/channel/item/yweather:forecastr", manager);

Temperature = channel.SelectSingleNode

("item").SelectSingleNode("yweather:condition",

manager).Attributes["temp"].Value;

Condition = channel.SelectSingleNode

("item").SelectSingleNode("yweather:condition",

manager).Attributes["text"].Value;

Humidity = channel.SelectSingleNode

("yweather:atmosphere", manager).Attributes

[Humidity].Value;

WindSpeed = channel.SelectSingleNode("yweather:wing",

manager).Attributes["speed"].Value;

Town = channel.SelectSingleNode("yweather:location",

manager).Attributes["city"].Value;

TFCond = channel.SelectSingleNode

("item").SelectSingleNode("yweather:forecast",

manager).Attributes["text"].Value;

TFHigh = channel.SelectSingleNode

("item").SelectSingleNode("yweather:forecast",

manager).Attributes["high"].Value;

TFLow = channel.SelectSingleNode

("item").SelectSingleNode("yweather:forecast",

manager).Attributes["low"].Value;





}



}
6/29/2015
Topic:
help with my morning wake up weather script

Eric Hillen
Eric Hillen
Thanks Phil, in my search for a new free C# builder I found the Visual Studio was free i just had to click Update license and it starts working again with no problems. It's great it highlights errors and tells me exactly whats wrong, Unfortunately I have no idea what 90% of these errors mean. I am like a monkey looking at a wrist watch...
7/2/2015
Topic:
help with my morning wake up weather script

Eric Hillen
Eric Hillen
Chris, So i think I got the script working, but when i go to core services to add it as an "event" when i click open .cs file it adds a "voice announcement" and does not let me find the .CS file. I am trying to run the script from cores ervices script folder as it should act as an alarm, not a voice activated script through the kinect service. Am I doing something wrong here?
7/18/2015
Topic:
help with my morning wake up weather script

Eric Hillen
Eric Hillen
Bump for the previous post. Haven't found any other mentions of this problem in for forum.
7/18/2015
Topic:
help with my morning wake up weather script

Eric Hillen
Eric Hillen
Bump for the previous post. Haven't found any other mentions of this problem in for forum.
8/31/2015
Topic:
help with my morning wake up weather script

Eric Hillen
Eric Hillen
So I thought I had it... added the new coreservices to my script and tried to let it go, no success. I'm at a loss for this damn thing and I'm about over this Sh*T. heres the script if anyone wants to figure it out, as I am spent.


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
using System.IO;
using System.Web;
using CastleOSKinectService;
using CastleOSCoreService;
using System.Speech.Recognition;


namespace WeatherAlarm


{
public partial class Form1 : Form
{

public class MyScript
{
public void Main(string[] args)
{






string Temperature;
string Condition;
string Humidity;
string WindSpeed;
string Town;
string TFCond;
string TFHigh;
string TFLow;


public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

void _recognizer_SpeechRecognizer(object sender, EventArgs e)
{
string speech = e.Result.Text;
switch (speech)
{
case " ":
GetWeather();


ScriptingAPI.Speak("The weather in " + Town + " is " + Condition + " at " + Temperature + " degrees ");

}



}
private void GetWeather()
{

string query = String.Format("http://weather.yahooapis.com/forecastrss?w=23424583");
XmlDocument wData = new XmlDocument();
wData.Load(query);

XmlNamespaceManager manager = new XmlNamespaceManager (wData.NameTable);
manager.AddNamespace("yweather", "http://xml.weather.yahoo.com/ns/rss/1.0");

XmlNode channel = wData.SelectSingleNode("rss").SelectSingleNode("channel");
XmlNodeList node = wData.SelectNodes("/rss/channel/item/yweather:forecastr", manager);

Temperature = channel.SelectSingleNode("item").SelectSingleNode("yweather:condition", manager).Attributes["temp"].Value;

Condition = channel.SelectSingleNode("item").SelectSingleNode("yweather:condition", manager).Attributes["text"].Value;

Humidity = channel.SelectSingleNode("yweather:atmosphere", manager).Attributes[Humidity].Value;

WindSpeed = channel.SelectSingleNode("yweather:wing", manager).Attributes["speed"].Value;

Town = channel.SelectSingleNode("yweather:location", manager).Attributes["city"].Value;

TFCond = channel.SelectSingleNode("item").SelectSingleNode("yweather:forecast", manager).Attributes["text"].Value;

TFHigh = channel.SelectSingleNode("item").SelectSingleNode("yweather:forecast", manager).Attributes["high"].Value;

TFLow = channel.SelectSingleNode("item").SelectSingleNode("yweather:forecast", manager).Attributes["low"].Value;





}



}
8/9/2016
Topic:
J.A.R.V.I.S inspired weather wakeup announcment

Eric Hillen
Eric Hillen
Phil, Great job man glad you finished it! I plan on getting into it this afternoon and see how you finally got it to work as I am by no means a programmer or coder. I like how you left the notes in the file to easily go in and personalize the script. Again, great job!
edited by eahillen on 8/9/2016
1