Author Topic: What actions do I use?  (Read 3474 times)

0 Members and 1 Guest are viewing this topic.

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
What actions do I use?
« on: December 12, 2013, 04:34:07 PM »
Can someone help me create the logic for the following.  I'm struggling with what actions to use.

What I would like to do is... If an event is triggered between the hours of 7pm and 8pm mon-fri and the status of a certain lighting device is not "ON" Then

TTS- ddl is that you?

1) what action do I use to monitor triggering of an event?
2) how do I use VC to query the status of my ISY device?

Any help would be appreciated.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: What actions do I use?
« Reply #1 on: December 13, 2013, 02:21:54 AM »
Hi ddl.  Yes, I think I can help you with this after I get home tomorrow.

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: What actions do I use?
« Reply #2 on: December 13, 2013, 12:07:18 PM »
Ok,

Safe travels.

Thanks much

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: What actions do I use?
« Reply #3 on: December 13, 2013, 12:12:52 PM »
1) what action do I use to monitor triggering of an event?
2) how do I use VC to query the status of my ISY device?

1) Most of what you need to know about events is clearly explained here: http://voxcommando.com/mediawiki/index.php?title=Events

You can also watch the tutorial:


2) Did you read the ISY documentation?  Which model do you have?  I don't have one myself, but I imagine it is possible using the scrape action in VC with whatever http api the ISY makes available.

I'm not sure how you are going to generate events in VC based on your Insteon devices though.  You might have to poll the device on an interval depending on how the ISY api works.
« Last Edit: December 13, 2013, 02:05:12 PM by jitterjames »

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: What actions do I use?
« Reply #4 on: December 13, 2013, 04:45:06 PM »
ok, I will take a look at this afternoon.  Yes, I do have the documentation for the ISY.  I have the ISY994i/IR PRO. From the docs it looks like the VC.SetEventTimer is what I can use to get started.  However, I am still not clear on how to format the syntax.  Sorry if I am being stupid here.  But I just don't understand from viewing the videos.  Is it to much to ask for an example of what the syntax would look like?

example

Action = VC.SetEventTimer (is between 7 and 8pm) and

the status of my insteon motion detector is "On" (I think I can get the status of this device by creating a program in my ISY then having VC to scrape the program)

« Last Edit: December 13, 2013, 05:25:26 PM by ddl »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: What actions do I use?
« Reply #5 on: December 13, 2013, 06:04:38 PM »
I think you are failing to understand the actual meaning of the word event or at least the meaning of event within the context of VoxCommando (or other programs like EventGhost).

