LUUP Plugin/Virtual Device not responding to Scene Commands

So through a lot of help via the forum, I successfully created a simple LUUP Plugin virtual device that I use as a flag to indicate whether or not my vacation home is occupied, which I in turn use to control execution of certain scenes/timers. That aspect is working just fine.

However, the master scenes that I use when I either arrive at, or leave, my vacation home has a simple command to arm/disarm that virtual device, and those commands are not getting executed. The device is not arming/disarming. To ensure it wasn’t a problem with the scene itself - like a possible issue with other commands kluging up the executing of the arm command - I created a separate test scene with only a single command - to arm the virtual device/flag. It is not working, so clearly I’m doing something wrong -or- for reasons I may never understand, it’s not possible for scenes to issue commands to Luup Plug-in/virtual devices.

I can still go to the device itself and arm/disarm it, and that works fine, so my device seems to be OK. It’s just not responding to scene commands.

If anyone has any ideas, your feedback would be appreciated. Everything else with my Vera works like a charm, and once I figured out this virtual device thing, I was thrilled, but this one little issue is a thorn in my side.

Oh, FWIW, my virtual device mimics a sensor (based upon the sensor device standard) and all settings on the device are default.

Works for me inside the “Luup Scene”:

luup.variable_set(“urn:micasaverde-com:serviceId:SecuritySensor1”,“Armed”,0, 15)

Also, you can test Luup code easily in Devices → Luup plugins → Test Luup code (Lua)

Updated with more detailed explanation for the code above:

15 - device number for the sensor (either a real motion sensor, or virtual one based on motion sensor)
“Armed” - variable name, not value! A motion sensor has 2 useful variables - Armed and Tripped
0 - the value for the above variable. 0 means “Bypass”, 1 means “Arm”

So, the code above disarms the sensor #15.

Hi slackner,

that sounds very interresting. Would you be willing to share the device code? I am looking for someting similar and I would really appreciate it if I wouldn’t have to invent the wheel again.
Thanks

Umtauscher

@umtauscher, there is no code to write/share. As was previously explained on the forum several times, you need to create a new Luup device derived from a motion sensor:

Devices → Luup plugins, at the bottom in “Add device” section, enter “D_MotionSensor1.xml” in the UpnpDevFilename entry and select the Room, click “Add device” button, name it and Save. You may need to wait some time or reboot Vera to get this new device initialized… Once it shows as a motion sensor, you can use it’s Tripped and Armed states for your own needs. Tripped state can only be set and queried programmatically, while Armed state can be also set from the Web interface and queried programmatically in scenes…

One of the use cases is the Away/Occupancy state - Arm for Away/Empty and Bypass for Home/Present, for example.

Thanks for the advice. I’ll try that.
Cheers

Umtauscher

Denix - thanks, but I was actually referring to using the command pulldown in the device list within the scene, not writing additional code to arm/disarm the virtual sensor. I realize I could write code [and thanks for the example - will save me some time :slight_smile: ]

My virtual device appears as a device along with all my others under the “Commands” section of the scene. What’s not working for me is changing the pulldowns for the virtual sensor (flag) to “Arm” and “and leave it.” My assumption (perhaps incorrect) was that this would allow me to arm/disarm the virtual sensor without having to write any luup code.

Thoughts?

Setting it as part of the Commands in a Scene doesn’t seem to work - I guess it’s a bug, unless MCV says it’s not supposed to work that way for a reason… :slight_smile:

My virtual device appears as a device along with all my others under the "Commands" section of the scene. What's not working for me is changing the pulldowns for the virtual sensor (flag) to "Arm" and "and leave it." My assumption (perhaps incorrect) was that this would allow me to arm/disarm the virtual sensor without having to write any luup code.

Can you clarify the situation! You create a scene, you see in the Commands section
your Virtual Motion Sensor but in the drop down menus you don’t see anything or you select ARM and after save it doesn’t keep it?
What firmware version are you running?

Setting it as part of the Commands in a Scene doesn't seem to work - I guess it's a bug, unless MCV says it's not supposed to work that way for a reason...
The ARM/Disarm command is sent to HADevice which is tied to Zwave. Since your Virtual device isn't a zwave device the ARM/Disarm aren't implemented for it. If you set it as a zwve device it will be deleted at zwave report child devices, so right now there isn't any way to arm it from a scene.

We should add such a special device like this and in your scenes you’ll just need to add this lua code:

local SpecialDeviceNumX=1000 --[[ this is the DeviceNum that you'll get it from the web UI after you add the device --]]

local SpecialDeviceStatusX = luup.variable_get("urn:micasaverde-com:serviceId:SpecialDevice","Yes",SpecialDeviceNumX)
if (SpecialDeviceStatusX == "0") then
    return false
end

return true

OK, so you’ve answered my question.

Yes, the pulldowns are there for the device, and Arm is available as a selection. But selecting “Arm” has no effect on the device. As you state in your post, it must be because this is not available for a non-zwave device.

So I guess I will need to use Lua code to Arm/Disarm my virtual device instead.

BTW, running firmware .979

Thank you.