TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login
    1. Home
    2. Jonas Leite
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 7
    • Best 0
    • Controversial 0
    • Groups 0

    Jonas Leite

    @Jonas Leite

    0
    Reputation
    1
    Profile views
    7
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Jonas Leite Unfollow Follow

    Latest posts made by Jonas Leite

    • RE: Getting data from Google Sheets

      @Russ
      It worked. The error was in credential.json, TRIGGERcmd couldn't find the file, so I entered the data directly into the python file.

      Good job. Thanks for the help my friend.

      posted in General Discussion
      Jonas LeiteJ
      Jonas Leite
    • RE: Getting data from Google Sheets

      @Russ I managed to get the code to work, see below. Is correct? It is taking the values ​​from the spreadsheet.

      import gspread
      from oauth2client.service_account import ServiceAccountCredentials
      
      # Configurar as credenciais do Google Sheets
      scope = ['https://spreadsheets.google.com/feeds',
               'https://www.googleapis.com/auth/drive']
      creds = ServiceAccountCredentials.from_json_keyfile_name('serviceaccount.json', scope)
      client = gspread.authorize(creds)
      
      # Abrir a planilha pelo seu ID
      sheet = client.open_by_key('1TuSui3-9aPT0jwJuEJ5S-VmBzue1jnKFbdCAprm_DIk')
      
      # Acessar a planilha desejada
      worksheet = sheet.get_worksheet(1)  # Supondo que seja a primeira aba da planilha
      
      # Ler o valor de uma célula específica
      cell_value = worksheet.acell('E11').value
      print("Valor da célula E11:", cell_value)
      
      import os
      import subprocess
      
      home_folder = os.path.expanduser('~')
      batch_script_relative_path = '.TRIGGERcmdData\SendResult.bat'
      batch_script_path = os.path.join(home_folder, batch_script_relative_path)
      parameters = [cell_value]
      try:
          result = subprocess.run([batch_script_path] + parameters, capture_output=True, text=True, check=True, shell=True)
          print("Output:", result.stdout)
      except subprocess.CalledProcessError as e:
          print("Error:", e)
          print("Output:", e.output)
      

      But I didn't understand how to put it in TriggerCMD.

      e8ecb844-d5ad-438c-b843-2a71c5827f6a-image.png

      I used the TRIGGERcmd command to execute the “test” command but Alexa only returns “no result.

      posted in General Discussion
      Jonas LeiteJ
      Jonas Leite
    • RE: Getting data from Google Sheets

      Well, I understand the logic, but something is wrong. And I couldn't figure out what it is. Would you help me?

      My command

      import gspread
      from oauth2client.service_account import ServiceAccountCredentials
      
      # define the scope of the API access
      scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
      
      # authenticate with the API using the credentials file
      creds = ServiceAccountCredentials.from_json_keyfile_name('credentials.json', scope)
      client = gspread.authorize(creds)
      
      # open the Google Sheet by its URL
      sheet_url = 'https://docs.google.com/spreadsheets/d/1AgCtusxv7xgLq9G_Q7Ea5YQsEwjg8Klz/edit#gid=0'
      sheet = client.open_by_url(sheet_url)
      
      # select the first worksheet
      worksheet = sheet.get_worksheet(0)
      
      # read the value of cell A1
      cell_value = worksheet.acell('E12').value
      
      print(cell_value)
      
      
      ERROR
      
      Traceback (most recent call last):
        File "C:\Users\jonas\PycharmProjects\Teste do SHEETS\Sheets.py", line 8, in <module>
          creds = ServiceAccountCredentials.from_json_keyfile_name('credentials.json', scope)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\jonas\AppData\Local\Programs\Python\Python311\Lib\site-packages\oauth2client\service_account.py", line 221, in from_json_keyfile_name
          return cls._from_parsed_json_keyfile(client_credentials, scopes,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\jonas\AppData\Local\Programs\Python\Python311\Lib\site-packages\oauth2client\service_account.py", line 171, in _from_parsed_json_keyfile
          raise ValueError('Unexpected credentials type', creds_type,
      ValueError: ('Unexpected credentials type', None, 'Expected', 'service_account')
      

      The credential is correct, I took the test and managed to authenticate, but when I enter the command you gave me it doesn't work.

      posted in General Discussion
      Jonas LeiteJ
      Jonas Leite
    • Getting data from Google Sheets

      I want to get data from a specific cell in Google Sheets. Example: I ask Alexa a question, Alexa how many pieces there are of item A. Then she tells me what is contained in cell A1. Can someone help me?

      posted in General Discussion
      Jonas LeiteJ
      Jonas Leite