Virtual Motion Sensor Plugin

[quote=“davidd1205, post:19, topic:179671”]hello thanks for your plugin

i use your virtual sensor with armed status and on triped it 's run a scene but with become not triped it’s not run my second scene

i want when a armed sensor become triped run scene 1 and when 60 seconde later when it status become not tripped run a second scene it’s possible ?

thanks[/quote]
You should be able to trigger a scene when the sensor is not tripped.

quick question …
is there a way to disable repeat actions ?
if the sensor is tripped it keep repeating the triggers
(this is a common thing on motion sensor devices …)
i have a set of S_* Files with No repeat to bypass this issue
with this code in S_ file

  <serviceStateTable>
    <stateVariable allowRepeats="0">
       <name>Tripped</name>
       <sendEventsAttribute>yes</sendEventsAttribute>
       <dataType>boolean</dataType>
       <shortCode>tripped</shortCode>
       <defaultValue>false</defaultValue>
    </stateVariable>
  </serviceStateTable>

however in S_VMotion.xml
allowRepeats=“0” does not seem to work (or i just put it wrong) ?

however in S_VMotion.xml allowRepeats="0" does not seem to work (or i just put it wrong) ?

VMotion uses the standard service file (S_SecuritySensor1.xml) for all of its variables. This is to maintain compatibility with normal Motion Sensors. If you change that file, it will affect all of your Security Sensor devices.

The S_VMotion.xml file is used only to define the special action used to trip the virtual sensor.

yeah after i post that i did digging arround alittle and found that out as well … i have a “S_SecuritySensor_norepeat1.xml” on the vera for another issue i needed to get rid of the repeat problem.

altered I_VMotion.xml like this: local ont = lul_settings.OnTime or "0" if ont ~= "0" then luup.call_delay("unTrip",tonumber(ont),lul_device) end

also removed the reset to not tripped in ‘initstatus’

this will eliminate the timer if none has been given, at the cost of the default 5 sec delay …
and not cause the status to switch back to 0 if luup restarts.

it works now (in combination with the S_SecuritySensor_NoRepeat1.xml) changed in the D_VMotion_norepeat.xml file to load.

hope i not violating any copyrights with that …

WOW! I just stumbled onto this thread in the recent unread topics list. Rex you are a genius sir! I am also using Synology Surveillance Station and this is going to be my next project!

I am also using Synology Surveillance Station and this is going to be my next project!

See also Synology Recording Control if you want to trigger recording from Vera.

[quote=“RexBeckett, post:26, topic:179671”]

I am also using Synology Surveillance Station and this is going to be my next project!

See also Synology Recording Control if you want to trigger recording from Vera.[/quote]

Rex, thanks again for your tutorials. I have the virtual motion sensor up and running and will work on recording control next. Have you derived any method to do this with multiple cameras? If we can only set 1 sms provider then I suppose we can only trip one sensor? At least I was able to pic an area where I had no motion detection coverage.

On a sidenote, does anyone here know how to get deals on Synology camera licenses? I have 8 cameras and only 6 licenses currently. FTP seems to be the way to go to avoid the fees. It would be nice to replay any recording on the Synology instead of just the licensed cameras.

I just saw that Surveillance Station 7.0-3706 has been released. It looks like there are a lot of changes/new “features”. Has anyone tried it? I have a lot of other stuff to catch up on with my Vera and PLEG before I can consider the jump. I also may have some ideas about the licensing system limitations but I’m still researching.

Rex-- thanks for posting this. Very clever to hack Synology/SMS!

I was wondering the same thing as YZRacer. I have multiple cameras. I’m using your virtual motion sensor to have my hikvision trigger a front porch light. However, I obviously wouldn’t want motion sensor events on other cameras to trigger the front porch.

I was wondering if you happen to have any thoughts/ideas on how to further hack this so that Vera could distinguish between cameras. (Not asking you to do the work =) i’d be willing to try to help out)

thanks in advance.

I haven’t looked but I recall that it was possible to set up multiple SMS providers on Surveillance Station. I would think it should be possible to have different cameras use different SMS but I have not tried it. If not, does SS include the camera name or number in the SMS message text? There may be a way to finagle this into an http argument that could be accessed in plugin code.

I still use VMotion but I don’t use the camera motion sensors now. I use some modified security lights with Fibaro twin-relay modules on board. One relay is switched by the PIR (modified to work in all light levels) and PLEG logic decides whether to trip the appropriate VMotion and/or turn on the light via the second relay. PLEG also starts and stops SS recording the cameras. I get a lot fewer false triggers with this scheme.

Rex, I appreciate all the great ideas you share with the forum! I’m really excited to get home later this year and start tinkering with some of these projects.

SS does allow multiple SMS providers, but I don’t believe more than 1 can be active at the same time. I’ll tinker with it some and if I find a way I’ll post an update here. I can’t really do any physical projects while I am away but VMotion and a camera will work for now. I may even try SS7 and see if something new there will help.

Looks like our problems have just been solved with SS7!

Action Rule

In Action Rule, you can manage a variety of action rules that automate different surveillance functions and reduce the manual workload needed to perform surveillance. There are many applications for action rules such as instructing a camera to patrol between different user defined preset positions, providing status on surveillance system components (e.g., lost camera connection or tampering was detected), and much more. Action rules can be triggered or scheduled. There are 15 events and 12 actions as follows:
Events

Camera
    Camera Enabled
    Camera Disabled
    Connection lost
    Connection resumed
    Motion detected
    Audio detected
    Alarm triggered
    Tampering detected
