Author Topic: Triggering VC command with a vera scene  (Read 4763 times)

0 Members and 1 Guest are viewing this topic.

Casmo

  • $upporter
  • Contributor
  • *****
  • Posts: 85
  • Karma: 0
    • View Profile
Triggering VC command with a vera scene
« on: January 19, 2015, 12:29:21 PM »
Hi All,

 Previously I had a motion sensor triggered 'coming home' vc command that did the following; (with an 'away' variable taking care of the logic)

-turn on tv
-turn on hue lights
-tts greeting/time/you have x new emails
-launch xbmc party mode

I've moved the tv and lights actions to the vera so I now have a motion sensor triggered vera 'coming home' scene. I simplified the vc command so once the vera scene is launched, the vc command does the following;

-tts greeting/time/you have x new emails
-launch xbmc party mode

This works fine, but at random times the vc command is triggered when the vera scene has not been launched.
I used vera1.scene1.active as the vc trigger. I'm just a bit unclear as to how vc vera polling works and how you should trigger a command using a vera scene.

Any advise welcome, thanks..




jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Triggering VC command with a vera scene
« Reply #1 on: January 19, 2015, 01:25:35 PM »
This is how Vera generates "scene active" events.  If a scene is defined as lights A,B, and F are on, then when lights A,B, and F are turned on Vera will generate an event to say that this scene is active.  This can be annoying but good luck getting Vera to change it.

It may make more sense for you to use the motion trigger to trigger your VC command instead of the scene event.

Or you can add some LUUP/LUA code in your Vera scene that will send an event to VC.  This way it will only send it when you actually trigger the scene on purpose.
« Last Edit: January 19, 2015, 01:28:08 PM by jitterjames »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Triggering VC command with a vera scene
« Reply #2 on: January 19, 2015, 01:26:29 PM »

This works fine, but at random times the vc command is triggered when the vera scene has not been launched.

As explained above, it is not "random"

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Triggering VC command with a vera scene
« Reply #3 on: January 19, 2015, 01:36:26 PM »
Here is an example of the luup code you can put into your scene:

Code: [Select]
local socket = require "socket"
local udp = socket.try(socket.udp())
assert(udp:setoption("broadcast", true))   
socket.try(udp:sendto("event&&Vera.MyScenes.Home", '255.255.255.255', 33000))

If you are going to do this in more than one or two scenes then it is better to define a function in your Vera's "Startup Lua".  On UI5 you can go to "APPS", then "Develop Apps" then "Edit Startup Lua" and put this code in:
Code: [Select]
function sendVC(strMessage)
   local socket = require "socket"
   local udp = socket.try(socket.udp())
   assert(udp:setoption("broadcast", true))   
   socket.try(udp:sendto(strMessage, '255.255.255.255', 33000))
end -- sendVC

and then in any scene all you would need to put in the LUUP box would be
Code: [Select]
sendVC("event&&Vera.MyScenes.Home")
« Last Edit: January 19, 2015, 01:40:55 PM by nime5ter »

Casmo

  • $upporter
  • Contributor
  • *****
  • Posts: 85
  • Karma: 0
    • View Profile
Re: Triggering VC command with a vera scene
« Reply #4 on: January 19, 2015, 04:34:25 PM »
Ah, I see. Great explanation, thanks.
What I love about this stuff is how there's usually more than one way of achieving what you're trying to do..

keithj69

  • $upporter
  • Sr. Member
  • *****
  • Posts: 113
  • Karma: 7
    • View Profile
Re: Triggering VC command with a vera scene
« Reply #5 on: January 28, 2015, 05:06:22 PM »
I have pretty much the same scene for coming home as you do.   I may have gone about it in a very round about way, but i did so to avoid the issue you mentioned. 
 equipment used - vera lite, hue lights, harmony home hub,door sensor,  xbmc, pc with vc.
vera things used to accomplish this.  pleg, a couple of timers, virtual switch and scenes

There  may be a better way to do this, but this works for me.
When I leave, Vc reads me the current weather, runs a vera scene.  In the scene is a 10 minute timer that arms a pleg device that states "if armed and the front door opens turn virtual switch to on". 
(timer is set to 10 minutes in case i have to come back home real quick. Plus without it, by the time I gave the leaving command and made it to the front door, it would be armed so the I'm home scene would run)


So what happens when i get home, as soon as I open the door, the virtual switch triggers vera and Vc to run through my commands.
It disarms pleg, my hue lights turns on, I am greeted by Lemon(vc) and she tells me the temps in the living room, media room, turns on the tv/stereo/xbmc to party mode.  After a 3 second timer the virtual switch is turned off.

I hope that made some sense.