Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stupid question: How can I read a motion or other field state change
#1
I know this is a stupidly easy question, but it has been a while since I coded triggered events and I am hitting a blank, I looked through the docs but I cant find what I am looking for. I used to be able to do this.

Lets say I want to do something very simple:
When "elk.motion1" detects motion, and the hallway lights are currently off, then turn them on to 25%.
The second half I have properly, my problem is reading the motion. I tried creating a trigger, setting it to Is Feild Change (is this even correct), and then putting the following code in, but I dont remember how to have it read the motion. (I know it is probably not TrigEvent::GetFldChangeInfo I just put it there as a place holder)

Thank you

Code:
If 
TrigEvent::GetFldChangeInfo
    P1=
    P2=

If 
Devices::FieldRead
    P1=Lutron.LGHT#Sw_Hallway
    P2=False
    P3=True

Devices::FieldWrite
    P1=Lutron.LGHT#Dim_Hallway
    P2=25
    P3=True

Devices::FieldWrite
    P1=Lutron.LGHT#Sw_Hallway
    P2=True
    P3=True

End

End
Reply
#2
You would get the motion state in the actual trigger that's received. You can get it or infer it. To infer it, if you only care about one state (start or stop) set up the filter so that the event only runs on that state. To get it, use another of the TrigEvent: commands we were talking about in the other thread to read the motion trigger info, which will include the motion state being reported.
Dean Roddey
Explorans limites defectum
Reply
#3
I have two outside motion detectors, and if the Elk detects motion on either, I set up an Event that triggers on:

Is Field Change for -> Elk.PhyZone009

or

Is Field Change for -> Elk.PhyZone010

then in the Action Template, I want it to only turn on if it is within 30 minutes of dusk, so  I have this:

Code:
If
System::IsNight
   P1=-30

Devices::FieldWrite
   P1=Lighting.On
   P2=OutsideFront
   P3=True

End
Reply
#4
Thank you. So I tried the code below. My goal is that if the motion triggers and the lights are off it will turn them on at 25%. But it didnt work. Any suggestions why? Also, I would want to edit the code that it turns on for lets say 30 seconds. Which should be easy by just adding a timer. ButI want it, that if a user increases the brightness of the lights during that time, the timer should stop.


I have the trigger being "is Field Change for" "Zone_LivingRoomMotion_PhysStatus"
Code:
Devices::FieldRead
   P1=Lutron.LGHT#Dim_LivingLeftSpot
   P2=LVar:LivingLeftSpot
   P3=True

Devices::FieldRead
   P1=Lutron.LGHT#Dim_LivingLeftSpot
   P2=LVar:LivingRightSpot
   P3=True

If
System::Equals
   P1=%(LVar:LivingLeftSpot)
   P2=False
   P3=Case

Devices::FieldWrite
   P1=Lutron.LGHT#Dim_LivingLeftSpot
   P2=25
   P3=True

Devices::FieldWrite
   P1=Lutron.LGHT#Sw_LivingLeftSpot
   P2=True
   P3=True

End

If
System::Equals
   P1=%(LVar:LivingRightSpot)
   P2=False
   P3=Case

Devices::FieldWrite
   P1=Lutron.LGHT#Dim_LivingRightSpot
   P2=25
   P3=True

Devices::FieldWrite
   P1=Lutron.LGHT#Sw_LivingRightSpot
   P2=True
   P3=True

End
Reply
#5
You don't want to filter for that. There are dedicated triggers for motion, lighting, etc... You wuold always use those if you can. If you can't, then you have to explicitly add a trigger to a field. We don't send out a trigger for every field that changes, since it would overwhelm the system. So there are set of standard ones, and everything else is a manual configuration. To trigger on physical zone status you would have to do a manual one.

This discusses the types of triggers:

https://www.charmedquark.com/Web2/CQCDoc...eredEvents

This describes the info that is sent in the various types of triggers:

https://www.charmedquark.com/Web2/CQCDoc...TriggerFmt


Anyhoo, go to the /System/Monitor/ section of the tree in the admin intf. and there's a tab for monitoring event triggers. Trigger a motion sensor and you'll see them show up there.

In your case you want to do something like two filters of this sort, with the All True option set.

IsMotionStart
IsMotionEvFor(themotionfield)

That will only trigger the event if it's a motion start event for the specific field you care about.

Oh, and also note that motion triggers should be optionally configurable (according to the V2 specs) because they can create a lot of traffic. So in the client side interface of the driver, when you configure a motion zone, you should have the option of whether that zone will send a trigger or not. You need to enable that on the ones you want to react to.
Dean Roddey
Explorans limites defectum
Reply
#6
Thank you. That helped with the understanding, but its still not working. Just in case the issue was with me checking if the light was on, I removed those lines and only have