Door
    Access granted
    Access denied
    Alarm triggered
    Tampering detected
Access controller
    Alarm triggered
    Case opened
External device
    External event detected

Actions

Camera
    Enable Camera
    Disable Camera
    Start recording
    Take snapshot
    Activate digital output
    Play audio pattern
    Move to preset
    Patrol
    Auto pan
    Auto object tracking
Surveillance Web Client (open Surveillance Station in web browser)
    Play audio pattern
External device
    Execute URL command

Please note that only users belonging to the administrators group can use this application.
List

In the List tab, you can add, edit, enable, disable, and delete action rules.
History

In the History tab, you can view, clear, and download the results of previously executed action rules.
Audio Pattern

In the Audio Pattern window, you can add, edit, delete, and play audio patterns. Audio patterns are used in action rules as well as in the two-way audio feature of Live View.

Execute URL command

There you go, then. You can have as many virtual motion-sensors as you like. Well almost. Remember each one will chew-up about 2MB of your precious RAM. If you want a lot, it could be worth converting VMotion to a parent + children plugin.

Awesome find YzRacer. Going to give it a try. Thanks.

RexBeckett-- now that I recognize your name, I see it all over the place, such as with PLEG. Thanks for all your work in the vera community.

I started trying to do what Rex suggested and figure out a way to parse the message body, but didn’t get very far. (By the way, the SMS alert does include camera name message in the body of the SMS. The message is customizable)

Hi Rex-

This is more of a general LUUP programming question, so maybe another thread is more appropriate.

Do you happen to know if all the parameters from the URL Action call automatically get stored and are supposed to be accessible via the luup.variable_get call or is there some other object that this information is available from?

For example, with the synology sms url, the camera name is part of the message param.

http://your.vera.ip.address:3480/data_request?id=action&output_format=xml&DeviceNum=161&serviceId=urn:dcineco-com:serviceId:VMotion1&action=SetTripped&OnTime=10[b]&message=Some string with CAMERA NAME in it[/b]

Would you expect to be able to get the message param using luup_variable.get? I see that is how you set Tripped, but can’t seem to get it working for message.

thanks in advance,
dlca1

D_VMotion.xml

<?xml version="1.0"?>
<implementation>
        <functions>
                function initstatus(lul_device)
                        luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped","0",lul_device)
                        local armed = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Armed", lul_device)
                        if armed == nil then
                                luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed","1",lul_device)
                        end
                        status = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","LastTrip", lul_device)
                        if status == nil then
                                luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","LastTrip","",lul_device)
                        end
                        message = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","message", lul_device)
                        if message == nil then
                                luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","message","initial",lul_device)
                        end

                end

                function unTrip(devnostr)
                        if devnostr ~= nil then
                                local devID = tonumber(devnostr)
                                luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",0,devID)
                                luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","message","reset",devID)
                        end
                end
        </functions>

        <startup>initstatus</startup>

        <actionList>
                <action>
                        <serviceId>urn:micasaverde-com:serviceId:SecuritySensor1</serviceId>
                        <name>SetArmed</name>
                        <run>
                                local newarm = lul_settings.newArmedValue
                                if newarm ~= nil then
                                        luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Armed",newarm,lul_device)
                                end
                        </run>
                </action>

                <action>
                        <serviceId>urn:dcineco-com:serviceId:VMotion1</serviceId>
                        <name>SetTripped</name>
                        <run>
                                local status = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",lul_device)
                                local tempMsg = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","message",lul_device)
                                if status ~= "1" then
                                        luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",1,lul_device)

                                        luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","message",tempMsg,lul_device)
                                        luup.log("Setting Message: ".. tempMsg ..".")


                                        local now = os.time()
                                        luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","LastTrip",now,lul_device)
                                        local ont = lul_settings.OnTime or "5"
                                        luup.call_delay("unTrip",tonumber(ont),lul_device)
                                end
                        </run>
                </action>

        </actionList>
</implementation>

I added the param to S_VMotion.xml as well

      <argument>
          <name>message</name>
          <direction>in</direction>
        </argument>
Do you happen to know if all the parameters from the URL Action call automatically get stored and are supposed to be accessible via the luup.variable_get call or is there some other object that this information is available from?

Parameters used in action calls are only available to the plugin through the arguments passed to it. They must be defined in the service file - as you have done. You can access them in the plugin’s action block like this:

local newmsg = lul_settings.message

Remember to check for a nil value before parsing the string.

Thanks! That worked.

Rex I’m in the same boat. I got rid of my Blueiris plugin to clean up vera. That also got rid of my virtual motions Blueiris creates for each motion.

This motion shows as a generic z-wave device in VERA ui and has no motion or icon difference when its tripped. It also doesn’t work in Imperihome. So at this point from a visual stand point it does work in UI7.

Is there no way to trip a normal motion sensor like what was being done with the BI plugin?

Is there no way to trip a normal motion sensor like what was being done with the BI plugin?

You could use luup.variable_set(…) to write “1” to the variable “Tripped”. An actual Z-Wave motion sensor will change this value back to “0” when it is next polled. A virtual motion sensor will stay at this value until you write “0” to it.

I’m going to subscribe to this for later. I use Surveillance Station, but I don’t have any integration between the two. I do have my cameras set up in both Vera and in SS, though… and I’ve been able to set up a virtual motion sensor for the Foscam using a process outlined elsewhere that seems to work pretty well. I don’t have the same for my Hikvision, though I’m not sure I want it, because it’s ultra-sensitive and I haven’t been able to configure it so that SS doesn’t record the slightest breeze or cars driving by.