I’ve just been poking around the forums and from various threads worked out how to create a virtual motion sensor device. I am using a VeraPlus UI7.
Some background: I have a Fibaro Double Switch relay module connected to some bog standard PIR Security Flood lights in my back garden.
When these PIR flood lights detect motion from their inbuilt motion sensors they turn on. Reading the currently used wattage on the Fibaro Double Switch module, I can determine if the flood lights have come on, hence motion was detected. And when they automatically turn off again after a minute or so, the wattage on the Fibaro module will go back to 0 e.g no motion.
So I plan to use some PLEG logic to control the virtual motion sensor and if it is tripped or not etc.
Here is how I created my virtual motion sensor device in Vera.
- Go to Apps - Develop Apps - Create Device
In the “Description” field enter a name for your new device, I used: “Motion Sensor (Virtual)”
In the Upnp Device Filename field enter: D_MotionSensor1.xml
Select a room for the device to be located in and click the create device button.
- Upload the attached I_MotionSensor1.xml file to your Vera. This makes the Disarmed / Armed buttons work in the GUI for the virtual motion sensor device.
Go to Apps - Develop Apps - Luup Files
Click the Upload button and browse to the I_MotionSensor1.xml file to upload it.
- Edit the Parameters of the new Virtual motion sensor device
Go in to the device then go to Advanced - Params tab
Scroll down and look for device_json and enter D_MotionSensor1.json in to the field and then press tab on the keyboard.
look for impl_file and enter I_MotionSensor1.xml in to the field and then press tab on the keyboard.
Also whilst in here make a note of the devices ID number in my case it was 287.
Go to Settings - Z-Wave Settings - Advanced tab and select Reload Engine hit the Go button and wait for the engine to restart.
- Perform two actions to make the variables appear for Armed and Tripped.
a. First from the devices list in the web GUI find your new virtual motion sensor and press the Armed button from being Disarmed.
b. Run this command, go to Apps - Develop Apps - Test Luup Code (Lua) paste it in to the box and then click the Go button.
But change the DeviceNum from 287 to whatever the device number is of your new virtual motion sensor.
luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", 1,287)
This should change the virtual motion sensors status to tripped and you will then see a Red icon on it.
- Check what you did in step 4. worked? In the Vera web GUI in the browser hit the F5 or reload the browser page. Now go back in to the Virtual Motion sensor device and go to Advanced - Variables tab. You should now see some variables have been added “Tripped” and “Armed”
The values of these variables will be 0 for OFF (Not Tripped) or 1 for ON (Tripped) etc.
That’s it the new virtual motion sensor device has been created.
Now you need to create a scene or some PLEG logic to trip / untrip the virtual motion sensor device, to suit your requirements.
I_MotionSensor1.zip (352 Bytes)