Assign Priority to a physical switch vs Motion sensor in a script? - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Assign Priority to a physical switch vs Motion sensor in a script? (/showthread.php?tid=3760) |
Assign Priority to a physical switch vs Motion sensor in a script? - Paddyb - 20.12.2021 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 RE: Assign Priority to a physical switch vs Motion sensor in a script? - Daniel - 20.12.2021 In KNX we can check what physical address did sent the telegram, no idea if you can do the same in cbus. The simplest solution would be to use separate control groups, one for switch, second for PIR and third for the light. The control would be done by the script then. RE: Assign Priority to a physical switch vs Motion sensor in a script? - Paddyb - 20.12.2021 Hi, I had tried the three-group method already, but it leads to problems with the local LED indicators on the switches. Not sure how KNX works exactly, but in C-Bus, you basically just have one address for a group. You assign this group to any button you need to control the light, and then also assign the same group address to the relevant channel on your physical output unit. So it all keeps in sync that way...if GA 35 is 'On', all the LEDs on your buttons assigned to 35 are also on, and the output module you assigned as 35 is also on. Turn 35 off, and the relevant output goes off, and all the LEDs on the switches too.. there is no need to really map or cross-connect switch buttons to outputs, they just share the same address to begin with. That's kinda my problem, I wanted to continue to use this native basic configuration as there are a number of different switches already configured, and some other visualizations etc. that i didn't want to have to mess with. I was just trying to reduce the number of changes required to the system overall, for something I thought was a bit easier than it appears to be ... If this was like an industrial PLC I'd use some Set/Reset blocks and some rising and falling edge triggers...just struggling to adopt this approach to LUA code..I'll keep at it, but thanks for the suggestion RE: Assign Priority to a physical switch vs Motion sensor in a script? - admin - 21.12.2021 If you can get the sending device address then you can save it using storage.set when ON command is received. Then use storage.get to retrieve the address of the device that turned the lights ON when OFF command is received. RE: Assign Priority to a physical switch vs Motion sensor in a script? - Paddyb - 21.12.2021 Hi, Thanks for the idea. I did that and it works great. I made two Event scripts, one for the real lighting group 35, and another for the slave PIR group 73. In the event script for 35, I first check the event sender to make sure it really came from the physical bus or the visualization, then I create/set a storage object and set it to true when the switch turns on, or false when off. Normal bus/system functionality turns the actual light on/off. In the other event script for the PIR group 73, I turn on the light when this event value is '1' but if it is '0', I have a nested "If" to additionally check if the storage pseudo-blocker object is true or false before attempting to control the light. Works Perfect, and no rework is required to any other part of the system. Thanks again! |