Author Topic: how to determine if a group is enabled or disabled??  (Read 2224 times)

0 Members and 1 Guest are viewing this topic.

monkee

  • $upporter
  • Jr. Member
  • *****
  • Posts: 40
  • Karma: 4
    • View Profile
how to determine if a group is enabled or disabled??
« on: June 19, 2016, 04:46:35 AM »
Hello, I'm trying to create a command using IF/THEN logic based on whether a group is currently enabled or disabled.  How can I determine if it is enabled or disabled and use that in my IF/THEN logic??

Thanks in advance!

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: how to determine if a group is enabled or disabled??
« Reply #1 on: June 19, 2016, 08:23:50 AM »
You cannot but normally it's not needed. What are you trying to accomplish?

monkee

  • $upporter
  • Jr. Member
  • *****
  • Posts: 40
  • Karma: 4
    • View Profile
Re: how to determine if a group is enabled or disabled??
« Reply #2 on: June 19, 2016, 01:01:40 PM »
Well, that would explain why I couldn't figure out how to do it, haha.  This will be difficult to explain clearly but I'll try!  There are likely better ways to do what I'm trying to do too but here goes.

My smart door lock has an autolock feature but the built in time delay is not long enough and also I want the ability to easily (by voice) to disable or re-enable the autolocking feature (think repairmen going in/out on a certain day).  I disabled the integrated autolocking and decided to have VC do the autolocking instead.

The lock sends VC a code every time it is unlocked (manually,by voice, by timer, etc.).  I'm using that code to trigger a 20 minute timer, a the end of which, the lock is polled and, if still unlocked, it will be locked. 

