Author Topic: Time / Clock-related commands  (Read 7908 times)

0 Members and 1 Guest are viewing this topic.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Time / Clock-related commands
« on: January 28, 2014, 12:33:21 PM »
Many people have asked about getting alarms, figuring out the time, etc. Although these have been answered before for the most part, here are some examples of time-related commands.

This post includes three command groups:
1) "I just time travelled. Where am I?" - What time is it? Ask Vox for the time, the day of the week, or the date.
2) "Take your pill" - an alarm command. Get a reminder to take your medication once a day.
3) "Tell me the time" -- Talking clock announces the time automatically throughout the day. Includes some basic logic so that the announcement changes depending on the time of day. Runs 24 hours as long as Vox is running, but only actually announces the time between 6 a.m. and 9 p.m.

The "talking clock" command group uses the python plugin in order to do a basic calculation, so you'll need to enable to python plugin for that one. However, there is no "complicated" python code to understand, it's just subtracting one number from another.

These commands all use date or time variables. If you're not familiar with all of the variables you have access to in VC, search for the "variables" page in the wiki.

These commands could probably all be done in different ways. You could use more elaborate python code if you prefer, or set up events in Google Calendar and use the GgCal plugin (this could be a good alternative for the daily pill reminder, for example).

All three command groups are attached. You should be able to drag and drop the files you want directly into your command tree once you've downloaded them to your computer.

Nota bene: just drag *the file itself* directly into your tree -- you don't need to open the files first!
« Last Edit: July 02, 2014, 08:30:17 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)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Clock-related commands
« Reply #1 on: January 28, 2014, 12:38:31 PM »
1) "I just time travelled. Where am I?" - ask Vox for the time, the day of the week, or the date.

I'm so glad I married a nerd ...  :D

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Time / Clock-related commands
« Reply #2 on: July 03, 2014, 02:24:53 PM »
Here's an additional "what time is it" example, which uses custom time variables to enhance conversation with your computer (what some users like to think of as an "AI experience").

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.0.0.0-->
<command id="450" name="time-related friendly chitchat" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="See http://voxcommando.com/mediawiki/index.php?title=Custom_DateTime_codes for explanation of special date/time variables.">
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>,4,5,6,7,8,9,10,11,&amp;&amp;,{DtCustom.%H},</ifParams>
    <then>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>Good morning, Joe. It is currently {ShortTime}.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>Good morning. It is currently {ShortTime}.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>,12,13,14,15,16,17,&amp;&amp;,{DtCustom.%H},</ifParams>
    <then>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>Good afternoon Joe. It is {DtCustom.%h.mm} p.m.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>Good afternoon, Joe. It is {DtCustom. h:mm} p.m.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>,18,19,20,21,22,&amp;&amp;,{DtCustom.%H},</ifParams>
    <then>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>It is {ShortTime}. Hope you're enjoying your evening.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>It is {ShortTime}.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>,23,0,1,2,3,&amp;&amp;,{DtCustom.%H},</ifParams>
    <then>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>Yawwn. It's {ShortTime}. Are you still awake?</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>It's {ShortTime}. Go to bed !!!</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <phrase>What's up computer?</phrase>
</command>

More elegant solutions can be conceived using the Python plugin, but solutions like the above are a good way for those without programming experience to accomplish something similar.
« Last Edit: February 05, 2016, 01:40:58 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)

IKROWNI

  • $upporter
  • Sr. Member
  • *****
  • Posts: 146
  • Karma: 2
    • View Profile
Re: Time / Clock-related commands
« Reply #3 on: August 11, 2016, 01:13:55 AM »
How would you run a command only if its between a certain time period? Like for example if i only wanted a light in a room to be turned on between 10PM-11PM? I have a motion detector that constantly flips my garage light on during the day and i only want it to be capable of running the event between 10p-11p.

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 497
  • Karma: 43
    • View Profile
Re: Time / Clock-related commands
« Reply #4 on: August 11, 2016, 03:06:19 AM »
How would you run a command only if its between a certain time period? Like for example if i only wanted a light in a room to be turned on between 10PM-11PM? I have a motion detector that constantly flips my garage light on during the day and i only want it to be capable of running the event between 10p-11p.

In order to do this you will need to use an if statement with {DtCustom.HH}

the output from {DtCustom.HH} is - 00 01 02 03 04....21 22 23

the group I attached has two commands one will only work when the hour is 22 (10:00PM-10:59PM)

the second will only work when the hour is 22 or 23 (10:00PM-11:59PM)

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.2.2-->
<commandGroup open="True" name="IF Statements using {DtCustom.HH}" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="122" name="22 = 10PM" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{DtCustom.HH}&amp;&amp;22</ifParams>
      <then>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>it is between 10:00 PM and 10:59PM</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
  </command>
  <command id="110" name="between 10:00PM and 11:59PM" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)Contains(B)</ifType>
      <ifParams>22 23&amp;&amp;{DtCustom.HH}</ifParams>
      <then>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>it is between 10:00pm and 11:59 PM</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
  </command>
</commandGroup>

I know it's simple but I hope it helps

IKROWNI

  • $upporter
  • Sr. Member
  • *****
  • Posts: 146
  • Karma: 2
    • View Profile
Re: Time / Clock-related commands
« Reply #5 on: August 13, 2016, 02:41:57 PM »
I know it's simple but I hope it helps

It sure did thank you very very much for the help i got this setup like this now after seeing yours. I'm definitely a visual learner lol

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.2.3-->
<command id="346" name="JAMES BLE DETECTED" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>06 07 08 09 10 11&amp;&amp;{DtCustom.HH}</ifParams>
    <then>
      <action>
        <cmdType>Hue.Scene.Load</cmdType>
        <params>
          <param>kAgMobQ-oYaTEsY</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>Good Morning James</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>12 13 14 15 16 17&amp;&amp;{DtCustom.HH}</ifParams>
    <then>
      <action>
        <cmdType>Hue.Scene.Load</cmdType>
        <params>
          <param>kAgMobQ-oYaTEsY</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>Good afternoon James</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>18 19 20 21 22 23 24 01 02 03 04 05&amp;&amp;{DtCustom.HH}</ifParams>
    <then>
      <action>
        <cmdType>Hue.Scene.Load</cmdType>
        <params>
          <param>Qz07sqDQoR8aeti</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>Good Evening James</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <action>
    <cmdType>X10.SendPlc</cmdType>
    <params>
      <param>A7 ON</param>
      <param>Fan Turn On</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>X10.SendPlc</cmdType>
    <params>
      <param>A9 ON</param>
      <param>Stereo Turn On</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>UsbUIRT.Send</cmdType>
    <params>
      <param>{M:uu_TV.Power On}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>HappyB.JAMES BEACON SLIDES.Found.Office</event>
</command>