The way we use the word event is a bit different from the way you might think of it.  If your birthday is an event that lasts all day, it is not the same thing as an event in VC, or an event triggered by a Vera, or an ISY controller.  An event is something that happens once, at precise point in time (like a trigger), and is not something that can be defined over a time range.  If you read the description for the action VC.SetEventTimer (http://voxcommando.com/mediawiki/index.php?title=Actions#SetEventTimer) you will see that it says

Quote
VC.SetEventTimer
Creates a timer that triggers the event <EventName> after a period of time.

So calling this action will cause an event to occur, (for example) 30 seconds after the action is called.  (You choose the event name and the delay until it is triggered when you call the action, by specifying the parameters)

I don't think this is what you want.

I think what you will ultimately need is to have an event occur when the motion sensor goes off, but without knowing how to use the ISY api I'm not sure how this can be accomplished.

If I were using Vera it would work like this:

- Vera detects motion from a sensor
- Because the Vera plugin for VC has subscribed to events from the Vera controller an event will be generated in VoxCommando.  The event will be unique based on the device number of the motion sensor.
- This event will trigger a VC command (whichever command you assigned the event to).
- The command will check to see what time it is, and if the current time falls within a certain period then it will use a TTS action to say something.

I can give you an xml example of this but it won't help you because there is no plugin for the ISY so you need to find a way to detect when the motion has been triggered.  There are probably 2 ways to do this but please keep in mind that I am not familiar with this device or the API and I don't have the hardware so I cannot do any experiments to try to figure it out.

- One way is to write a loop that checks every x seconds to see if the motion sensor was triggered.  This is a bad choice since it is very wasteful, but it might be the only option.  It is also a pain to set up and might not be worth the trouble.  In order to do this in a way that will be stable and not clogging up the VC pipeline you will probably need to write a python script to do it.  If you can find some sample python code which performs this type of function, then maybe I can help you adapt it to work in VC.
- A better way would be to subscribe to the ISY for events.  Unfortunately I don't know how the ISY works, so in this case I can't give you an example of how to do it.

You say that you are very familiar with the ISY api so maybe once you become more familiar with VC will you find a way to do it.
« Last Edit: December 13, 2013, 06:20:05 PM by jitterjames »

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: What actions do I use?
« Reply #6 on: December 13, 2013, 06:36:04 PM »
James,

Thanks for your detailed response. 

I will abandon my efforts for this until I learn more about VC and the ISY.  When I said that I was familiar with the ISY.  I meant from a user perspective not a developer.:(

Thanks again.

d

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2319
  • Karma: 47
    • View Profile
Re: What actions do I use?
« Reply #7 on: December 13, 2013, 06:44:48 PM »
« Last Edit: December 13, 2013, 07:15:37 PM by Kalle »
***********  get excited and make things  **********

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: What actions do I use?
« Reply #8 on: December 13, 2013, 08:04:25 PM »
All,

Does this help?.  I posted a question on the Universal Devices forum.  This is what they suggested.


You can always use our Web Services APIs to subscribe to ISY: http://www.universal-devices.com/isy-developers.  Also you should be able to subscribe to ISY as long as you keep either a socket open or a URL to which ISY can publish its events.
« Last Edit: December 13, 2013, 08:34:29 PM by ddl »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: What actions do I use?
« Reply #9 on: December 13, 2013, 09:25:39 PM »
Maybe... but probably not just using existing plugins and actions.  If one could decipher the api documentation then one could probably do it by creating a plugin, or writing a python script.

Actually what might work better and be easier to set up,  would be to have a "program" on the ISY use the network module to send a message to VC using either HTTP, TCP, or UDP.  Are you able to do this?  I think you might need to buy the network module and don't actually know what the program code would look like on the ISY but I believe it is possible.  If you can figure out how to send a UDP message from an ISY program then you are all set, because I think you can then set your triggers and schedules within the ISY and sending events to, or calling actions in VC using UDP, TCP or HTTP is very easy.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: What actions do I use?
« Reply #10 on: December 13, 2013, 09:29:42 PM »
Hi James and ddl, maybe this can help  ::hmm

http://forum.universal-devices.com/viewtopic.php?f=27&t=7274

or this

http://wiki.universal-devices.com/index.php?title=Main_Page

Yes Kalle, I've looked at those links, especially the one on eventGhost.  I was reading that thread hoping to find a way to send an event to VC but there is no example code provided.

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: What actions do I use?
« Reply #11 on: December 13, 2013, 10:12:55 PM »
Hi Jitterjames,

Yes, I do have the network module and I believe I can figure it out.  I will try your suggestion and report back ASAP.  I am excited to know that this can be done.  I will try to figure out how to send you a screen shot of what the code structure looks like in the networking module of the ISY.  I will need your help in trying to figure out how to pass the command to VC.

Thanks again.  I really appreciate all the help.


ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: What actions do I use?
« Reply #12 on: December 13, 2013, 10:23:20 PM »
Here are a few images of screen shots of where I would place the code in the networking module.



« Last Edit: December 13, 2013, 11:03:38 PM by ddl »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: What actions do I use?
« Reply #13 on: December 14, 2013, 09:30:31 AM »
This looks very promising.  Assuming you are able to set your ISY 994 up to trigger this program when you want it to, I don't think you will have any problems.

- Select the UDP protocol
- Set the port to 33000 (unless you have changed the default UDP listen port in VC options on the advanced tab)
- Set the host to the IP address of your windows computer that is running VoxCommando (or you can try 255.255.255.255 to broadcast to all machines on the LAN)
- You can try different settings for mode, but you will probably want "raw"
- in the "body" you can put your message to send to VC.

You can call an action like this:
Code: [Select]
TTS.Speak&&this is a test
Or if you want to execute a command you can generate an event which can be assigned to any command
Code: [Select]
Event&&Test.Thing
If you wanted to generate an event to make VC speak, but you wanted VC to do several things (maybe to use softmute, then speakSync, then softunmute, for example) then you could send an event with a payload.

Code: [Select]
Event&&ISY.TTS&&Hello again, is that you JoeNow any command that has the ISY.TTS event assigned to it will be triggered and will have access to payload 1 which in this case will be equal to: Hello again, is that you Joe

Here is an example of a command that could do this:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="234" name="isy tts test" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>XJson.SoftMute</cmdType>
    <cmdString>50</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.SpeakSync</cmdType>
    <cmdString>{1}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>XJson.SoftUnMute</cmdType>
    <cmdString />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>ISY.TTS</event>
</command>
« Last Edit: December 14, 2013, 09:34:07 AM by jitterjames »

ddl

  • Sr. Member
  • ****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: What actions do I use?
« Reply #14 on: December 14, 2013, 11:47:05 AM »
JitterJames,

Thank you! thank you! thank you!  JitterJames, I must say that you all are amazing!!  I was able to get the first part accomplished per your instructions.  Passing the codes from the ISY to VC worked great.  Now, all I need to do is spend a bit more time understanding how to put it all together to accomplish what I want VC to do which is what I have written above.  In the ISY. I can manage writing a program with the conditions (if time is... then....) and getting it to VC  just fine.  Its the second part I get all confused about.  I think I may need to understand a bit more about events, assigning commands to event and etc in VC.

Here is what I have done so far:

In the ISY I have created a resource. See image isy7.  To reference the resource.  I created a program that has the conditions that will trigger the resource.  See image isy6.  

Since all I wanted to do here was have VC to speak "Hi Joe is that you?".  This part was easy.  Its where I begin to try to create events and commands in VC I get all twisted up. I'll spend more time with trying to understand that part today.