In order to disable auto-locking, I put the command that detects the code the door sends when unlocked (and starts the timer) in a folder that is disabled when I say "disable autolocking".  [I also have the "disable autolocking" command set to lock the door and re-enable that folder (and thus autolocking) after 24 hours in case I forget to re-enable it by voice but that shouldn't matter in this discussion.]

This is all working flawlessly BUT, to be perfect, I also want to be able to detect if autolocking is currently disabled or enabled.  As it is now, if I say "disable autolocking" VC responds with "disabling autolocking", however, if I say "disable autolocking" again a minute later, VC will again respond with "disabling autolocking" even though it is already disabled.  I was planning to just detect if that folder was enabled or disabled to use in IF/THEN logic to have VC respond "autolocking is already disabled" if the folder is disabled.

I hope that makes sense and I can probably figure out another way to do it but I was assuming I could just detect the enabled/disabled status of the folder. 

I've include the relevant working (but unfinished) code in case it helps.

Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<VoiceCommands version="2.2.2.0" space="preserve" date="6/19/2016 12:00:00 AM">
    <groupCollection open="True" name="mine">
        <commandGroup open="True" name="vera" enabled="True" prefix="" priority="0" requiredProcess="" description="">
            <command id="505" name="disable autolock" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
                <action>
                    <cmdType>Group.Disable</cmdType>
                    <params>
                        <param>auto door lock</param>
                    </params>
                    <cmdRepeat>1</cmdRepeat>
                </action>
                <action>
                    <cmdType>TTS.Speak</cmdType>
                    <params>
                        <param>Auto door locking has been disabled.</param>
                    </params>
                    <cmdRepeat>1</cmdRepeat>
                </action>
                <action>
                    <cmdType>VC.SetEventTimer</cmdType>
                    <params>
                        <param>24h</param>
                        <param>24hrrestart</param>
                    </params>
                    <cmdRepeat>1</cmdRepeat>
                </action>
                <phrase>disable autolock, disable auto door lock</phrase>
            </command>
            <command id="528" name="enable autolock" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
                <action>
                    <cmdType>Group.Enable</cmdType>
                    <params>
                        <param>auto door lock</param>
                    </params>
                    <cmdRepeat>1</cmdRepeat>
                </action>
                <action>
                    <cmdType>TTS.SpeakSync</cmdType>
                    <params>
                        <param>Auto door locking has been enabled.</param>
                    </params>
                    <cmdRepeat>1</cmdRepeat>
                </action>
                <action>
                    <cmdType>VC.TriggerEvent</cmdType>
                    <params>
                        <param>lockdoor</param>
                    </params>
                    <cmdRepeat>1</cmdRepeat>
                </action>
                <phrase>enable autolock, enable auto door locking</phrase>
            </command>
            <command id="596" name="enable autolock no voice 24hr" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
                <action>
                    <cmdType>Group.Enable</cmdType>
                    <params>
                        <param>auto door lock</param>
                    </params>
                    <cmdRepeat>1</cmdRepeat>
                </action>
                <action>
                    <cmdType>VC.TriggerEvent</cmdType>
                    <params>
                        <param>lockdoor</param>
                    </params>
                    <cmdRepeat>1</cmdRepeat>
                </action>
                <event>24hrrestart</event>
            </command>
        </commandGroup>
        <commandGroup open="True" name="auto door lock" enabled="True" prefix="" priority="0" requiredProcess="" description="">
            <command id="534" name="lock the door" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
                <action>
                    <cmdType>Vera.Get.LockStatus</cmdType>
                    <params>
                        <param>9</param>
                    </params>
                    <cmdRepeat>1</cmdRepeat>
                </action>
                <if ifBlockDisabled="False" ifNot="False">
                    <ifType>(A)==(B)</ifType>
                    <ifParams>{LastResult}&amp;&amp;1</ifParams>
                    <then />
                    <else>
                        <action>
                            <cmdType>Vera.Toggle</cmdType>
                            <params>
                                <param>9</param>
                            </params>
                            <cmdRepeat>1</cmdRepeat>
                        </action>
                    </else>
                </if>
                <event>lockdoor</event>
            </command>
            <command id="580" name="start timer" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
                <action>
                    <cmdType>VC.SetEventTimer</cmdType>
                    <params>
                        <param>20m</param>
                        <param>lockdoor</param>
                    </params>
                    <cmdRepeat>1</cmdRepeat>
                </action>
                <event>Vera1.DoorLock.9.Open</event>
            </command>
        </commandGroup>
    </groupCollection>
</VoiceCommands>

Thanks!
« Last Edit: June 19, 2016, 01:18:25 PM by monkee »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: how to determine if a group is enabled or disabled??
« Reply #3 on: June 19, 2016, 01:56:16 PM »
I don't mind adding this feature but you'll have to wait until the next release which might take a while and there are a lot of ways you could work around this.

As it is now, if I say "disable autolocking" VC responds with "disabling autolocking", however, if I say "disable autolocking" again a minute later, VC will again respond with "disabling autolocking" even though it is already disabled.  I was planning to just detect if that folder was enabled or disabled to use in IF/THEN logic to have VC respond "autolocking is already disabled" if the folder is disabled.

To me the most obvious and easy solution is to put your "disable autolock" command into the "auto door lock" group so that that command is not longer active and won't be recognized when you say it. 
Really, that is the reason why we are able to enable and disable groups in VoxCommando.  The idea is that if you have multiple groups of commands with similar phrasing you can enable and disable groups depending on which programs are running.  So, you enable your Kodi groups when Kodi is running and when you run MediaMonkey, you disable your Kodi groups and enable your MediaMonkey groups, because they both use commands such as "play", "stop", and "set volume".

Seems to me maybe you are using the disabling and enabling of groups for the wrong reason.  Probably you want to just set a variable and use that in your logic blocks, instead of enabling and disabling groups.
http://voxcommando.com/mediawiki/index.php?title=Variables#User_Variables

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 499
  • Karma: 43
    • View Profile
Re: how to determine if a group is enabled or disabled??
« Reply #4 on: June 19, 2016, 01:57:53 PM »
jitterjames posted before I finished my post, but thought I would share my Idea as well

to me it seems the easiest way to handle this is to use Variables (Results.SetVar)

more info here http://voxcommando.com/mediawiki/index.php?title=Actions#SetVar

using a 24 hour timer works but if you restart VC during that 24 hours the timer will be cleared and wont trigger so I would look into a couple of differnt methods that can help you make sure it triggers 24 hours later

option one uses Windows Task Scheduler  http://voxcommando.com/forum/index.php?topic=1780.0

option two uses a Command that I made called "Reminders with a Memory" http://voxcommando.com/forum/index.php?topic=1943.msg16729#msg16729

either on of these will Require some configuring to work with your setup but they should both make sure that your Events are triggered even if VC or your PC is rebooted

monkee

  • $upporter
  • Jr. Member
  • *****
  • Posts: 40
  • Karma: 4
    • View Profile
Re: how to determine if a group is enabled or disabled??
« Reply #5 on: June 19, 2016, 02:26:14 PM »
Thanks to both of you.  I'll check out variables now and let you know how it turns out.  As jitterjames said, I do use disable groups/enable exclusive in eventghost so that my "pause" button will pause VLC, SageTV, etc. depending on what is active.  And yes, SageTV is still awesome, now open sourced and free too :)  I know Kodi has much better VC integration but I just always go back to SageTV.

I was already planning to look up what would happen with my timer if I restarted the PC so you saved me some time.  I figured I may have to use the task scheduler but will also check out your solution, PegLegTV.

Thanks!

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: how to determine if a group is enabled or disabled??
« Reply #6 on: June 19, 2016, 02:57:06 PM »
my 2 cents on the topic, I would store it in a map (DB) so that if VC restarted it will still remember the state of it ...

http://voxcommando.com/mediawiki/index.php?title=Maps
« Last Edit: June 19, 2016, 04:30:31 PM by nime5ter »
When Voice command gets tough, use hand gestures

monkee

  • $upporter
  • Jr. Member
  • *****
  • Posts: 40
  • Karma: 4
    • View Profile
Re: how to determine if a group is enabled or disabled??
« Reply #7 on: June 19, 2016, 05:25:11 PM »
Ok, variables are pretty useful.  They'll come in handy for other things in my setup too.  Thanks for pointing me in the right direction! 

Now I'm using variables instead of disabling the folders and it's a bit cleaner.  I added a command to set the variable to enable autolocking when VC loads and also start the 20 min timer, so on reboot/crash it'll default back to enabled and then lock in 20 minutes if unlocked.  I'll look into the better timer options but this should do for now.  The map DB sounds useful too... another thing for me to learn about when I have some time!

Here is the new version:

Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<VoiceCommands version="2.2.2.0" space="preserve" date="6/19/2016 12:00:00 AM">
    <groupCollection open="True" name="mine">
        <commandGroup open="True" name="vera" enabled="True" prefix="" priority="0" requiredProcess="" description="">
            <command id="505" name="disable autolock" 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>{var.autolock}&amp;&amp;disabled</ifParams>
                    <then>
                        <action>
                            <cmdType>TTS.Speak</cmdType>
                            <params>
                                <param>Autolocking is already disabled.</param>
                            </params>
                            <cmdRepeat>1</cmdRepeat>
                        </action>
                    </then>
                    <else>
                        <action>
                            <cmdType>Results.SetVar</cmdType>
                            <params>
                                <param>autolock</param>
                                <param>disabled</param>
                            </params>
                            <cmdRepeat>1</cmdRepeat>
                        </action>
                        <action>
                            <cmdType>TTS.Speak</cmdType>
                            <params>
                                <param>Auto door locking has been disabled.</param>
                            </params>
                            <cmdRepeat>1</cmdRepeat>
                        </action>
                        <action>
                            <cmdType>VC.SetEventTimer</cmdType>
                            <params>
                                <param>24h</param>
                                <param>24hrrestart</param>
                            </params>
                            <cmdRepeat>1</cmdRepeat>
                        </action>
                    </else>
                </if>
                <phrase>disable autolock, disable auto door lock</phrase>
            </command>
            <command id="528" name="enable autolock" 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>{var.autolock}&amp;&amp;enabled</ifParams>
                    <then>
                        <action>
                            <cmdType>TTS.Speak</cmdType>
                            <params>
                                <param>Autolocking is already enabled.</param>
                            </params>
                            <cmdRepeat>1</cmdRepeat>
                        </action>
                    </then>
                    <else>
                        <action>
                            <cmdType>Results.SetVar</cmdType>
                            <params>
                                <param>autolock</param>
                                <param>enabled</param>
                            </params>
                            <cmdRepeat>1</cmdRepeat>
                        </action>
                        <action>
                            <cmdType>TTS.SpeakSync</cmdType>
                            <params>
                                <param>Auto door locking has been enabled.</param>
                            </params>
                            <cmdRepeat>1</cmdRepeat>
                        </action>
                        <action>
                            <cmdType>VC.TriggerEvent</cmdType>
                            <params>
                                <param>start timer</param>
                            </params>
                            <cmdRepeat>1</cmdRepeat>
                        </action>
                    </else>
                </if>
                <phrase>enable autolock, enable auto door locking</phrase>
            </command>
            <command id="596" name="enable autolock no voice 24hr" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
                <action>
                    <cmdType>VC.TriggerEvent</cmdType>
                    <params>
                        <param>lockdoor</param>
                    </params>
                    <cmdRepeat>1</cmdRepeat>
                </action>
                <action>
                    <cmdType>Results.SetVar</cmdType>
                    <params>
                        <param>autolock</param>
                        <param>enabled</param>
                    </params>
                    <cmdRepeat>1</cmdRepeat>
                </action>
                <event>24hrrestart</event>
            </command>
            <command id="536" name="lock the door" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
                <action>
                    <cmdType>Vera.Get.LockStatus</cmdType>
                    <params>
                        <param>9</param>
                    </params>
                    <cmdRepeat>1</cmdRepeat>
                </action>
                <if ifBlockDisabled="False" ifNot="False">
                    <ifType>(A)==(B)</ifType>
                    <ifParams>{LastResult}&amp;&amp;1</ifParams>
                    <then />
                    <else>
                        <action>
                            <cmdType>Vera.Toggle</cmdType>
                            <params>
                                <param>9</param>
                            </params>
                            <cmdRepeat>1</cmdRepeat>
                        </action>
                    </else>
                </if>
                <event>lockdoor</event>
            </command>
            <command id="591" name="start timer" 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>{var.autolock}&amp;&amp;enabled</ifParams>
                    <then>
                        <action>
                            <cmdType>VC.SetEventTimer</cmdType>
                            <params>
                                <param>20m</param>
                                <param>lockdoor</param>
                            </params>
                            <cmdRepeat>1</cmdRepeat>
                        </action>
                    </then>
                    <else />
                </if>
                <event>Vera1.DoorLock.9.Open</event>
                <event>start timer</event>
            </command>
            <command id="592" name="enable 20 min autolock on boot" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
                <action>
                    <cmdType>Results.SetVar</cmdType>
                    <params>
                        <param>autolock</param>
                        <param>enabled</param>
                    </params>
                    <cmdRepeat>1</cmdRepeat>
                </action>
                <action>
                    <cmdType>VC.TriggerEvent</cmdType>
                    <params>
                        <param>start timer</param>
                    </params>
                    <cmdRepeat>1</cmdRepeat>
                </action>
                <event>VC.Loaded</event>
            </command>
        </commandGroup>
    </groupCollection>
</VoiceCommands>

And thank you all!

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: how to determine if a group is enabled or disabled??
« Reply #8 on: July 02, 2016, 01:36:05 PM »
You probably don't need this anymore but I just uploaded version 2.2.2.1 which includes the new action:

Group.GetEnabled