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

    Pass color and brightness parameters using TRIGGERcmd Smart Home Alexa skill

    Announcements
    alexa
    4
    10
    667
    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.
    • RussR
      Russ
      last edited by Russ

      Thanks to @tuicemen's suggestion, now you can use commands that accept brightness or color as a parameter via the TRIGGERcmd Smart Home Alexa skill.

      • Brightness will be a number from 1 to 100.
      • Color will be red, blue, brown, green, pink, purple etc.

      To test it, you could enable parameters on your notepad command like this:

      874113e6-7786-4b22-a2e4-857fc0bfa44a-image.png

      Then say something like: "Alexa, turn notepad red"

      I'll look into adding on Google Assistant too, but so far this only works with the TRIGGERcmd Smart Home Alexa skill.

      Alexa devices for existing commands (created before 2/6/2022) will need to be deleted and re-discovered, or you can change the command's name and change it back so it will be re-created with the new color and brightness properties.

      Russell VanderMey

      1 Reply Last reply Reply Quote 1
      • tuicemenT
        tuicemen
        last edited by tuicemen

        Just awesome!
        For the Dim commands you can say something like "Alexa, office light 50%" or "Alexa set office light to 50"
        This should allow control of other things that rely on a number value as well.
        You can say Dim in a Alexa call but brighten doesn't seem to work Alexa says OK but nothing happens. (at least not in my tests)

        1 Reply Last reply Reply Quote 0
        • Javier Rilova 0J
          Javier Rilova 0
          last edited by

          Awesome, looking forward to this to be implemented for Google Home too, can't wait!

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

            @javier-rilova-0, this works on Google Home now too. Please try it.

            Russell VanderMey

            1 Reply Last reply Reply Quote 0
            • Moacir Vilela SêgaM
              Moacir Vilela Sêga
              last edited by

              Did it stop working? I used this to control my computer volume, and I think since yesterday it isnt working anymore, even after deleting the devices

              RussR 1 Reply Last reply Reply Quote 0
              • RussR
                Russ @Moacir Vilela Sêga
                last edited by

                @moacir-vilela-sêga , not that I know of. Are you using the Google Assistant or Alexa?

                Are you using a script? If so can you paste it here?

                Do you have parameters enabled on the command?

                Is your script logging the parameter? If you run the script manually with a number parameter does it work?

                Russell VanderMey

                Moacir Vilela SêgaM 1 Reply Last reply Reply Quote 0
                • Moacir Vilela SêgaM
                  Moacir Vilela Sêga @Russ
                  last edited by

                  @russ I am using Alexa. I did a simple python script

                  import pyttsx3
                  import threading
                  import sys
                  from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume, IAudioEndpointVolumeCallback
                  from comtypes import CLSCTX_ALL, COMObject
                  
                  from ctypes import POINTER, cast
                  
                  class fala:
                      def __init__(self,msg,voice=0):
                          threading.Thread(target=self.thread,args=(msg,voice,)).start()
                      def thread(self,msg,voice):
                          tts = _TTS(voice)
                          tts.start(msg)
                          del(tts)
                      
                  class _TTS:
                      engine = None
                      rate = None
                      def __init__(self,voice):
                          self.engine = pyttsx3.init()
                          self.engine.setProperty('volume',1.0)
                          voices = self.engine.getProperty('voices')
                          self.engine.setProperty('voice', voices[voice].id)
                      def start(self,text_):
                          self.engine.say(text_)
                          try:
                              self.engine.runAndWait()
                          except:
                              fala(text_)
                  
                  
                  class AudioEndpointVolumeCallback(COMObject):
                      _com_interfaces_ = [IAudioEndpointVolumeCallback]
                  
                      def OnNotify(self, pNotify):
                          print('OnNotify callback')
                  
                  list2 = sys.argv[1:]
                  devices = AudioUtilities.GetSpeakers()
                  interface = devices.Activate(IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
                  volume = cast(interface, POINTER(IAudioEndpointVolume))
                  callback = AudioEndpointVolumeCallback()
                  volume.RegisterControlChangeNotify(callback)
                  
                  
                  
                  try:
                      if isinstance(int(sys.argv[1]),int):
                          fala('volume definido para ' + str(int(sys.argv[1])))
                          volume.SetMasterVolumeLevelScalar(int(sys.argv[1])/100,None)
                  except:
                      fala(' '.join(list2))
                  
                  
                  

                  So if I say a number it changes the volume, but if I say a color or "Turn on/off" it says On, Off or the Color. (Basically it tries to say it out loud if the parameter is not a number)

                  Now, it only works during On and Off. All the colors or the numbers are not working as valid parameters.

                  This is how it is coded in TriggerCMD currently:

                   {
                    "trigger": "Protocolo",
                    "command": "python \"D:\\Programming\\Python\\teste vozes.py\"",
                    "offCommand": "",
                    "ground": "foreground",
                    "voice": "Protocolo",
                    "voiceReply": "",
                    "allowParams": "true"
                   }
                  
                  RussR 1 Reply Last reply Reply Quote 0
                  • RussR
                    Russ @Moacir Vilela Sêga
                    last edited by

                    @moacir-vilela-sêga , will you please try this simpler script that just prints and logs the first parameter?

                    import os, sys
                    
                    f = open(os.path.dirname(os.path.realpath(__file__)) + "\log.txt", "a")
                    msg = "first arg is " + sys.argv[1] + "\n"
                    print(msg)
                    f.write(msg)
                    f.close()
                    

                    Also, please try running your script from a cmd prompt with red or 80 as the parameter to see if it's erroring. I wonder if it's erroring and you're just not seeing the output so you don't see the error.

                    Russell VanderMey

                    Moacir Vilela SêgaM 1 Reply Last reply Reply Quote 0
                    • Moacir Vilela SêgaM
                      Moacir Vilela Sêga @Russ
                      last edited by

                      @russ I dont know what to tell you now. It is just working normally now. I didn't change neither my script nor tried to re-add the device.
                      I decided to test it before changing to your script and it worked.

                      RussR 1 Reply Last reply Reply Quote 0
                      • RussR
                        Russ @Moacir Vilela Sêga
                        last edited by

                        @moacir-vilela-sêga , strange. I don't know what fixed it either.

                        Russell VanderMey

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post