Author Topic: Scrape continuously looking for Variable  (Read 1592 times)

0 Members and 1 Guest are viewing this topic.

sebaszz

  • Jr. Member
  • **
  • Posts: 8
  • Karma: 0
    • View Profile
Scrape continuously looking for Variable
« on: December 22, 2015, 03:48:49 AM »
My goal is to trigger the vc on/ off command by using scrape to get a variable from my fibaro controller.
I can get the variable and trigger by using the save and execute button. However it doesn't seem continously looking for the variable. How can can I do this?

Tried the search button but din't find the answer....


nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Scrape continuously looking for Variable
« Reply #1 on: December 22, 2015, 08:56:38 AM »
Commands in VC need to be triggered, either by a voice command or events. They then run once only, unless you re-trigger them somehow.

Based on the fact that you want to use this to turn VC on, you'd need to poll Fibaro at least once per second in order to get a quick response. That would be bad for Fibaro and for VoxCommando. (Every 15s or so might be more manageable.)

What is changing this "Listening_On" value on your Fibaro?

If you can have the Fibaro trigger an event in VC when that value changes, that would be much better than constant polling.

http://voxcommando.com/mediawiki/index.php?title=API_Application_Programming_Interface

**Polling should generally be avoided whenever possible.**


If this kind of manual polling is really the only option for your needs, it should be done using VC's Python plugin and some scripting, so that the polling takes place in a separate, background thread. For an example, see http://voxcommando.com/forum/index.php?topic=1679.0
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: Scrape continuously looking for Variable
« Reply #2 on: December 22, 2015, 10:10:48 AM »
Update: I see that Fibaro supports Lua scripting.

We have several threads on the forum that discuss how to send UDP messages from the Vera to VC to trigger events in VC using Luup scripting. Fibaro may permit something similar.

The wiki page I linked to above references those forum posts.
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)

sebaszz

  • Jr. Member
  • **
  • Posts: 8
  • Karma: 0
    • View Profile
Re: Scrape continuously looking for Variable
« Reply #3 on: December 23, 2015, 12:20:50 PM »
First of all, thank you for the response!

I agree trigger VC is much better to prevent polling. I just discovered the event option.
LUA scripting is possible, did some scripts before.

What I did now as test is using the VC webserver option, used the post field and used the following code:

VC.TriggerEvent:Listening&&ON

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.1.2-->
<commandGroup open="True" name="Fibaro Listening" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="287" name="Vox Listening Fibaro ON" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>ON&amp;&amp;{1}</ifParams>
      <then>
        <action>
          <cmdType>VC.On</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
    <event>Listening</event>
  </command>
  <command id="295" name="Vox Listening Fibaro OFF" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>OFF&amp;&amp;{1}</ifParams>
      <then>
        <action>
          <cmdType>VC.Off</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
    <event>Listening</event>
  </command>
</commandGroup>

I see the event in the history but it doesn't trigger the command.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Scrape continuously looking for Variable
« Reply #4 on: December 23, 2015, 12:47:02 PM »
Your commands are working fine for me, using your test method.

I used a POST request: VC.TriggerEvent&&Listening&&ON

It also worked for me using the same syntax and a GET request. That is, when I typed the following URL in to my browser address bar:

Code: [Select]
http://127.0.0.1:8080/api/VC.TriggerEvent&&Listening&&On
--

Is it possible that you tested these commands before you had saved and exited your command tree?

For events to trigger commands, the tree needs to be rebuilt with the new commands in them. That means you need to either save and exit the command tree window, or use File > Quick Restart if you want to leave the command tree window open.

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)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Scrape continuously looking for Variable
« Reply #5 on: December 23, 2015, 01:25:11 PM »
If you still can't get it to work please attach your VoxCommando log.

http://voxcommando.com/mediawiki/index.php?title=Getting_support#When_You_Ask

sebaszz

  • Jr. Member
  • **
  • Posts: 8
  • Karma: 0
    • View Profile
Re: Scrape continuously looking for Variable
« Reply #6 on: December 24, 2015, 05:54:40 AM »
Hmmm it's working now from the browser, probably didn't executed the command tree.  :o

I now posted topic in the fibaro forum. I used same type of code before in IP relay board but it is not working for voxcommando.


http://forum.fibaro.com/index.php?/topic/20334-http-get-command/

In meantime I will create a new log file.



nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Scrape continuously looking for Variable
« Reply #7 on: December 24, 2015, 09:45:06 AM »
The response you were given on the Fibaro forum makes sense to me.

If Fibaro is sending the Get Request, it should not be using 127.0.0.1. It needs to target the true IP address for the computer that is running VoxCommando.

When you were testing the command, you were testing on the machine running VoxCommando, so pointing to "localhost" was fine. https://en.wikipedia.org/wiki/Localhost

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)

sebaszz

  • Jr. Member
  • **
  • Posts: 8
  • Karma: 0
    • View Profile
Re: Scrape continuously looking for Variable
« Reply #8 on: December 24, 2015, 10:07:38 AM »
yes i changed the ip in my test as well

together with other suggestion it works now!

thank you for the great help!

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Scrape continuously looking for Variable
« Reply #9 on: December 24, 2015, 10:26:42 AM »
You're welcome. Thanks for reporting back on your progress.

Have fun with VoxCommando!
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)