Author Topic: Weather xml request  (Read 15459 times)

0 Members and 1 Guest are viewing this topic.

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Weather xml request
« on: September 15, 2014, 08:19:30 AM »
I was wondering if anybody has written a sophisticated weather commands and would like to share the XML ...

P.S. I was not sure where to put this post so I thought to try this board
« Last Edit: September 15, 2014, 08:32:17 AM by jitterjames »
When Voice command gets tough, use hand gestures

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Weather xml request
« Reply #1 on: September 15, 2014, 06:26:22 PM »
I don't know how 'sophisticated' it is, but the following command is probably one that's useful to many users.

We can ask for the weather forecast for any day of the week ("Sunday" through "Saturday"), as well as "today" and "tomorrow".

You'd think that should be easy! But since Weather Underground uses a relative day variable to calculate the forecast (where today =0, tomorrow = 1, etc.), we have to help it to calculate the correct day.

I've done this with a Python script (attached), so both the Python plugin and the WUnder plugin must be enabled for this command to work.

The command xml:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.0.1.0-->
<commandGroup open="True" name="everyday weather" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="303" name="What's the forecast for {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>PY.ExecString</cmdType>
      <params>
        <param>weather({1})</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>WUnder.GetCustom</cmdType>
      <params>
        <param>Weather for {{var.day}.weekday}: {{var.day}.conditions}, with high of {{var.day}.high} degrees Celsius and a low of {{var.day}.low} degrees. There's a {{var.day}.pop}% chance of precipitation, with winds averaging {{var.day}.avewind} km/h.</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{LastResult}</param>
        <param>10000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>What's the forecast for</phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\weather_day.xml</payloadFromXML>
  </command>
  <command id="285" name="load python script" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>PY.ExecFile</cmdType>
      <params>
        <param>PY\weatherDay.py</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>VC.Loaded</event>
  </command>
</commandGroup>

Above I've included a 2nd command that loads the Python file when VC starts up. If you already have other Python scripts, you can just add this script to an existing Python file so that they all load at once.

Note that with only minor adjustments, I think it should be possible to use this in other languages as well. In the Python script, you should only need to translate the words "today" and "tomorrow", and of course you need to translate the VC command itself.

As always, you can customize what the TTS message says. For example, if you're retrieving imperial measurements you'll want to change the words "Celsius" and "km/h".

[Edit: updated this to fix errors]
« Last Edit: April 07, 2015, 05:04:56 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Weather xml request
« Reply #2 on: September 16, 2014, 01:36:59 PM »
Thank you nime5ter ...
When Voice command gets tough, use hand gestures

2exclusive

  • Contributor
  • ***
  • Posts: 54
  • Karma: 0
    • View Profile
Re: Weather xml request
« Reply #3 on: October 01, 2014, 12:06:49 AM »
How do you change the weather format to Fahrenheit and Miles Per Hour?

Instead of Celsius and KM/h

thanks

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Weather xml request
« Reply #4 on: October 01, 2014, 08:29:34 AM »
In the Wunder plugin settings, where you set your location.

You should always review plugin settings upon enabling one.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Weather xml request
« Reply #5 on: October 01, 2014, 10:17:36 AM »
And of course there are old posts with various custom weather responses depending on the forecast.

When I posted the above, I was assuming Haddood already knew of the previous posts, but for other users, see for example Dave's post: http://voxcommando.com/forum/index.php?topic=776.msg7742#msg7742

(We miss you Dave!)
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Dave

  • $upporter
  • Sr. Member
  • *****
  • Posts: 139
  • Karma: 31
    • View Profile
Re: Weather xml request
« Reply #6 on: October 01, 2014, 11:36:01 AM »
I'm still here ;)
Unfortunately I'm so busy atm, I had not even time try VC2...
But I try at least to keep track of all the new features!

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Weather xml request
« Reply #7 on: October 01, 2014, 01:02:23 PM »
Hi Dave  ::wave

Whoa! Really? You haven't tried VC2 yet?

I hope you'll have time for it some day. James has added a ton of new features, as well as improvements to old stuff.

I think you'll have fun experimenting with it if you ever find the time. But, so life goes. :)

Machs gut!
« Last Edit: October 01, 2014, 01:04:24 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

2exclusive

  • Contributor
  • ***
  • Posts: 54
  • Karma: 0
    • View Profile
Re: Weather xml request
« Reply #8 on: October 01, 2014, 03:54:11 PM »
In the Wunder plugin settings, where you set your location.

You should always review plugin settings upon enabling one.

I set the plugin (wunderground.com) to Imperial but still doesn't work. Also should I remove the word "metric" in the weather formats in the plugin settings?

