Author Topic: Prepare for upcoming snowstorms  (Read 2220 times)

0 Members and 1 Guest are viewing this topic.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Prepare for upcoming snowstorms
« on: March 24, 2017, 11:51:07 AM »
In his recent VoxWear (VoxWav for Android Wear 2.0) video, James demonstrates one of our new favourite commands: "Check snow cast."

I came up with this command a few months ago and it turns out to be very handy. I realise it's a bit silly to post a winter command when for most of you it's already springtime (or perhaps fall, if you're in the other hemisphere).

I thought I'd post it because it's a simple, fun command concept that can be adapted to other scenarios.

Where we live, it's helpful to monitor snow conditions a few days in advance. We periodically lose power during bad weather. Depending on how much snow is expected, we need to prepare for snow clearing, make sure we have firewood, charged batteries, candles, fresh water supplies etc.

This command, of course, uses the Weather Underground plugin. It also uses the Python plugin to add up some numbers. I retrieve the expected snowfall values for the next three days, add them up. If the amount is greater than zero, the command tells me what's in the cards. Otherwise, Vox gives us the "all clear".

The command could be triggered by an event to run automatically on a schedule. We just use a voice command.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.3.5-->
<command id="62" name="Check snow cast" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>WUnder.GetCustom</cmdType>
    <params>
      <param>{D0.snow_allday}+{D1.snow_allday}+{D2.snow_allday}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>PY.ExecString</cmdType>
    <params>
      <param>result = {LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)&lt;(B)</ifType>
    <ifParams>0&amp;&amp;{LastResult}</ifParams>
    <then>
      <action>
        <cmdType>WUnder.GetCustom</cmdType>
        <params>
          <param>{D0.snow_allday} cm of snow expected today, {D1.snow_allday} cm expected tomorrow, and {D2.snow_allday} on {D2.weekday}.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>Looks like there's snow in the forecast. </param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>{LastResult}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>{LastResult}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>No snow is expected in the next few days.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <phrase>Check snow cast</phrase>
</command>



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)