Please login or register.

Login with username, password and session length

Author Topic: Program "Trigger Code" - Trigger difference between "Run Once" vs other options  (Read 1365 times)

soxfan1966

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 388

So I have a few Programs defined that basically send RF signals to the same x10 module when they turn on (and separate programs for when they turn off).   There is a 2 second pause between the trigger (the x10 module Status.Level being equal to 1 or 0 depending on if turning On or Off) and sending the RF signal.

I'm going to change this from 2 seconds pause to 1 second but thats not really related.

The problem I am having is that if someone manually turns the light switch on, then off, then on the light gets in this string of On / Off / On / Off etc

I was hoping to try and use some "Flags" ( ie. dummy modules) then I saw some options under "Trigger" (5 options) but couldn ot find any documentation on the difference between them (I was wondering if the "Run Once, ..." one would solve my issue or perhaps one of the others)
Logged

petera

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 27
  • Posts: 1750

Creating a Virtual Module defined as a switch would do that. There's a virtual module demo in the Program section that should explain its usage.
Logged

soxfan1966

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 388

I think I removed the Virtual Devices when I cleaned up my original install.  I'd still like to understand what the different Trigger options mean too.

Did you mean the use of virtual devices would replace the dummy modules as flags? 
Logged

petera

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 27
  • Posts: 1750

I think I removed the Virtual Devices when I cleaned up my original install.  I'd still like to understand what the different Trigger options mean too.

Did you mean the use of virtual devices would replace the dummy modules as flags?

What dummy modules are you talking about.
Logged

soxfan1966

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 388

I was referring to the dummy modules I was going to use as flagas (ie use house code F for flags)
Logged

petera

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 27
  • Posts: 1750

I was referring to the dummy modules I was going to use as flagas (ie use house code F for flags)

I think Bkenobi already covered the futility of using "flags" in a previous post. HG doesnt need flags to perform automation tasks based on conditions.

Maybe you could post pseudo code of what you are trying to achieve and we could help you formulate a solution in HG. Something like

If device1 is set to on at 11am then turn on device2 for 30 minutes and turn off device1

Is this something like you require.
Logged

soxfan1966

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 388

Ok.

I'd still like to know the trigger options too.

So I have macros that turn on an x10 device via a PLC command then a pause of 1 second then the same device via an RF command.

The problem is it gets in a weird cycle where this is repeated - on, off, on, off, etc

So I wanted to add a check that I could set a flag so if it was set, don't turn on again for 10 seconds or so - just to keep it out of that repeat cycle.

This happens only when the light is turned on manually and off manually.  My timed macros and timers all work great.
Logged

petera

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 27
  • Posts: 1750

When I get a bit of time this week I'll have a look at this. Have you looked into the Wizard Scripts yet.
Logged

soxfan1966

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 388

I've done a few Wizard scripts so far, but not for this.
Logged

soxfan1966

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 388

Tried playing around with it some more this morning but no luck - I could write something if I knew what it was I was trying to do.  I'm just not sure what I need to "set" in order to handle the delay of 10 seconds or so before the "RF On" program will run again.

If I just add another pause in the program after the RF command is sent would that in essence prevent the program from running again too soon after it already did ?

I tried it and it seems to at least prevent the cycle of On/Off/On/Off.

I have 4 such light switches that people can manually turn On and Off (everything else is a plug or something with a timer outside that people do not manually turn on).  The worst one is the one for my back deck (which also has an x10 motion sensor).  The other is the garage lights (which I have a timed event to turn off after 10 minutes but does not have a motion sensor, so the existence of the motion sensor is not the issue).

I'm going to update my programs for those 4 devices to have a 10 second pause after sending the RF command and see if that at least stabilizes things.
Logged

bkenobi

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 24
  • Posts: 2081

I'm not going to say my approach is perfect, but I used a filter of sorts to prevent multiple ON commands from a motion sensor from hammering my chime as implemented in the Advanced Smart Lights script.  Depending on the type of motion sensor used, it may either turn on and send a single ON until motion is stopped and then an OFF (e.g., HeathZenith hard wired sensors) or send ON every time motion is detected again after the short timeout period (e.g., MS16A).  Without the timeout code, a twitching branch near the motion sensor will cause the chime to go off every 5 seconds (MS16A timeout).  I added a time of day dependent trigger that prevents multiple triggers from hammering the chime.  The only down side is that there is up to a 5 second delay for a real motion (visitor, deer, etc).

This is the section of code that looks for these nuisance triggers.  I know it's complicated looking, but that's partly due to how HG loops through modules (you don't have to do that) and partly because I added a bunch of debug logging.
https://github.com/bkenobi/HomeGenie_Apps/blob/master/Advanced_Smart_Lights.hgx#L245
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.