TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Take variable from voice into Python

    Alexa
    2
    2
    278
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      Itricio
      last edited by

      So basically, I want to take a number I say to Alexa (specifically int), and make a variable from python, that number. Is this possible, and if it is, how can I do it? Thanks

      RussR 1 Reply Last reply Reply Quote 0
      • RussR
        Russ @Itricio
        last edited by Russ

        @Itricio, you'll need to use one of the non-Smart Home skills - either TRIGGERcmd, or TRIGGER command. The Smart Home skills only pass "on" or "off" as the parameter.

        Here's a script that takes a parameter, and passes it back to TRIGGERcmd so you can have Alexa say the parameter back to you if you include {{result}} in the Voice Reply field.

        import sys, os
        
        if(len(sys.argv) > 1):
            first_param = sys.argv[1]
            print('Sending parameter to TRIGGERcmd for Alexa or Google Assistant to speak: ' + first_param)
            sts = os.system(os.environ['USERPROFILE'] + "\\.TRIGGERcmdData\\SendResult.bat " + first_param)
        else:
            print('No script arguments/parameters.')
        

        Assuming you give your script the word "script" in your voice field, say, ""Alexa, ask triggercmd to run script with parameter five."

        Here's some more about using the Voice Reply command field:
        https://www.triggercmd.com/forum/topic/962/solved-get-alexa-responses-that-contain-a-variable-value-taken-from-a-script/4

        Russell VanderMey

        1 Reply Last reply Reply Quote 0
        • tuicemenT tuicemen moved this topic from Instructions on
        • First post
          Last post