We have moved at community.getvera.com

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

Offline brsipaq

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +1/-0
Virtual Device - Flag
« on: September 28, 2009, 03:19:53 pm »
Greetings,

I'm interested in a 'Virtual' Device, call it a virtual binary flag, that I can use to indicate whether I'm home or not.  I would create 'Scenes' to turn it on or off.

I would like then to create events that would test whether this device was 'on' or 'off' based on certain times of the day or night.  Ultimately I'd like some random function, but first steps first.

I tried to add a device based on the D_BinaryLight1.xml file, but I got an error something to the affect of no implementation.

If someone has the proper D_, S_, I_ files, I would greatly appreciate it.  Or if someone smarter than me could point me in the proper direction, I would attempt to build one.

Thanks in advance.
Controllers - Vera firmware 979 Dongle version 2.78 L:1, GE 45601 and 45608, HA07c, HA09c
Outlets/Switches - HA01c, (2) HA02c, (4) VRI06, (2) VRS15, HA04c (Not used yet) Sensor - HRDS1 Door/Window (garage door) Thermostat - WDTC-20 IP Camera - Linksys WVC54GCA

Offline TedStriker

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +2/-0
Re: Virtual Device - Flag
« Reply #1 on: September 30, 2009, 05:28:47 pm »
Hi brsipaq,

you may use the ?_AwarenessSensor.xml files from the Ping Sensor.
As I started writing it, I had the same idea you are having now. I wanted to have a generic binary device which could be controlled by whatever trigger I could think of.
If you want, you can rewrite the plugin itself. http://wiki.micasaverde.com/index.php/Ping_Sensor_Plugin
Currently the "ping" is the event which changes the binary state. If you erase that functionality, then you can replace it, by whatever function you want, or trigger it even by UPnP calls.

Offline brsipaq

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +1/-0
Re: Virtual Device - Flag
« Reply #2 on: October 02, 2009, 11:08:55 am »
I tried to take your Awareness sensor.  I created a D_ file and loaded it.  I have your Ping working, so I thought it would just load and I'd get the ARM/DISARM ui, but I get nothing showing up in the device.

In your Ping Sensor LUA code, there's a comment about having to reload LUA to make the UI work.  What is that all about.

Any ideas on why the UI wouldn't work?

Thanks,
Brian
Controllers - Vera firmware 979 Dongle version 2.78 L:1, GE 45601 and 45608, HA07c, HA09c
Outlets/Switches - HA01c, (2) HA02c, (4) VRI06, (2) VRS15, HA04c (Not used yet) Sensor - HRDS1 Door/Window (garage door) Thermostat - WDTC-20 IP Camera - Linksys WVC54GCA

Offline TedStriker

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +2/-0
Re: Virtual Device - Flag
« Reply #3 on: October 08, 2009, 04:58:46 am »
Hi brsipaq,

I've got news for you. Due to the fact that I need such a virtual device too, I'm going to create one.
I'll update this thread and wiki when it's done.
Maybe it's already done next week. :)

Offline 325xi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1101
  • Karma: +0/-0
  • V1, V2, still V2...
Re: Virtual Device - Flag
« Reply #4 on: October 08, 2009, 08:37:35 am »
It might be easier to use binary switch on/off for this purpose

Offline LibraSun

  • Hero Member
  • *****
  • Posts: 574
  • Karma: +2/-0
Re: Virtual Device - Flag
« Reply #5 on: October 08, 2009, 10:14:19 am »
Guys, it just occurred to me (again) that back in the olden days of X10, it was quite simple and straightforward to create numerous "fictitious devices" for the purpose of having "flags".

X10 didn't mind one bit whether the physical device actually existed or not.  You could declare a switch, say, using a certain code (A5, for example).  It was then completely OK to use IF-THEN constructs such as:  "IF (A5)=ON THEN SET (A5, B4) OFF"

No problem.  Of course, all this was possible, because X10 was completely ignorant of whether devices ACTUALLY were 'On' or 'Off' (because unlike Z-Wave, X10 devices did not report status).  By comparison, Z-Wave is rigid in what it allows, but pays back dividends in reliability and reporting ability.

Nice that you're onto a work-around for this "limitation" ... something MCV ought to have considered from the outset of Vera.
Vera Model I running UI4 (Firmware 1.1.1338), died in 2015
Vera Plus running UI7 (Firmware 1.7.2935)

Offline TedStriker

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +2/-0
Re: Virtual Device - Flag
« Reply #6 on: October 08, 2009, 01:46:42 pm »
It might be easier to use binary switch on/off for this purpose

of course ;) thank's for the hint.
I'll create another AwarenessSensor for this, I guess.

Offline brsipaq

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +1/-0
Re: Virtual Device - Flag
« Reply #7 on: October 08, 2009, 03:06:51 pm »
I tried the Binary Switch device.  But whenever I clicked the ON or OFF button, I get an 'Implementation' Error.

