We have moved at community.getvera.com

Author Topic: Virtual Device - Flag  (Read 32529 times)

Offline denix

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1088
  • Karma: +1/-0
Re: Virtual Device - Flag
« Reply #30 on: January 15, 2010, 06:23:04 pm »
Instead of a real motion sensor (Arm/Bypass) you can use a real switch (On/Off), if it's not used to control any actual loads. Especially if it's located close to the entry/exit in your place. You can query its state from Lua similarly. The only reason you may need to use a virtual device, is when you don't have any real devices with unused Arm/Disarm or On/Off states.

Otherwise, it doesn't matter which room the "Away-state" device (be it real or virtual sensor or switch) is in - you can enable/arm or disable/disarm it from scenes in any room by any means, such as in-wall scene controller or remote scene controller or cellphone etc.

For example, I have a global scene called "Away & Arm", which does the following:

Turn all the devices/lights off
Turn foyer light on, after 30 seconds turn it off
Set my Away sensor to Bypass, after 30 seconds set it to Arm

And all my scenes, which only need to work when someone's home, check if Away sensor is Armed or not...

So, when I run this "Away & Arm" scene either from a remote or from a cellphone, I have 30 seconds to leave and close the door in a well-lit environment. :)

Of course, people with real security panels would also want to actually Arm the panel in this scene... ;D
Veras (1, 2, 3, Lite, Plus), lots of different Z-Wave modules, Luup plugins and theater/security integration.

Offline myhomeserver

  • Hero Member
  • *****
  • Posts: 874
  • Karma: +3/-5
  • http://www.MyZwave.net
Re: Virtual Device - Flag
« Reply #31 on: January 19, 2010, 04:49:16 pm »
I got this working properly and now have an ON/OFF Virtual Device that I use when I'm away.  When I'm home it's off, and when I leave I flip it on. This arms the motion sensor and turns on all the lights when tripped (so my cams will capture images nicely) and it also sends me a txt msg. 

I'd like to make a scene that I can use this virtual device in, how can I add this and does anyone have the code I'd need to add this?  I know it's a Virtual device and those don't show in the list of devices for a scene

Any help would be appreciated, thanks!
 
MyZWave.net - See Our Z-Wave product Reviews
(formerly MyHomeServer)

Offline denix

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1088
  • Karma: +1/-0
Re: Virtual Device - Flag
« Reply #32 on: January 19, 2010, 05:21:39 pm »
Veras (1, 2, 3, Lite, Plus), lots of different Z-Wave modules, Luup plugins and theater/security integration.

Offline myhomeserver

  • Hero Member
  • *****
  • Posts: 874
  • Karma: +3/-5
  • http://www.MyZwave.net
Re: Virtual Device - Flag
« Reply #33 on: January 19, 2010, 07:03:03 pm »
I am, and I have the Binary switch working but want to make a scene that sets the "away" mode, now I have to go into the room and turn the virtual device ON. I'd like to simply execute a scene so I can assign that scene to a remote control button on my GE 45608 and have it tell Vera to turn off the lights and set the away switch to ON

thanks!
MyZWave.net - See Our Z-Wave product Reviews
(formerly MyHomeServer)

Offline denix

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1088
  • Karma: +1/-0
Re: Virtual Device - Flag
« Reply #34 on: January 19, 2010, 08:11:29 pm »
but want to make a scene that sets the "away" mode

http://forum.micasaverde.com/index.php?topic=2355.msg11957#msg11957

Scenes -> Add scene -> Name: "Set away state" -> Loop scene, and Copy/Paste the "set state" code sample from the post above

Scenes -> Add scene -> Name: "Reset away state" -> Loop scene, and Copy/Paste the "reset state" code from the post above

In the scenes which depend on the away state, use the "test state" code sample from the post above
Veras (1, 2, 3, Lite, Plus), lots of different Z-Wave modules, Luup plugins and theater/security integration.

