This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Assign Priority to a physical switch vs Motion sensor in a script?
#1
Hi,
Looking for some help to determine if a particular light/group address was last turned on via a physical switch, or via a PIR motion sensor (which is a different address).
I need the switch to 'Win' i.e if a user turned on a light via a switch, leave it on when the PIR motion even expires. Is this possible?

This is a C-bus system not KNX, but more or less the same in terms of principles and addresses...
The real lighting GA is assigned to a bus relay output, and also to 4 physical buttons over various switch plates. Each button has a local LED and works great to indicate the state of the actual light, so I don't want to interfere with this.  

The PIR is a normal dumb/electrical device (non-bus aware itself) but is connected via a volt-free bus-auxiliary input, and effectively works like a bell-push event as seen by the logic machine / SHAC. It's simply Motion = 1, No motion = 0. The length of time the PIR signal stays at 1 (motion detected) is determined via a mechanical dial on the PIR itself, can't be influenced via LM...

I have this basic construct of what I need to do, but I'm missing the magic of determining what the last device to turn the light on really was...
Any help is greatly appreciated. 

Code:
-- Control of main GA via a PIR Slave GA

local Master = 35     -- Utility Room Light Group Address (all existing switch buttons use this Group)
local Slave = 73    -- PIR Group Address (This event script is linked to this address)
local Nw = 0
local Group = 56

value = event.getvalue()

--if light is currently off, turn it on
if (GetCBusLevel (Nw,Group,Master) = 0) and (value >=1) -- Similar to standard grp.getvalue in standard LM...
then
  --set Master GA On
  SetCBusState(Nw, Group, Master, true)    -- Similar to standard grp.write in standard LM..
end


--PIR Goes off - if light is currently on, and was turned on via motion sensor and not a switch, turn it off
if (GetCBusLevel (Nw,Group,Master) >= 1) and (value = 0)
 
  -- Here I would like to determine somehow if light/GA was turned on via a physical button, or the PIR
  -- The physical switch should 'win' - if a person turned on light manually via a button, leave it on.
 
then
  --set Master GA Off
  SetCBusState(Nw, Group, Master, false)
end
Reply


Messages In This Thread
Assign Priority to a physical switch vs Motion sensor in a script? - by Paddyb - 20.12.2021, 16:55

Forum Jump: