Vera & Z-Wave motion sensor configuration


  #1  
Old 10-19-19, 04:14 PM
L
Member
Thread Starter
Join Date: Nov 2015
Posts: 1,573
Received 201 Upvotes on 172 Posts
Vera & Z-Wave motion sensor configuration

I have Vera Edge, Z-Wave motion sensor and Z-wave switch.
I use motion sensor to detect motion outside and turns on z-wave switch controlling outdoor lights.
This part was configured rather easily.

I have Vera configured to turn on the light when motion is detected and turn off the light after 1 minute.

Now, the problem is I want outdoor lights to stay on without timing out when turned on with light switch.

At the moment, the light will stay on if I turn the light on with switch. However, as soon as any motion is detected, the light turns off after 1 minute.

Is there any way to accomplish this?
 
  #2  
Old 10-20-19, 05:26 AM
L
Member
Thread Starter
Join Date: Nov 2015
Posts: 1,573
Received 201 Upvotes on 172 Posts
I'm sure there is a better way, but this is what I have done for now and seems to work.

I created 4 scenes.
2 for arming or disarming motion sensor depending the light condition.

1 for turning on the light when motion sensor is armed and motion is detected. Triggered by motion sensor.
Instead of using built in device action, I entered following luup code in 3rd step.
local sensorDeviceNo = 6 -- Motion Sensor device number
local lightDeviceNo = 4 -- Light device number

local SS_SID = "urn:micasaverde-com:serviceId:SecuritySensor1" -- Security Sensor Service ID
local SP_SID = "urn:upnp-org:serviceId:SwitchPower1" -- Switch Power Service ID

local switchState = luup.variable_get(SP_SID, "Status", lightDeviceNo)

if (switchState == "0") then -- Turn on light only if it is not already on
luup.call_action(SP_SID, "SetTarget", {newTargetValue = "1"}, lightDeviceNo)
Front_Motion_On = true -- SetGlobal Variable to mark light turned on by motion sensor
end

return true

1 for turning off the light triggered by motion sensor stop detecting motion trigger regardless of armed or disarmed (just in case motion sensor gets disarmed while the light is on).

This has following luup code.

local sensorDeviceNo = 6 -- Motion Sensor device number
local lightDeviceNo = 4 -- Light device number
local period = 30

local SS_SID = "urn:micasaverde-com:serviceId:SecuritySensor1" -- Security Sensor Service ID
local SP_SID = "urn:upnp-org:serviceId:SwitchPower1" -- Switch Power Service ID

function TurnOffLight()
luup.call_action(SP_SID, "SetTarget", {newTargetValue = "0"}, lightDeviceNo)
Front_Motion_On = false -- Reset SetGlobal Variable
end

if (Front_Motion_On == true) then -- Turn off light after set period only if it was turned on by the motion sensor
luup.call_delay ("TurnOffLight", period)
end

return true

Basically, I set a global variable that gets set when the switch is turned on by motion sensor and off scene only turns off the light when motion sensor turned on the light.

Now, it seems to work as intended.
Only downfall is when you want light to stay on while the light was turned on by the motion sensor.
I don't see any way to distinguish between a button press and switch state.
 
 

Thread Tools
Search this Thread
 
Ask a Question
Question Title:
Description:
Your question will be posted in: