Author Topic: How to use payloads with scrape action for HTTP get requests  (Read 5324 times)

0 Members and 1 Guest are viewing this topic.

MárlonPrado

  • Jr. Member
  • **
  • Posts: 12
  • Karma: 0
    • View Profile
Olá, bom dia a todos.
Agradeço pelo apoio e boa recepção de vocês.
Nime5ter, você entendeu o que eu preciso, no entanto, já tentei de todas as formas configurar e não deu certo. James está certo.
Trata-se de um pequeno projeto de automação residencial onde estamos desenvolvendo o próprio hardware e software de controle.
Ainda em fase de testes, essa é a primeira tentativa de controle por voz e escolhemos o voxcommando pela liberdade de configurações possíveis.
Quando digitamos no navegador 192.168.0.1, é aberta uma página de controle que se encontra hospedada em um microcontrolador. Nesta página, podemos clicar nos botões que são (t1, t2, t3, etc.). Dessa forma, o endereço final fica como 192.168.0.1/t1, por exemplo.
Ainda nesta fase de testes, o pequeno servidor no microcontrolador está com o ip fixo e não tem uma porta configurada, estando aberto a qualquer porta de comunicação.
James, peço por gentileza um exemplo de como configurar a função "Scrape.Get" para este meu caso e se possível disponibilizar o xml de um exemplo.
Grato à vocês pela atenção e bom domingo a todos.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: How to use payloads with scrape action for HTTP get requests
« Reply #1 on: May 17, 2015, 08:15:17 AM »
Here is a command group with 3 examples. They are different ways to do the same thing.

To use the Payload XML example, please download the file that I have attached to this post, and put it in your VoxCommando\payloads folder.