Offline michaelk

  • Hero Member
  • *****
  • Posts: 633
  • Karma: +0/-0
Re: Virtual Device - Flag
« Reply #35 on: January 29, 2010, 11:44:03 pm »
this probably is a little basic so forgive me- I'm trying to make a virual flag for it's dark outside.

I gloomed 325xi's code for a binary device (thank you very much!)  and successfully created my virtual "it's dark outside" device. I can flip the status in the test luup window with:
luup.variable_set("urn:upnp-org:serviceId:SwitchPower1","Status",1,27) to turn on
-and-
luup.variable_set("urn:upnp-org:serviceId:SwitchPower1","Status",0,27) to turn off (the viirtual device is #27)

But to trigger it automatically I'm a little confused.  

Can i use the timer for sunrise and sunset and then just put the above  code bits in the luup scene box? Or do I need to ignore the built in timers to trigger and include even the trigger in the luup scene? If i have to include the trigger than I'd gloom ap15e's code for sunrise and sunset here: http://forum.micasaverde.com/index.php?topic=2073.msg8132#msg8132


Offline lyonne

  • Sr. Newbie
  • *
  • Posts: 29
  • Karma: +0/-0
Re: Virtual Device - Flag
« Reply #36 on: January 30, 2010, 08:08:58 am »
I have a sun up scene and another sun down scene to control the virtual device (appropriately named "sun").  I use the sunrise and sunset timers.  This way it is only one line of lua code in each scene to set the status of the sun.  Then I just poll the status of the sun for day/night dependent scenes.
Version 1.0.996 -- Schlage Lock, WD-20 Thermostat, HSM100 and a boatload of switches and outlets.

Offline michaelk

  • Hero Member
  • *****
  • Posts: 633
  • Karma: +0/-0
Re: Virtual Device - Flag
« Reply #37 on: January 30, 2010, 12:45:00 pm »
I have a sun up scene and another sun down scene to control the virtual device (appropriately named "sun").  I use the sunrise and sunset timers.  This way it is only one line of lua code in each scene to set the status of the sun.  Then I just poll the status of the sun for day/night dependent scenes.


I did basically the same and it seems to work (but it's only been onesunrise- so fingers still crossed- laughing) . I used the sunrise and sunset times and then plugged in the appropriate single line of code i have above under the luup scene bit.

honestly I'm still a bit confused but i'll just go with it  ;D  So the luup scene button can have conditions and commands in it.  But i  gues if there is an event/timer trigger than that has to be true first before the luup scene condition or comman kicks in.

Offline lyonne

  • Sr. Newbie
  • *
  • Posts: 29
  • Karma: +0/-0
Re: Virtual Device - Flag
« Reply #38 on: January 31, 2010, 06:27:23 am »
Your understanding is the same as mine and it seems to work.  The other complication is the LUA event code that executes within a scene only when an event is true.
Version 1.0.996 -- Schlage Lock, WD-20 Thermostat, HSM100 and a boatload of switches and outlets.

Offline michaelk

  • Hero Member
  • *****
  • Posts: 633
  • Karma: +0/-0
Re: Virtual Device - Flag
« Reply #39 on: January 31, 2010, 10:40:28 pm »
Virtual devices do not show up in the device list in scenes. You must use Lua code to set, reset, or interrogate.

It does show up in Devices | Lua Devices however.

seem  there's no way to trigger actions when these virtual devices change at the moment even with lua code;   some other “event”  first has to trigger the lua code?

We're releasing a new UI next week (hopefully) which addresses these issues by allowing devs to create new device icons and controls in xml/json files which get populated in the UI.  This includes the ability to add your devices into the scene structure.


but the impending new release will allow us to use virtual devices state changes as the "event" to trigger other commands (and/or luup code)?

Man I can’t wait for the new version!  
 :)

Offline 325xi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1101
  • Karma: +0/-0
  • V1, V2, still V2...
Re: Virtual Device - Flag
« Reply #40 on: January 31, 2010, 11:07:29 pm »
If this virtual device idea is as popular as it seems ti be, it might be a good idea to ask MCV to add "native" virtual device and virtual sensor - with full functionality. This would allow to have a unified way to build and use this sort of devices. Besides making things plain simpler to develop, it would improve compatibility and interoperability between plugins and components.

Offline denix

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1088
  • Karma: +1/-0
Re: Virtual Device - Flag
« Reply #41 on: January 31, 2010, 11:09:54 pm »
I second that!

I, for example, prefer basing Virtual Flag Device from a Motion Sensor instead of a Binary Switch. But either way unified interface would only help us all!
Veras (1, 2, 3, Lite, Plus), lots of different Z-Wave modules, Luup plugins and theater/security integration.

Offline michaelk

  • Hero Member
  • *****
  • Posts: 633
  • Karma: +0/-0
Re: Virtual Device - Flag
« Reply #42 on: February 01, 2010, 05:21:05 pm »
I'd prefer it just be built in as well. But sounds like the new update will allow someone (HINT HINT- LOL) to make a solid virtual device that can have pretty status icons and also act as a triggering event. Then they could just chuck that new device in the gallery of luup plugins and it would be just as well.

As someone wrote above (or in another related thread)- from the days of x-10 we could just make piles of the virtual devices without any problem. I thought i had it all figured out- dug out an old usb-> serial adapter and a insteon/x10 wall wort i had to try and hook it up just so i could trick vera into having some easy to set and respond to virtual devices. But after i fiddled for a couple hours I realized i had the "bad" inteon controller so was out of luck.

Myself- just got the vera a few weeks ago, but already I imagined a state variable for day/night, home/away, vacation or not, and my wife is chilly or not (to jack the thermostat set points by a couple degrees). that's without even trying to thing about anything.  :)

« Last Edit: February 01, 2010, 05:33:00 pm by michaelk »

Offline CMRancho

  • Hero Member
  • *****
  • Posts: 1008
  • Karma: +1/-0
Re: Virtual Device - Flag
« Reply #43 on: February 02, 2010, 09:28:48 am »
Myself- just got the vera a few weeks ago, but already I imagined a state variable for day/night, home/away, vacation or not, and my wife is chilly or not (to jack the thermostat set points by a couple degrees). that's without even trying to thing about anything.  :)

Yes, we all agree with you. This is one of the most basic controls I can imagine for operation in any HA system. Even $20 motion sensor lights have the good sense not to turn on when it's light outside. Any here we are with a very flexible (and by comparison, very expensive) system that is too stupid to do this. Unless you're a programmer. <end rant>
Vera123beta; Schlage, Kwikset, TZEMT400; Linksys cams, Smarteye cams, HSM100; Aeon, Everspring, Cooper, Leviton, Intermatic, FortrezZ, Global Caché, USB-UIRT, Somfy, etc.

Offline woodsby

  • Beta Testers
  • Sr. Member
  • *****
  • Posts: 466
  • Karma: +1/-0
Re: Virtual Device - Flag
« Reply #44 on: February 02, 2010, 05:14:42 pm »
Sunrise/sunset sensor - See attached.  Same concept - call_timer... Should start working at first sunset after installing,  Install all three files at the luup files screen. Create event-based scenes based on the sunrise or sunset events.

Just cleaned up the code this afternoon - test and confirm it works...
« Last Edit: February 02, 2010, 05:16:37 pm by woodsby »
Vera1 (1.1142), Vera2 (1.1182), VRI06 (12), VRS15 (3), VRS05 (2), VRF01 (2), VRCS4 (2), ZRW113, ZRF113 (2), 45602, 45603, TZMT400 (2), FE599 (2), 99100, Thinkstick, Harmony 890Pro (2), Harmony RF Extender, Nevo S70, Nevo NC-50, Minimote, SQ Remote, SQ Blaster, EtherRain-8, Cliste ActiveRFID, TED5002