Code:
Devices::FieldWrite
   P1=Lutron.LGHT#Dim_LivingLeftSpot
   P2=25
   P3=True

Devices::FieldWrite
   P1=Lutron.LGHT#Dim_LivingRightSpot
   P2=25
   P3=True

Devices::FieldWrite
   P1=Lutron.LGHT#Sw_LivingLeftSpot
   P2=True
   P3=True

Devices::FieldWrite
   P1=Lutron.LGHT#Sw_LivingRightSpot
   P2=True
   P3=True


For the tiger I have:

Code:
Is Motion Start
Is Motion Event For Elk.SEC#Zone_LivingRoomMotion_Status

I also tried  
Code:
Is Motion Event Fo Elk.Zone_LivingRoomMotion_PhysStatus


In the Elk driver, I set both of them to be triggers for any value change.

Thank you
Reply
#7
Oh, that's not going to work. Remove the triggers from the fields, and configure the zone as a motion zone. The Elk.SEC# bit on the field name means that you have configured them as security zones, which won't send motion triggers. They will send security triggers which isn't what you want. So configure the ones that are really motion to be motion zones and save the changes. Then bring up the event monitor tab and cause one of those to trigger (if it's already triggered you'll have to wait for the end of motion.) You should see a motion trigger show up. As it is now, you would be seeing both a field change trigger and a built in zone security trigger. SO you would be both sending redundant double triggers and the wrong kind.

Using the event trigger monitor tab will help you figure out what is happening. As it is now, you would probably see a field change trigger and security zone state trigger.
Dean Roddey
Explorans limites defectum
Reply
#8
Perfect it works. Now I am having an issue with my IF part (without the IF part it works). But with the IF it doenst work. Thank you


Code:
Devices::FieldRead
   P1=Lutron.LGHT#Dim_LivingLeftSpot
   P2=LVar:LivingRightSpot
   P3=True

Devices::FieldRead
   P1=Lutron.LGHT#Dim_LivingLeftSpot
   P2=LVar:LivingLeftSpot
   P3=True

If
System::Equals
   P1=%(LVar:LivingLeftSpot)
   P2=False
   P3=Case

Devices::FieldWrite
   P1=Lutron.LGHT#Dim_LivingLeftSpot
   P2=25
   P3=True

Devices::FieldWrite
   P1=Lutron.LGHT#Dim_LivingRightSpot
   P2=25
   P3=True

End

If
System::Equals
   P1=%(LVar:LivingRightSpot)
   P2=False
   P3=Case

Devices::FieldWrite
   P1=Lutron.LGHT#Sw_LivingLeftSpot
   P2=True
   P3=True

Devices::FieldWrite
   P1=Lutron.LGHT#Sw_LivingRightSpot
   P2=True
   P3=True

End
Reply
#9
You are reading a dimmer, not a switch. So you would be getting the dimmer level. So presumably you want to read Lutron.LGHT#Sw_LivingLeftSpot instead.
Dean Roddey
Explorans limites defectum
Reply
#10
(01-09-2019, 03:09 PM)Dean Roddey Wrote: You don't want to filter for that. There are dedicated triggers for motion, lighting, etc... 

Is this true for the Elk V1 driver?  It's been so long since I have configured anything for this, I didn't recall that you could set up different triggers, and the V1 Driver docs are not on your help system (that I could find)

I still have plans to convert to Elk V2, it's just that it would be more than i could bite off right now.
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Question on Parsing a String in a CML Macro kblagron 2 87 06-18-2019, 06:21 PM
Last Post: Dean Roddey
  ELK M1 Client Interface question lleo 1 115 06-12-2019, 08:15 AM
Last Post: Dean Roddey
  Question on Socket Error kblagron 4 415 04-07-2019, 09:19 PM
Last Post: kblagron
  Values Tab - Regular Expression Question bryanb 22 2,967 03-30-2019, 04:07 PM
Last Post: rbroders
  Missing how to tell CQC to read a Lutron keypad button pressed ghurty 7 630 01-08-2019, 09:55 PM
Last Post: Dean Roddey
  Getting "Tried to read at the logical end of the stream" when importing a package ghurty 2 378 12-28-2018, 08:56 AM
Last Post: ghurty
  Basic CML question lleo 12 1,249 12-14-2018, 06:50 PM
Last Post: Dean Roddey
  GetCurMillis immune to system time change? rbroders 6 739 12-09-2018, 02:58 PM
Last Post: rbroders
  Moving MS question IVB 15 1,066 12-08-2018, 10:43 PM
Last Post: IVB
  Auto Generate general question carealtor 4 780 11-12-2018, 09:22 PM
Last Post: carealtor

Forum Jump:


Users browsing this thread: 1 Guest(s)