3 maneiras de fazer a mesma coisa

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.2-->
<commandGroup open="True" name="3 maneiras de fazer a mesma coisa" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="594" name="Press button (using a Payload List)" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Selecting {1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>http://192.168.0.1/{1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Press button</phrase>
    <payloadList>t1,t2,t3,t4,t5</payloadList>
  </command>
  <command id="605" name="Press button (using a Payload Range)" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Selecting t{1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>http://192.168.0.1/t{1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Inititate button number</phrase>
    <payloadRange>1,10</payloadRange>
  </command>
  <command id="623" name="Press button (using a Payload XML file)" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Selecting {PF.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>http://192.168.0.1/{1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Initiate scene</phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\cenas.xml</payloadFromXML>
  </command>
</commandGroup>

« Last Edit: May 17, 2015, 08:40:43 AM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: How to use payloads with scrape action for HTTP get requests
« Reply #2 on: May 17, 2015, 10:54:02 AM »
In VoxCommando, we can use different Scrape actions depending on the kind of HTTP request we want to do.

Scrape (simple HTTP Get request -- this is usually sufficient for common needs)

Scrape.Get (more sophisticated Get request)

Scrape.Post (HTTP Post request)

Scrape.Put (HTTP Put request)

etc.

http://voxcommando.com/mediawiki/index.php?title=Actions#Scrape

You can use the basic "Scrape" action if you do not need to specify any other header information in your HTTP get request. It accepts 3 parameters:
1. The URL (required)
2. User name (optional)
3. Password (optional)

Because you explained that you are able to enter a URL in your web browser to execute your home automation commands, I gave you 3 examples of how you can use the Scrape action to trigger your commands: http://192.168.0.1/t1 , http://192.168.0.1/t2 etc.

« Last Edit: May 17, 2015, 10:56:08 AM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

MárlonPrado

  • Jr. Member
  • **
  • Posts: 12
  • Karma: 0
    • View Profile
Re: How to use payloads with scrape action for HTTP get requests
« Reply #3 on: May 17, 2015, 02:50:06 PM »
Olá Nime5ter, muito obrigado por toda a orientação.
A função "Scrape" funcionou perfeitamente, no entanto, se eu utilizar payloads conforme o exemplo que você enviou, não funciona. Tanto para a função "Scrape" como para "OSD", não tem efeito quando executado.
Experimentei sem payloads e funcionou corretamente, então, não sei o quê estou fazendo errado quanto ao payload.
Coloquei o arquivo "cenas" dentro do diretório c:\VoxCommando\payloads.
De qualquer forma, já é um grande avanço pra mim ter conseguido executar o comando, e só preciso entender agora como criar comandos com payloads conforme seu exemplo.
Talvez esteja faltando configurar algum detalhe para funcionar o payload.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: How to use payloads with scrape action for HTTP get requests
« Reply #4 on: May 17, 2015, 03:05:53 PM »
How are you running (executing) the command?

Nime5ter gave you 3 different commands to test.  Did you try all three of them?  None of them work?  Can you explain what you mean by "does not work?".  This can mean many different things.

Based on your description, what you are trying to do is very simple if you know how to use VoxCommando. Unfortunately I think you are suffering from a total lack of understanding on how the program works.  This is a difficult problem to correct since you do not speak English.  I suggest you try to view the wiki using a translation tool for websites such as the one built into chrome.

If you are using VoxCommando SP with the Portuguese language engine, then it is possible that the number range payloads will not work correctly.  If that is the case then the payloadXML file with words should work fine.  Or if you really only have 4 "buttons" then you can just create 4 separate commands and then you do not need to use payloads at all.

Maybe you can learn some things, and get some help in "PT-BR" over here:

http://www.xbmcbrasil.net/forumdisplay.php?fid=33

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: How to use payloads with scrape action for HTTP get requests
« Reply #5 on: May 17, 2015, 03:22:24 PM »
It is difficult because we don't speak a common language. :)

You still need to learn the basics of how VoxCommando works. This is the problem.

I don't know whether this message will translate well, but I will try to explain anyhow.

Explanation of how to test the commands

All of the command examples that I provided assume that you will test them using voice commands.

Before testing any new commands, you should save the command tree and close it, because VoxCommando needs to rebuild your command tree when you import or create new commands.

----

For the command "Press button (using a Payload List)":

You should test it using a voice command like: "Press button t1" or "Press button t2" etc. (You can first translate the English into PT-BR before testing it, if you are using the Portuguese speech engine).

-----

For the command "Press button (using a Payload Range)":

You should test it using a voice command like: "Initiate button number 1" or "Initiate button number 2" (Again, you can translate the English voice command phrases into PT-BR first).

----

For the command "Press button (using a Payload XML file)

You should test it using a voice command like: "Initiate scene Quarto de Natália" or "Initiate scene cozinha"

This is because the Payload XML file allows us to create a table. In the table, we pair "friendly phrases" with the value we want VoxCommando to use.

I have attached a picture of the Payload XML editor window, in case you did not see this.

---

I do not understand the sentence:
Quote
Tanto para a função "Scrape" como para "OSD", não tem efeito quando executado.

Maybe Google Translate is not translating properly.

OSD means "on-screen display". This action will simply open a window on the computer that is running VoxCommando to display a message.

In my commands, I use OSD actions to show which payload value VoxCommando has understood. This, of course, requires that you tell it which payload value to use in your voice command ...
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

MárlonPrado

  • Jr. Member
  • **
  • Posts: 12
  • Karma: 0
    • View Profile
Re: How to use payloads with scrape action for HTTP get requests
« Reply #6 on: May 17, 2015, 04:44:38 PM »
Olá James, desculpe minha ignorância quanto ao VoxCommando, mas o lado bom é que estou aprendendo com vocês.
Estou compreendendo claramente toda orientação que vocês tem me passado, apesar da tradução não ser muito boa pelo google.
Sim, estou utilizando o VoxCommandoSP com voz Português do Brasil.
Executei todos os procedimentos que Nime5ter orientou, e segue anexo duas imagens da execução do comando e o resultado OSD na tela.
Quando utilizo a função “Scrape” com o endereço na forma  (http://192.168.0.1/{6}), o programa não acessa a tabela do payload “cenas” fornecido pelo Nime5ter, mas quando coloco o endereço da forma (http://192.168.0.1/t6), funciona o comando, ou seja, parece que está faltando alguma coisa, seja na configuração ou na compatibilidade com a versão SP com voz Português do Brasil no VoxCommando.
James, eu não compreendi bem quando você fala dos payloads sendo usados com números ou palavras e peço um exemplo se for possível.
Nime5ter, eu segui todos os procedimentos que você passou, inclusive traduzi as frases para o português dentro do editor de payload “cenas” que você enviou. Também reiniciei o VoxCommando todas as vezes que fiz alguma alteração.
Tudo bem se o recurso “payload” não funcionar pra mim, pois o principal já consegui com a função “Scrape”, porém, seria interessante continuar buscando uma solução para o payload, pois pode ser útil pra outros casos e também para outras pessoas do fórum VoxCommando.
Muito grato pela paciência de vocês para comigo.

MárlonPrado

  • Jr. Member
  • **
  • Posts: 12
  • Karma: 0
    • View Profile
Re: How to use payloads with scrape action for HTTP get requests
« Reply #7 on: May 17, 2015, 04:48:27 PM »
Segue a outra imagem

MárlonPrado

  • Jr. Member
  • **
  • Posts: 12
  • Karma: 0
    • View Profile
Re: How to use payloads with scrape action for HTTP get requests
« Reply #8 on: May 17, 2015, 04:55:16 PM »
Se for melhor falar do assunto "Payloads" em outro tópico do fórum, basta dizer e indicar o caminho, pois sei que aqui o tópico se refere à TCP IP.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: How to use payloads with scrape action for HTTP get requests
« Reply #9 on: May 17, 2015, 05:04:42 PM »
Quando utilizo a função “Scrape” com o endereço na forma  (http://192.168.0.1/{6}), o programa não acessa a tabela do payload “cenas” fornecido pelo

Do NOT edit my command. Translate it to PT-BR, but do not try to change the syntax.

Use {1} only.

You do not have 6 payloads. You have 1 payload, with 6 (or more) possible values.

The 1 payload will be

t1

or

t2

or

t3

etc.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

MárlonPrado

  • Jr. Member
  • **
  • Posts: 12
  • Karma: 0
    • View Profile
Re: How to use payloads with scrape action for HTTP get requests
« Reply #10 on: May 17, 2015, 05:09:34 PM »
Sim Nime5ter, eu não alterei a sintaxe. O que fiz também foi criar um exemplo sem o uso do payload.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: How to use payloads with scrape action for HTTP get requests
« Reply #11 on: May 17, 2015, 05:16:14 PM »
Your screen images show {6}.

{6} is not correct. That is why I indicated that you should not change the syntax.


{1} refers to the part of the voice command that you want to pass to the command macro. This is the value that changes.

You only have 1 value that you want to pass to the command macro --> this is the payload.

Sometimes, we may want to pass multiple different values at the same time to a command, that is when we would use {1}, {2}, {3}, etc.

But in your case, you do not need multiple payloads. Just one. So, just {1}.

I will try to create a visual example, but it will take some time.

TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

MárlonPrado

  • Jr. Member
  • **
  • Posts: 12
  • Karma: 0
    • View Profile
Re: How to use payloads with scrape action for HTTP get requests
« Reply #12 on: May 17, 2015, 05:28:48 PM »
Entendi Nime5ter, vou verificar se consigo e depois reporto aqui.
Não se preocupe em perder tempo criando imagens de apoio, pois estou compreendendo o que você quer dizer.
Falta apenas uma experiência de conhecimento do VoxCommando da minha parte  ::dis
Obrigado por tudo  :D

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: How to use payloads with scrape action for HTTP get requests
« Reply #13 on: May 17, 2015, 07:22:48 PM »
OK. Maybe this will help.

I am sorry if the Portuguese is very bad. You can blame Google Translate.  :biglaugh



I do not speak Portuguese. I am using the TTSMS voice to speak the voice commands because I cannot.

VoxCommando hears what she says, and this triggers the command, which responds.
« Last Edit: May 17, 2015, 07:31:35 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: How to use payloads with scrape action for HTTP get requests
« Reply #14 on: May 17, 2015, 07:26:25 PM »
Here are the commands used in the video.

They do nothing useful: It is just the computer providing feedback based on the voice command.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.5-->
<commandGroup open="True" name="Examples from the video" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="698" name="PAYLOAD RANGE -- Mostra-me {1} unidades" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Você pediu para ver {1} unidades</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTSMS.Speak</cmdType>
      <params>
        <param>Você pediu para ver {1} unidades</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Mostra-me</phrase>
    <payloadRange>2,10</payloadRange>
    <phrase>unidades</phrase>
  </command>
  <command id="696" name="PAYLOAD LIST -- Mostre-me uma maçã" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Aqui é o seu {1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTSMS.Speak</cmdType>
      <params>
        <param>Aqui é o seu {1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Mostre-me uma</phrase>
    <payloadList>laranja, maçã, banana</payloadList>
  </command>
  <command id="694" name="2 PAYLOADS -- {1} a luz {2}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)Contains(B)</ifType>
      <ifParams>{1}&amp;&amp;Ligar</ifParams>
      <then>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <params>
            <param>Acender a luz no {2}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTSMS.Speak</cmdType>
          <params>
            <param>Acender a luz no {2}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <params>
            <param>Desligar a luz do {2}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTSMS.Speak</cmdType>
          <params>
            <param>Desligar a luz do {2}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <payloadList>Ligar, Desligue</payloadList>
    <phrase>a luz na, a luz no</phrase>
    <payloadList>cozinha, quarto</payloadList>
  </command>
</commandGroup>
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)