I also see in command name (whats the forecast for {1}) your WUnder.GetCustom says "degrees Celsius and a low of"  so I would have to remove that celsius as well correct?


Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Weather xml request
« Reply #9 on: October 01, 2014, 04:16:39 PM »
You will find in the plugin a table which replace any kind of letters/words/signs in the result. For example: if the result show you "degrees Celsius" and you need only degrees, write on the left side in the table the word Celsius and in the right side type only a blank space sign and save the settings. This will replace all words Celsius in the forcast with a blank space.

Here is a good video tutorial how you can use the VC WUnder plugin

http://www.youtube.com/watch?v=UjYF36Mg8KU
« Last Edit: October 01, 2014, 04:22:30 PM by Kalle »
***********  get excited and make things  **********

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Weather xml request
« Reply #10 on: October 01, 2014, 04:45:29 PM »
I set the plugin (wunderground.com) to Imperial but still doesn't work. Also should I remove the word "metric" in the weather formats in the plugin settings?

What do you mean by "still doesn't work"?

1. Do you mean that when you test non-metric variables in the plugin settings window it is still returning metric values?
2. Do you mean that when you try to use the command xml I posted above, it is still returning metric values?
3. Do you mean that when you try to use the command xml I posted above, it is displaying the correct numerical values but still using the phrases "km/h" and "Celsius"?

I recommend that you watch at least the last part of the Wunder video tutorial that is posted on the Wunder wiki page (I've time stamped it to a particularly relevant section):
&feature=youtu.be&t=13m41s

There are settings in the plugin window that allow you to create forecasts customized to your wishes, which you can then access in your commands using the appropriate Wunder action (Wunder.GetCurrent, or Wunder.GetForecast #) http://voxcommando.com/mediawiki/index.php?title=Plugin_WUnder#Actions_for_the_WUnder_plugin

If you intend to use those actions in your commands, you should format the forecast the way that you want it in the plugin settings. (You can rewind the video to learn more about all the variables, or play around with them yourself.)

These are not relevant to my command xml above, however, because I used WUnder.GetCustom and the variables that I chose should use whichever measurement system users have selected as their default.

Recently, one VC user in Europe noticed that his particular weather station was only reporting Imperial values, so he could not get metric forecasts from that station. He switched to another local weather station and everything was fine. My guess is that this would be a pretty rare situation, so I would first make sure there is no user error, but if that fails you can try selecting a different weather station in the settings.

Quote
I also see in command name (whats the forecast for {1}) your WUnder.GetCustom says "degrees Celsius and a low of"  so I would have to remove that celsius as well correct?

Related to question 3 above: that's right. In this particular command example, I am defining the forecast string within the command itself. This means that even if you're correctly retrieving imperial values, the numbers may be correct but the phrases will continue to say whatever it says in the command xml. You should edit the command text to say whatever is appropriate for your needs.

« Last Edit: October 01, 2014, 05:05:29 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

2exclusive

  • Contributor
  • ***
  • Posts: 54
  • Karma: 0
    • View Profile
Re: Weather xml request
« Reply #11 on: October 01, 2014, 06:40:13 PM »
ok let me look at the video again and make sure I didnt miss anything.  thanks again

Spenner11

  • Jr. Member
  • **
  • Posts: 26
  • Karma: 0
  • British laddo, kicking it in B.C
    • View Profile
Re: Weather xml request
« Reply #12 on: October 27, 2014, 03:14:58 PM »
Hi all, after importing the XML to the command tree and trying to test the command I get this error:

Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
File name: 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
   at vcPlugin.locations.search(String strLocation)

Wondering If anyone can help me out?
Thanks
Jamie

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Weather xml request
« Reply #13 on: October 27, 2014, 03:39:53 PM »
Hi Spenner 11.  Welcome to the VC forum.

Please let us know what version of VoxCommando you are using.

If using 2.105 please update to 2.107

Spenner11

  • Jr. Member
  • **
  • Posts: 26
  • Karma: 0
  • British laddo, kicking it in B.C
    • View Profile
Re: Weather xml request
« Reply #14 on: October 29, 2014, 06:50:45 PM »
Thanks James, SO...I was running 2.1.05.
I just updated to 2.1.07 but now im getting this error from the Vox History panel.

PY.ExecString:weather({1})
Error: Line: 14 >>
TypeError: unsupported operand type(s) for -: 'set' and 'int'

Plugin: C:\Users\Media Centre\Documents\Vox Commando 2.1.07\Plugins\PY\PY.dll

But Vox does run the command,TTS just skips the actual variable of the weather. Unlike before where it wouldn't run at all.

Thanks for the help!