AutoVoice Triggering multiple profile or loop existing profile

Discussion in 'AutoApps' started by razorgamez, Jun 20, 2016.

  1. razorgamez

    razorgamez New Member

    Joined:
    Jun 20, 2016
    Messages:
    2
    Likes Received:
    0
    So what I am trying to attempt is the following.

    I have a few questions:
    1) I have a profile that will accept a voice command like: "Turn on Foyer Lights" working with regex. How would I go about making it work if i want it to for example fo "Turn on foyer lights and turn off living room lights"

    To be more precise the regex is: turn (?<command>on|off)(?<z1> my| the|)? (?<device>.+)

    2) I have multiple regex profiles, one that recognizes a command such as "Turn on Foyer Lights" and another such as "Run morning routine". How can I make it work if I say "Turn on Foyer Lights and Run morning routine" or "Run morning routine and turn on foyer lights".
    Regex: turn (?<command>on|off)(?<z1> my| the|)? (?<device>.+)
    Regex 2: run (?<routine>.+)

    Thanks for any and all feedback and help.
     
    Last edited: Jun 20, 2016
  2. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    How about this:
    Check this out: Test AutoVoice (11)
    A1: Variable Set [ Name:%command To:turn off living room and kitchen and turn on tv Do Maths:Off Append:Off ]
    A2: Variable Split [ Name:%command Splitter:and Delete Base:Off ]
    A3: For [ Variable:%commandpart Items:%command() ]
    A4: Variable Search Replace [ Variable:%commandpart Search:\A\s+|\s+\z Ignore Case:Off Multi-Line:On One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
    A5: If [ %commandpart ~R ^turn ]
    A6: Variable Split [ Name:%commandpart Splitter: Delete Base:Off ]
    A7: Variable Set [ Name:%lastonoroff To:%commandpart2 Do Maths:Off Append:Off ]
    A8: End If
    A9: Variable Search Replace [ Variable:%commandpart Search:turn %lastonoroff Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: ] If [ %lastonoroff Set ]
    A10: Flash [ Text:%commandpart: %lastonoroff Long:Off ]
    A11: End For

    By step 10 you'll have the device name in %commandpart and "on" or "off" in %lastonoroff :)

    So, a command like "turn off living room and kitchen and turn on tv" will produce 3 flashes:
    - living room: off
    - kitchen: off
    . tv: on

    Hope this helps :)
     
  3. razorgamez

    razorgamez New Member

    Joined:
    Jun 20, 2016
    Messages:
    2
    Likes Received:
    0
    definitely helps, now I just need to make a few different versions to cater to different command patterns.
     
    Last edited: Jun 22, 2016
  4. Styxman

    Styxman New Member

    Joined:
    Sep 13, 2016
    Messages:
    2
    Likes Received:
    0
    joaomgcd - Love the example...thanks. However, I have about 20 lights in my house, all controlled via Vera and it seems impossible to write a task for every combination. Is there a way to modify the example you provided to do that? For example, one time I might want to say: turn off x and y and z and turn on a --- another time I might want to say turn of x and y and turn on z and a. Thanks for the great apps.
     
  5. Styxman

    Styxman New Member

    Joined:
    Sep 13, 2016
    Messages:
    2
    Likes Received:
    0
    in running your above script, I'm getting a strange result:
    living room: off
    kitchen: off
    turn on tv: off --- doesn't seem to be picking up on the 2nd "turn"

    I've checked and rechecked my code against your post and can't figure it out. Thanks.
     
: regex

Share This Page