Then I tried a "Motion Sensor" device.  And it created the UI under the LUUP devices, and after awhile the UI showed up.  I could click the ARM / DISARM buttons, and even enter a Tripped value of 0 or 1.  No 'Implementation' Error.  However, I couldn't use the LUUP get variable (or even set Variable) code to test or set them....

Until I loaded version 949.  Now it works.

So I have 'Motion Sensor' called 'We Are Gone' flag.  I now have a Living room light that has an event that triggers at sunset.  My Luup code tests if my We Are Gone flag is ARMED, if so it returns true, which allows the scene to continue and turn the light on.

I then have a late night event that will do the same test and turn it off.

If this flag is DISARMED, it returns false and does nothing.

So it appears to work in my testing.

Now for a 'Randomize' function....

Brian
Controllers - Vera firmware 979 Dongle version 2.78 L:1, GE 45601 and 45608, HA07c, HA09c
Outlets/Switches - HA01c, (2) HA02c, (4) VRI06, (2) VRS15, HA04c (Not used yet) Sensor - HRDS1 Door/Window (garage door) Thermostat - WDTC-20 IP Camera - Linksys WVC54GCA

Offline mpenda

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +1/-0
Re: Virtual Device - Flag
« Reply #8 on: October 08, 2009, 07:01:31 pm »
Did you use the D_MotionSensor1.xml file?
I created one and I never get the ARM/DISARM options on the device.
I tried the binary switch and, like you, got the implementation errors.
I'm also at 949.
v1.0.980, HA09C, HA07C, WDTC-20, HRDS1, BLC131A, SM103, ZIR000, HA-18WD, ZRW103, HA02C, HA03C

Offline brsipaq

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +1/-0
Re: Virtual Device - Flag
« Reply #9 on: October 09, 2009, 08:58:50 am »
Yes, that's the XML file I used.  It took awhile for the UI to ultimately show up.  I rebooted the router a couple of times.  Can't remember, but it took several of these attempts, maybe 30 minutes or so, but ultimately it showed up.

I did a second one and it also took awhile, but it also showed up.  So while not pretty, it is repeatable.

Then I used the following to test the Arm and Tripped variables (my device is 49):
luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",0, 49)
luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",0, 49)
This code did not work before version 949.

Once I knew I could set / get readings, I have the following in my 'Scenes' (WAG = We Are Gone; Armed = 0 means it is disarmed):

local WAGStatus = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",49)
if (WAGStatus == "0") then
    return false
end
return true
Controllers - Vera firmware 979 Dongle version 2.78 L:1, GE 45601 and 45608, HA07c, HA09c
Outlets/Switches - HA01c, (2) HA02c, (4) VRI06, (2) VRS15, HA04c (Not used yet) Sensor - HRDS1 Door/Window (garage door) Thermostat - WDTC-20 IP Camera - Linksys WVC54GCA

Offline mpenda

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +1/-0
Re: Virtual Device - Flag
« Reply #10 on: October 09, 2009, 04:13:12 pm »
Right you are, after about 18 hours it showed up. Why so long? Dunno.

Thanks for the code snippets....I'll tinker this weekend.
v1.0.980, HA09C, HA07C, WDTC-20, HRDS1, BLC131A, SM103, ZIR000, HA-18WD, ZRW103, HA02C, HA03C

Offline mpenda

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +1/-0
Re: Virtual Device - Flag
« Reply #11 on: October 09, 2009, 07:59:07 pm »
Works great.
I have a question. What's the command to embed a delay? Is there a "sleep" command by chance?
I've got the ping sensor set up, but I want to base the modem restart on TWO addresses being down, not just one. So I plan to ping one address and if it fails, arm a virtual device, if the second fails, sleep for a few minutes, then check that the other device is armed and THEN do the reboot.

v1.0.980, HA09C, HA07C, WDTC-20, HRDS1, BLC131A, SM103, ZIR000, HA-18WD, ZRW103, HA02C, HA03C

Offline 325xi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1101
  • Karma: +0/-0
  • V1, V2, still V2...
Re: Virtual Device - Flag
« Reply #12 on: October 09, 2009, 08:29:13 pm »
I wrote a simple virtual switch based on binary switch, took about 5 minutes, it "just works", and you can stuff it with any logic you can think about.

http://edmidor.com/simple-state-device-for-vera/
« Last Edit: February 22, 2011, 11:13:00 pm by 325xi »

Offline denix

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1088
  • Karma: +1/-0
Re: Virtual Device - Flag
« Reply #13 on: October 10, 2009, 12:13:21 am »
@325xi: any examples of how to use it?
Veras (1, 2, 3, Lite, Plus), lots of different Z-Wave modules, Luup plugins and theater/security integration.

Offline 325xi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1101
  • Karma: +0/-0
  • V1, V2, still V2...
Re: Virtual Device - Flag
« Reply #14 on: October 10, 2009, 12:18:07 am »
Well, that was an example of how to make a virtual device; as for how to use it read this thread :)

Basically it's a logical flag that you can control in a convenient way just as a regular switch. You assign the meaning, and use it in scenes: "do this, but if that virtual device is On, do something else"