Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
X10SCRIPTS(5)		      File Formats Manual		 X10SCRIPTS(5)

NAME
       x10scripts - Scripting for HEYU,	an X-10	CM11A serial interface control
       program

DESCRIPTION
       Heyu  is	a program for controlling an X-10 "CM11A" home control device.
       See  the	heyu(1)	man page for usage information.

       This page contains information regarding	the capabilities of Heyu  ver-
       sion 2 for launching scripts upon reception of specified	X10 signals or
       special	conditions.   The  word	 'script' as used here encompasses not
       only shell scripts but also executable binaries and shell commands,  in
       fact, any valid command line.

       (The  auxilliary	program	Xtend by David Shaw which was required by ear-
       lier versions of	Heyu for this functionality is	no  longer  needed  or
       used.)

       In  order  to  launch scripts the Heyu state engine daemon must be run-
       ning.  It is started manually by	executing 'heyu	 engine',  or  can  be
       configured  to start automatically with the 'heyu start'	command	by in-
       cluding the directive "START_ENGINE AUTO" in  the  configuration	 file.
       If the Heyu configuration file is changed, the daemon must be restarted
       by executing 'heyu restart' - the existing daemon will re-read the con-
       figuration file and incorporate the changes.

       Scripts	to be launched are each	defined	in the Heyu configuration file
       with a SCRIPT directive.	 This directive	(more fully  explained	below)
       defines	the  launch conditions under which a command line will be exe-
       cuted and the command line itself.  For each event, i.e., X10 signal or
       special condition, encountered by Heyu the list of SCRIPT launch	condi-
       tions are tested	in the order the SCRIPT	directives appear in the  con-
       figuration  file.   The	command	 line is executed for the first	set of
       corresponding launch conditions which are satisfied.  Any  given	 event
       can  normally launch no more than a single SCRIPT command line, but see
       section "SCAN MODE" below to override this restriction.

       There are eight types of	scripts	which can be launched by Heyu:
       Normal scripts are launched by an  X10  function	 signal,  e.g.,	 'on',
       'off', etc., which can be either	sent or	received.
       Address	scripts	 are similar to	normal scripts but require only	an X10
       address signal.
       Powerfail scripts are launched when the restoration of AC power follow-
       ing an interruption is reported to the computer by the CM11A.
       RFFlood scripts are launched when an unbroken stream of RF signals  are
       received	by the auxiliary input daemon heyu_aux.
       RFJamming  scripts  are	launched  by  an RF Jamming signal reported by
       older firmware versions of RFXCOM receivers.
       Timeout scripts are launched at expiration of a countdown  time	speci-
       fied  by	 the  user  with  a 'heyu settimer n hh:mm:ss' command or by a
       script with the '@settimer n hh:mm:ss' precommand.
       Exec scripts are	launched only from the command	line  with  the	 'heyu
       launch <scriptname>' command, not by any	signal or hardware condition.
       Sensorfail  scripts  are	launched when a	sensor with a heartbeat	(i.e.,
       which periodically reports its current state), fails to report  in  the
       specified time, however they are	now deprecated.

       As  of heyu-2.9,	when an	inactive sensor	is detected Heyu generates the
       pseudo-signal "Inactive"	which appears to have been transmitted by  the
       sensor.	 The  function "inactive" can be used in the launch conditions
       for a Normal script the same as any other function, however one differ-
       ence is that the	"changed" launched condition refers only to the	 tran-
       sition  from  Active to Inactive	rather than a change in	the data value
       as for real signals.  The  directive  "HIDE_UNCHANGED_INACTIVE  YES|NO"
       (default	 NO)  determines  whether  the unchanged pseudo-signal is dis-
       played in the monitor and logfile.

       Sensorfail scripts are ignored under this new system.  The  config  di-
       rective	"INACTIVE_HANDLING  OLD" can be	used to	revert to the previous
       system.

       The Heyu	state engine daemon (heyu_engine) interprets X10 signals, both
       those received over the AC power	line via the  CM11A  interface,	 those
       sent  to	the interface from the Heyu command line, and those RF signals
       transceived or forwarded	from the heyu_aux daemon.  It keeps  a	record
       of  the	effect	of these signals upon each X10 module identified in an
       ALIAS directive in the configuration file (or the default module).  See
       the x10config(5)	man page for details about this.

       Heyu classifies each X10	signal by its source, which will be one	of the
       following:
	  sndc	- Sent from the	Heyu command line.
	  snds	- Sent by Heyu executed	from a normal or address script. (*)
	  sndp	- Sent by Heyu executed	from a power-fail script. (*)
	  sndm	- Sent by an uploaded macro when initiated by a	Timer.
	  sndt	- Sent by an uploaded macro when initiated by a	Trigger.
	  snda	- RF transceived to power line code by the heyu_aux daemon.
	  rcva	- RF signals forwarded from the	heyu_aux daemon.
	  rcvi	- Received over	the AC power line.
	  rcvt	- A Trigger signal which initiated an uploaded macro.
       (*) When	that script is launched	by the Heyu state engine daemon.

       The  launch conditions for a script requires that the source or sources
       to be allowed to	launch the script be specified if other	than  the  de-
       fault 'rcvi'.  Using the	source keyword 'anysrc'	is equivalent to spec-
       ifying  all  the	above mentioned	sources	except 'snds'.	If you are new
       to using	Heyu scripts, including	'anysrc' in the	launch conditions  for
       your scripts is probably	a good idea until you gain more	experience.

       Note  that  a  CM11A does NOT report the	individual addresses and func-
       tions when a macro is executed, only the	fact that a  macro  at	EEPROM
       address	XXX  has  been	executed.   Heyu determines the	individual ad-
       dresses and functions from a copy of the	EEPROM memory image it	stores
       in file 'x10image' when a schedule is uploaded to the CM11A.
       Neither	does  the  CM11A report	the actual X10 signal which triggers a
       macro, at least not reliably.  Again, Heyu  determines  this  from  the
       stored  memory  image file.  (The CM11A firmware	allows Heyu to distin-
       guish up	to six different triggers for the _same_ macro.)

       Each X10	standard module	in the system can be in	the major  states  On,
       Dimmed, and Off.	 They are not mutually exclusive - a module that is in
       the Dimmed state	is also	considered to be in the	On state.

       There are additional major states for X10 security sensors and remotes,
       e.g., Alert, Clear, Active, Inactive.

       In  addition,  there  are  minor	 states:  Addressed, Changed, and Mod-
       uleChanged.

       A module	is considered to be in the ModuleChanged state when  the  last
       X10 signal matching its housecode and unit caused a change in its major
       state.

       A module	is considered to be in the Changed state when:
	 It's in the ModuleChanged state -OR-
	 If the	X10 signal matching its	housecode and unit is the first
	   valid signal	encountered since start	or restart -OR-
	 For sensors with a heartbeat, if the sensor first becomes Inactive
	   or returns to Active	status.

       (A  signal  is considered "valid" if it is supported by the module type
       in question.)

       Addressing is a feature built into module firmware and emulated in  the
       Heyu state engine.

       A standard X10 module becomes Addressed when it receives	an X10 address
       code  matching  its own housecode|unit address.	It becomes unaddressed
       when it receives	an X10 address code not	matching its own address after
       having received _any_ X10 function code on the same housecode -or- when
       it receives the 'alloff'	(all_units_off)	function on that housecode.

       The X-10	company	has not	been consistant	with their designs  and	 some,
       but   not   all,	  dimmer   modules   which   support  the  'lightsoff'
       (all_lights_off)	command	will become unaddressed	after  receiving  that
       command,	 and some dimmer modules will become unaddressed after receiv-
       ing the 'lightson' (all_lights_on) command.  Similarly there  are  some
       modules,	 usually  X10 camera power supplies, which are not unaddressed
       by the 'alloff' command.

       SwitchLinc and other modules which support the 'preset' function	 auto-
       matically  unaddress  themselves	insofar	as a subsequent	'preset' func-
       tion is concerned immediately after receiving any X10 function code.

       The state tables	maintained by the Heyu	state  engine  daemon  include
       common  flags  which can	be set or cleared by Heyu commands.  The state
       of one or more flags, "flagNN" or "notflagNN", can be included as  part
       of the conditions determining whether a script is to be executed.  Heyu
       counters	 set a "counter-zero" ("czflagNN") flag	when the corresponding
       counter NN value	is zero.  Heyu user-configurable countdown timers  set
       a  "timer-zero"	("tzflagNN")  flag  when the corresponding timer NN is
       zero.

       Heyu's security commands	set flags, e.g.,  'armed',  'disarmed',	 etc.,
       which can also be tested	as part	of the launch conditions.  If the LON-
       GITUDE and LATITUDE directives are included in the user's configuration
       file,  the  flags 'night' and 'dark' and	their negations	'notnight' and
       'notdark' can also be tested in the launch conditions.

       The user	can choose to run in a mode  compatible	 with  the  heyuhelper
       feature	of  Heyu 1.xx, a mode compatible with (most) Xtend scripts, or
       with the	full features of Heyu scripting.  For heyuhelper, put the  di-
       rective	SCRIPT_MODE  HEYUHELPER	 in your configuration file, otherwise
       specify (or take	the default) SCRIPT_MODE SCRIPTS.

       When SCRIPT_MODE	HEYUHELPER is specified, all the other script-oriented
       directives described below except SCRIPT_SHELL and SCRIPT_CTRL are  ig-
       nored.  If an executable	script named 'heyuhelper' exists on the	user's
       path,  it is launched every time	Heyu receives an X10 function over the
       AC power	line via the CM11A interface.  One difference from  Heyu  1.xx
       however	is that	the heyuhelper script is NOT launched when an uploaded
       macro is	executed.

QUICK SCRIPTS
       For those anxious to get	started	without	having to  understand  all  of
       Heyu's	extended   scripting  features,	 just  take  the  default  for
       SCRIPT_MODE, add	one or more simple SCRIPT directives like the  follow-
       ing to your configuration file, and run 'heyu engine' to	start the Heyu
       state  engine  (or 'heyu	restart' if it's already running).  The	simple
       SCRIPT format for (normal) scripts is:

	 SCRIPT	 <Housecode|unit>  <function>  anysrc :: <command line>

       The Housecode|Unit, function, and keyword "anysrc" taken	 together  de-
       scribe  for  Heyu the launch condition, i.e., the condition under which
       the command line	is to be executed.

       The Housecode|Unit can be an ALIAS defined in the configuration file.

       The keyword "anysrc" allows Heyu	to satisfy the	launch	condition  re-
       gardless	 of  the source	of the X10 signal, e.g., whether received over
       the power line or sent from the command line.  Later you	 may  wish  to
       restrict	 the source(s) of the signal to	specific ones from the list of
       sources above.

       Examples:
	 SCRIPT	porch_light on anysrc :: echo "Porch light has been turned on"
       | mail

       The above sends an email	to you whenever	the X10	'on'  signal  for  the
       housecode|unit aliased to 'porch_light' is received over	the power line
       or sent from the	command	line.

	 SCRIPT	 C1 off	anysrc ::  play	ssb.wav; heyu turn tv_set off

       When  remote  X10  signal  'C1 off' is received,	play the Star Spangled
       Banner .wav file, then turn off the TV set.  Users outside the USA  can
       substitute  a  .wav file	for "O Canada",	"God Save the Queen", or what-
       ever TV station signoff music is	usual in their country.	:-)

       Note: The '::' (two colons) is a	mandatory separator between the	launch
       condition (e.g. 'C1 off') and the command line.

       Unless redirected elsewhere, any	text output  from  a  launched	script
       will be written to the log file.

       Address scripts are similar to normal scripts but the keyword 'address'
       is substituted in place of any and all function names.  Example:

	 SCRIPT	A1 address anysrc :: mysound.sh	volumeup
	 SCRIPT	A2 address anysrc :: mysound.sh	volumedown

       For powerfail scripts the simple	SCRIPT format is:
	  SCRIPT -powerfail :: <command	line>

       Example:
	  SCRIPT -powerfail :: heyu on night_lights

ADVANCED SCRIPTS
       Define  for Heyu	a script to be launched	and the	conditions for launch-
       ing it with a SCRIPT directive in your configuration file.  Any	number
       of SCRIPT directives may	appear in the configuration file.

       The format is:
	  SCRIPT [-l label] <launch conditions>	:: [options] <command line>

       <launch conditions> tell	Heyu under what	conditions the script is to be
       launched.   See	the  section LAUNCH CONDITIONS below for full details.
       <launch conditions> may alternatively (or  additionally)	 be  specified
       with a LAUNCHER directive in the	configuration file.

       Launch conditions are tested in the order they appear in	the configura-
       tion  file.   The command line will be executed for the first (and only
       the first) set of launch	conditions which are satisfied,	i.e., only one
       command line can	be executed per	X10 signal or special condition.

       The script label	is optional so long as all the launch  conditions  are
       specified  in the SCRIPT	directive.  If omitted,	Heyu will create a la-
       bel for display purposes	of the form 'Script_NN', where NN is the  line
       number  of  the	SCRIPT directive in the	configuration file.  If	script
       labels are provided, they must be unique	for each SCRIPT	directive.

       A script	label is mandatory when	any launch conditions  are  separately
       specified  with	a  LAUNCHER  directive - Heyu needs it to match	up the
       launcher	with its corresponding script.	But most users probably	 won't
       bother with the LAUNCHER	directives.

       The  symbol  '::' (two colons) is mandatory, to tell Heyu when the list
       of launch conditions ends and the command line begins.

       When a script is	launched, Heyu provides	additional  environment	 vari-
       ables  containing  information  from Heyu's record of the state of each
       module, plus a few other	variables to simplify writing the script.  The
       script options allow some variation in the type and format of these en-
       vironment variables.

       Script options are:

       -xtend (or simply -x)  -	Provide	an environment compatible  with	 Xtend
       scripts.

       -rawlevel  (or  simply -r) - Include native dimlevel of modules instead
       of percentage of	full On	level in the Heyu environment, i.e., for stan-
       dard modules 0-210; for preset modules 1-32; for	extended code  modules
       0-62;  for  VDATA  modules 0-255.  This option is incompatible with the
       -xtend option.

       -noenv (or simply -n) - Provide no environment variables	 beyond	 those
       which already exist in the user's environment.

       -quiet  (or  simply  -q)	 - Heyu	will normally display the script label
       along with the full command line	in the	log  file  when	 a  script  is
       launched.   This	option directs Heyu to display only the	script label -
       useful if you have a very long command line and don't want  to  clutter
       your log	file.

       -qquiet	(or simply -qq)	- This option directs Heyu suppress display of
       even the	script label in	the log	file when a script  is	launched.   It
       may  be	useful when you	have a bunch of	interrelated SCRIPT directives
       and having the launching	of all of them displayed in the	 log  file  is
       more  confusing	than  instructive.  However please use this only after
       you have	confirmed that your scripts are	working	 correctly  and	 reli-
       ably.

       Script  options must be placed between the '::' separator and the start
       of the command line.

       Example:
	 SCRIPT	 D1 off	:: -x  myxtend.sh

       See the section SCRIPT ENVIRONMENT below	for a description of these en-
       vironment variables.

LAUNCH CONDITIONS FOR NORMAL SCRIPTS
       The launch conditions tell Heyu under what conditions a script is to be
       launched.  Each time an X10 function is sent or received	(or  a	power-
       fail  signal  is	 received - more about this in the next	section), Heyu
       will test to see	which (if any) of the conditions are  satisfied.   The
       testing is performed in the order in which the conditions are specified
       in  the	configuration  file, and stops once the	conditions are matched
       and a script is launched.

       For normal scripts, each	set of launch  conditions  specifies  the  af-
       fected  housecode|units,	 the  function or functions, optional function
       mode keywords, the allowed source(s) of	the  functions,	 and  optional
       flag conditions.
	 HU functions [keywords] [sources] [flags]

       The  housecode|units string 'HU'	must always come first and must	always
       include a units list even when a	function like 'alloff' (all units off)
       is specified.  Using an asterisk	('*') in place of a units list,	 'H*',
       will  launch  on	any unit 1-16 but in the context of a launch condition
       will launch even	when no	units are addressed, so	can be used when it is
       desired to specify a launch when	one of the specified functions is  re-
       ceived for that housecode regardless of unit addresses.

       An  alias may be	used in	place of a housecode|units string.  Functions,
       keywords, and sources may appear	in any order after that.

       Whether included	within the SCRIPT directive or separately in  LAUNCHER
       directives,  multiple launch conditions for the same script may be con-
       tinued on the same line by separating each group	of conditions  with  a
       semicolon (';''), i.e.,
	 HU  functions	[keywords]  [sources] [flags]; HU functions [keywords]
       [sources] [flags]; ...

       Functions which can be specified	in a launch condition are any  of  the
       native  X10  functions:	on,  off,  dim,	 bright,  lightson, lightsoff,
       alloff, preset,	extended,  hail,  hail_ack,  status,  status_on,  sta-
       tus_off,	 data_xfer.   Also  functions allon, xpowerup, and vdata.  The
       general functions 'anyplc' or 'anyfunc'	in  a  launch  condition  will
       match any of the	above.

       RF  signals  received  from  X10	 security  remotes and sensors via the
       heyu_aux	daemon provide the additional functions	 disarm,  arm,	alert,
       clear,  panic,  slightson,  slightsoff,	sdusk, and sdawn.  The general
       functions 'anysec' or 'anyfunc' will match any of these.

       RF signals from RFXSensor 1-Wire	temperature, humidity, and  barometric
       pressure	 sensors  which	 can be	used in	launch conditions are rfxtemp,
       rfxtemp2, rfxrh,	rfxbp, rfxlobat, rfxvad, rfxpot, and rfxvs.  The  gen-
       eral functions 'anyrfx' or 'anyfunc' will match any of these.
       For more	details	see man	page x10rfxsensors(5).

       RF  signals from	RFXMeter power,	water, gas, and	pulse meters and coun-
       ters which can be used in launch	conditions  are:  rfxpower,  rfxwater,
       rfxgas,	rfxpulse,  and	rfxcount.   The	 general functions 'anyrfx' or
       'anyfunc' will match any	of these.
       For more	details	see man	page x10rfxmeters(5).

       RF signals from Oregon sensors which can	be used	in  launch  conditions
       are: oretemp, orerh, orebp, and orewgt.
       For more	details	see man	page x10oregon(5).

       RF  signals  from  DigiMax  210 Thermostats which can be	used in	launch
       conditions are: dmxtemp,	dmxon, dmxoff, and dmxsetpoint.
       For more	information see	man page x10digimax(5).

       The 'allon' function is Heyu-defined and	in reality is  just  the  'on'
       signal when sent	to all 16 unit codes on	a housecode. (Note: 'allon' as
       used  in	 Heyu  1.xx  is	 the same as 'lightson', which is not the case
       here.)
       The 'xpowerup' function is sent by X-10 2-way modules  like  the	 LM14A
       and  AM14A at power-up following	an AC power interruption of at least a
       few seconds duration.

       Heyu also defines three 'generic' functions: gon, goff, and gdim.

       The generic 'gon'  encompasses any  of:	on,  lightson,	allon,	preset
       level 32, or extended preset level 62 or	63.

       The  generic  'goff' encompasses	any of:	off, lightsoff,	alloff,	preset
       level 1,	or extended preset level 0.

       The generic 'gdim' encompasses any of: dim, bright, or  any  preset  or
       extended	 preset	 levels	 between  the  limits  specified for 'gon' and
       'goff'.

       One or more functions can be specified in each launch  condition.   The
       logic used when the HU contains more than one unit and/or there is more
       than one	function is illustrated	in the following example:

	  SCRIPT  A1,3	on  off	 flag4	notflag7 :: myscript.sh
       is equivalent to:

       IF (A1 is addressed OR A3 is addressed) AND
	  (function On is received OR function Off is received)	AND
	  flag4	is set AND flag7 is not	set
       THEN
	  Execute myscript.sh

       KEYWORD 'trigemu'

       If a macro is uploaded to the CM11A EEPROM memory and a powerline trig-
       ger (e.g., "A1 on") is defined for it, the macro	will only be triggered
       when the	powerline address signal immediately precedes the powerline On
       function, with no intervening address or	function signals. Inclusion of
       the 'trigemu' keyword in	the launch conditions emulates this behavior.
       Example:	 If the	sequence "Addr A1, Addr	A2, Addr A3, Func On A"	is re-
       ceived in that order, a script will be launched with the	launch	condi-
       tion:
	 A2 on
       but not with the	launch condition:
	 A2 on trigemu
       because	the Addr A3 signal intervened between the Addr A2 and the Func
       On A signals.

       Note: the 'trigemu' keyword is ignored for lightson, lightsoff, alloff,
       and extended functions in the launch conditions.

       KEYWORD 'module'

       In the default 'signal' mode, whether or	not a script is	 launched  de-
       pends only on reception of the function at the housecode|unit as	speci-
       fied  in	 the launch condition and is independant of the	module at that
       address.

       Inserting the keyword 'module' in the launch conditions results in  X10
       signals	being  'filtered'  by the attributes of	the modules before the
       launch conditions are tested. For  example,  a  script  otherwise  pro-
       grammed	to  be launched	when the 'dim' signal is received would	not be
       launched	if the module at the particular	housecode|unit happened	to  be
       an appliance module (as defined in the ALIAS directive).

       KEYWORD 'changed'.

       Inserting  the  keyword	'changed'  in  the  launch conditions inhibits
       launching a script unless the function causes a	change	in  the	 major
       state  of the module, i.e., if it's in the Changed state.  For example,
       the launch condition 'A1	off changed' will not launch the script	if the
       module at A1 is already in the Off state	when the 'off' function	is re-
       ceived.

       In the case of RF signals received  from	 the  auxiliary	 input	daemon
       heyu_aux	 (source  RCVA),  any difference in the	data from the previous
       transmission at the same	housecode|unit address is considered a change.
       (The difference in the data for it to be	considered changed may be con-
       figured for Oregon sensors.)

       The keyword 'changed' automatically  implies  the  filtering  otherwise
       performed  when	the  keyword 'module' is specified and doesn't require
       separately specifying it.

       KEYWORD 'continue'.
       KEYWORD 'break'.

       See section "SCAN MODE" below for the usage of these keywords.

       SOURCES

       By default, a script is launched	only when the X10 function is received
       over the	AC power line (rcvi) by	the CM11A interface.  This can be  ex-
       tended to other sources by including one	or more	source keywords	in the
       launch  conditions.   For example, 'A1 on sndc' would launch the	script
       if the function is either received over the power line (per the default
       rcvi) or	sent from the Heyu command line.

       The source keyword 'anysrc' can be used to represent the	sources	 sndc,
       sndm,  sndt,  sndp,  snda,  rcvi,  rcvt,	 rcva.	It excludes the	source
       'snds'.

       The source 'snds' can be	separately specified if	you really have	to use
       it, but ONLY when you have verified that	its  use  won't	 result	 in  a
       script  loop.   A script	loop WOULD result in the following simple (and
       obvious)	case:
	  SCRIPT  A1 on	rcvi snds  ::  heyu turn A1 on

       however the possibility of a script loop	may not	be  quite  so  obvious
       when you	have multiple and/or more complex SCRIPT directives.

       Note  that  the	default	 source	 or  sources  can  be changed with the
       LAUNCHER_SOURCE directive in the	configuration file.

       One can disallow	default	sources	by prefixing  the  source  with	 'no',
       e.g.,  'norcvi',	 'nosndm'.  The	keyword	'nosrc'	has a special use - it
       has the function	of cancelling out all of the default sources.  It must
       always be accompanied by	one or more actual source keywords if a	script
       is to be	launched.

       Warning:	Functions with sources 'sndm' or 'sndt'	are processed by  Heyu
       at the time it receives the signal from the CM11A that a	macro has been
       executed, which may be some time	- seconds or even minutes depending on
       the length of the macro - before	the functions are actually transmitted
       by  the	CM11A.	Thus the state of the modules as recorded by Heyu will
       be incorrect before the functions are actually transmitted.   In	 addi-
       tion,  the  CM11A  will	not  accept further commands while it's	in the
       process of transmitting the macro commands, so an attempt to  send  an-
       other  command  may time	out.  To avoid these problems, the 'heyu wait'
       command can be used to defer execution of a launched script  until  all
       macro commands have been	transmitted.
       Example:
	  SCRIPT A1 on sndm :: heyu wait; (($X10_B2 & $isOn)) && heyu on C3

       FLAGS

       Flags  which  may be tested as part of the launch conditions are: state
       flags which reflect the corresponding state of a	 module	 (see  heading
       STATE FLAGS below); common software flags flag1...flagNN	set or cleared
       by  Heyu	state commands;	the counter-zero flags czflag1...czflagNN; the
       timer-zero flags	tzflag1...tzflagNN; the	 global	 security  flags  dis-
       armed,  armed,  notarmed,  armpending, home, and	away; the flags	night,
       dark, and their negations notnight and notdark; plus the	 "local	 flag"
       security	 switch	or low battery condition swhome, swaway, swmin,	swmax,
       and lobat transmitted by	security remotes and sensors.  (When  used  by
       themselves, home	or away	imply armed.)  RFXMeter	sensors	set a testable
       'rollover'  local flag at the first signal after	the counter rolls over
       from its	maximum	value (0xFFFFFF) to zero. A local 'rollover'  flag  is
       also  set  for  other sensors which store and transmit cumulative data,
       e.g., Oregon rain sensors.

       The common flag "true-if-set" keywords are flag1, flag2,	... ,  flagNN.
       The  flag  "true-if-clear"  ("true-if-reset")  terms are	notflag1, not-
       flag2, ... , notflagNN. Similar "true-if-clear" keywords	are recognized
       for counter-zero	and timer-zero flags, e.g., notczflag1,	nottzflag10;

       Inclusion of one	or more	of the flag keywords in	the  launch  condition
       means  that  each  and  every  flag state must be TRUE in order for the
       script to be executed.  In other	words, the flag	state  is  AND'd  with
       all the other launch conditions.
       Examples:
	  SCRIPT B1 on rcvi flag4 flag6	notflag8 :: my_command
       In  the above, my_command will be executed when the B1 On signal	is re-
       ceived only if flags 4 and 6 are	set and	flag 8 is not set (clear).
	  SCRIPT back_door alert armed rcva :: heyu on siren
       In the above, the module	controlling a siren is turned on when the back
       door is opened and the door/window security sensor on that door	trans-
       mits the	alert signal while the system is armed.
	  SCRIPT motion_sensor on night	:: heyu	on porch_light
       The  above  will	turn on	the porch_light	only if	the On signal from the
       motion_sensor is	received between Dusk and Dawn.
	  SCRIPT motion_sendsor	on dark	:: heyu	on porch_light
       The above is similar to the previous one, but the condition is that the
       motion_sensor signal is received	between	Dusk+Offset  and  Dawn-Offset,
       where Offset is defined by the config directive ISDARK_OFFSET.

       STATE FLAGS

       State flags are global and can be used in the launch conditions for any
       script.	 They are TRUE when the	corresponding state or flag state of a
       Hu address is TRUE.  Their use can simplify Heyu	SCRIPT	directives  by
       making  it  unnecessary to use shell logic to check the state of	a mod-
       ule.
       Up to 32	state flags may	be used	in a launch condition and each must be
       TRUE for	the script to be launched.

       The format for a	state flag consists of the state and Hu	address	 sepa-
       rated  by  a  colon  (':')  with	 no  embedded spaces, e.g., "on:B7" or
       "on:Porch_Light".  Like other flags, state flags	are not	case sensitive
       _except_	for an alias label (like "Porch_Light")	if used,  since	 alias
       labels are always case sensitive. If an alias label is used, it must be
       for a single unit alias.

       The  list  of states which can be included in a state flag follows, but
       run 'heyu stateflaglist'	to make	sure you have the  current  list.   In
       the following, Hu is the	Housecode|single_unit address or Alias label.
       Prefixing a flag	with "not" is the negation for all state flags.

	 on:Hu	       Hu is in	the On state
	 off:Hu	       Same as noton:Hu
	 dim:Hu	       Hu is in	the Dimmmed state
	 alert:Hu      An Alert	signal has put Hu into the alert state.
	 clear:Hu      A Clear signal has put Hu into the clear	state.
	 auxalert:Hu   An AuxAlert signal has put Hu into the auxalert state.
	 auxclear:Hu   An AuxClear signal has put Hu into the auxclear state.
	 sdusk:Hu      An sDusk	signal has put Hu into the sdusk state.	(GB10,
       DM10)
	 sdawn:Hu      An sDawn	signal has put Hu into the sdawn state.	(DM10)
	 valid:Hu      A supported signal has been received since start.
	 active:Hu	A valid	signal has been	received before	INACTIVE_TIME-
       OUT.
	 inactive:Hu   No valid	signal has been	received before	INACTIVE_TIME-
       OUT.
	 addr:Hu       The X10 module at Hu is in the addressed	state.
	 tamper:Hu     The tamper flag has been	raised for sensor Hu.
	 chg:Hu	       The last	signal on H resulted in	a change of state  for
       Hu.
	 lobat:Hu      The low battery flag has	been raised for	sensor Hu.
	 rollover:Hu   The rollover flag is raised for sensor Hu.
	 swmin:Hu      The swMin flag has been raised for sensor Hu.
	 swmax:Hu      The swMax flag has been raised for sensor Hu.
	 tmin:Hu       The Tmin	flag has been raised for sensor	Hu.
	 tmax:Hu       The Tmax	flag has been raised for sensor	Hu.
	 rhmin:Hu      The RHmin flag has been raised for sensor Hu.
	 rhmax:Hu      The RHmax flag has been raised for sensor Hu.
	 bpmin:Hu      The BPmin flag has been raised for sensor Hu.
	 bpmax:Hu      The BPmax flag has been raised for sensor Hu.
	 main:Hu       The Main	flag has been raised for sensor	Hu.
	 aux:Hu	       The Aux flag has	been raised for	sensor Hu.
	 heat:Hu       The DigiMax Heat	flag has been raised.
	 set:Hu		The  DigiMax  Setpoint	Temperature  Set flag has been
       raised.
	 init:Hu       The DigiMax Initialazation Init flag has	been raised.

       Please note that	for sensor signals in particular,  the	flag  negation
       does  not necessarily imply an opposite state, e.g., until a valid sig-
       nal is received,	both alert:Hu and clear:Hu may be FALSE, so  that  no-
       talert:Hu does not imply	clear:Hu.

       Similarly,  after  a start and until the	first valid signal is received
       or until	an initial INACTIVE_TIMEOUT interval, both active:Hu and inac-
       tive:Hu will be FALSE.

SCAN MODE
       When a signal is	received by the	heyu_engine daemon,  Heyu  by  default
       scans  the  list	 of  SCRIPT launch conditions and executes the command
       line for	the first one where its	launch conditions are  satisfied.   As
       there  are  occasions when it would be convenient to have more than one
       SCRIPT command line be executed upon receipt of a signal, this  default
       behavior	can be modified	with a combination of the configuration	direc-
       tive  LAUNCHER_SCANMODE	and  launch  condition keywords	'continue' and
       'break'.

       The config directive LAUNCHER_SCANMODE can take the parameters BREAK or
       CONTINUE, with the default being	BREAK.	The parameter  BREAK  provides
       the  default  behavior  described above.	 With parameter	CONTINUE, Heyu
       will execute the	command	line for all SCRIPTs where the	launch	condi-
       tions are satisfied.

       The  scan mode specified	by LAUNCHER_SCANMODE can be overridden for in-
       dividual	SCRIPTs	by including the keyword 'continue' or 'break' in  the
       launch conditions.  Following are some simple (trivial) examples.

       Example:
	 LAUNCHER_SCANMODE  BREAK
	 SCRIPT	-l DimLights A1	on rcvi	continue :: heyu turn B1,2,3 dimb 10
	 SCRIPT	-l TurnOnTV  A1	on rcvi	:: heyu	turn tv_set on
	 SCRIPT	-l TurnOffTV A1	on rcvi	:: heyu	turn tv_set off

       In  the above example, receipt of signal	"A1 On"	results	in the command
       lines for both DimLights	and TurnOnTV being executed.  TurnOffTV	is not
       executed	because	the scan mode reverts to BREAK when TurnOnTV  is  exe-
       cuted.

       Example:
	 LAUNCHER_SCANMODE CONTINUE
	 SCRIPT	-l DimLights A1	on rcvi	:: heyu	turn B1,2,3 dimb 10
	 SCRIPT	-l TurnOnTV  A1	on rcvi	break :: heyu turn tv_set on
	 SCRIPT	-l TurnOffTV A1	on rcvi	:: heyu	turn tv_set off

       The  above works	the same as the	first example -	the 'break' keyword in
       TurnOnTV	tells Heyu to stop scanning once  its  launch  conditions  are
       satisfied.

       Tip:  In	most cases users will find it more convenient and less confus-
       ing to keep the default "LAUNCHER_SCANMODE BREAK"  and  use  the	 'con-
       tinue' keyword where required.

       It's  ESSENTIAL	to understand what happens in Heyu when	using the con-
       tinue and break features.
       When a signal is	received by heyu_engine, Heyu starts scanning the list
       of launch conditions and	tags those where the conditions	are satisfied.
       It stops	scanning when a	launch condition is  satisfied	and  the  scan
       mode  is	 BREAK.	 Heyu then goes	back and executes in order the command
       lines for all SCRIPTs which were	tagged in the first pass.

       Several things to keep in mind:
       When more than one script is executed, the launch condition for	subse-
       quent  scripts  may  no	longer be true if conditions are modified by a
       preceding script, but the script	is launched nevertherless.
       Example:
	 SCRIPT	-l ResetFlag A1	on rcvi	flag1 continue :: @clrflag 1
	 SCRIPT	-l DoSomething A1 on rcvi flag1	:: something.sh

       In the example above, both scripts will be executed if Flag  1  is  set
       when  signal  A1	 On  is	received.  But when script DoSomething is exe-
       cuted, condition	flag1 will no longer be	TRUE since the flag will  have
       been  cleared  by  execution  of	 the previous script ResetFlag command
       line.  This may be important if the shell script	"something.sh"	relies
       on  the	value  of  environment	variable  $X10_Flag1  or  calls	 'heyu
       flagstate 1' to direct its operation.

       Secondly, when multiple shell commands or shell scripts	are  executed,
       the  order of actual command execution is determined in part by the op-
       erating system, with each script	getting	its multitasking  time	slices
       (typically  10 milliseconds).  (This does not apply to the internal en-
       gine precommands	like @clrflag which are	 executed  within  heyu_engine
       before shelling out the remainder of the	command	line.)

LAUNCH CONDITIONS FOR ADDRESS SCRIPTS
       Launch  conditions are identical	to those for normal scripts except the
       keyword 'address' is used in place of any and all  functions.   Neither
       functions nor the keywords 'changed', 'signal' or 'module' may be spec-
       ified  for  address  scripts.  (Likewise, the keyword 'address' may not
       appear in the launch conditions for normal acripts.)  The launch	condi-
       tions may include sources and flags as for normal scripts.

       Note that the launch conditions for address scripts are evaluated  each
       time an address signal is encountered and those for normal scripts each
       time  a function	signal is encountered, so it's possible	to have	multi-
       ple script launchings for what might appear to be a single X10  command
       but which in reality is two separate events.

LAUNCH CONDITIONS FOR POWERFAIL	SCRIPTS
       For powerfail scripts, the launch conditions always start with the spe-
       cial  keyword  '-powerfail' (note the '-' prefix) and may optionally be
       followed	with  flag  conditions.	  (Module  addresses,  functions,  and
       sources are not applicable for powerfail	scripts.)
	 -powerfail [flags]

       As  with	 normal	scripts, each of the specified flag conditions must be
       TRUE for	the script to be launched, and the  same  flag1,  flag2,  ...,
       flagNN  and notflag1, notflag2, ..., notflagNN keywords are valid.  Se-
       curity flags (disarmed, armed, armpending,  home,  away)	 may  also  be
       tested,	however	they may not be	valid if the computer has been powered
       down during the power interruption.
       In addition there are two special flags,	'boot' and 'notboot' which are
       valid only for powerfail	launchers.  The	boot flag is set by  the  Heyu
       relay  daemon at	the time it is first started and cleared a few seconds
       afterwards.

       If the boot flag	is included in the launch condition, then  the	script
       will  be	 launched only if the powerfail	signal is received immediately
       following the startup of	the Heyu relay daemon, i.e., if	the  CM11A  is
       polling for a clock update at the time Heyu is first started.

       Conversely,  if	the  notboot flag is included in the launch condition,
       the script will be launched only	if the powerfail  signal  is  received
       after the initial refractory period of a	few seconds.

       If  neither  the	boot nor the notboot flag is included, then the	script
       will be launched	regardless of the time the  powerfail  signal  is  re-
       ceived.

       Note:  A	 powerfail  script  can	be launched at startup ONLY if Heyu is
       started with the	'heyu engine' or 'heyu start' commands,	else the state
       engine daemon won't be running in time to catch the powerfail signal at
       startup.

LAUNCH CONDITIONS FOR RFFLOOD SCRIPTS
       An RFflood signal is issued with	the "started" flag when	an RF flood is
       first detected, then again at increasing	 longer	 intervals  while  the
       flood  continues.   Another  RFflood  signal is issued with the "ended"
       flag when the flood ceases.  Either of these two	flags can be tested in
       the launch conditions along with	any of the other flags.
       Example:
	  -rfflood  started

       Housecode|unit addresses, functions, and	sources	are not	applicable for
       RFFLOOD script launch conditions.

LAUNCH CONDITIONS FOR RFJAMMING	SCRIPTS
       An RFJamming signal is issued with either the "started" or "ended" flag
       as reported by an (older) RFXCOM	receiver, and with the "main" or "aux"
       flag depending on whether the signal  originated	 with  the  master  or
       slave  RFXCOM receiver.	All of these flags can be tested in the	launch
       conditions along	with any of the	other flags.
       Example:
	  -rfjamming  started aux

       Housecode|unit addresses, functions, and	sources	are not	applicable for
       RFJAMMING script	launch conditions.

LAUNCH CONDITIONS FOR SENSORFAIL SCRIPTS
       Sensorfail scripts are deprecated and ignored in	favor of the  Inactive
       pseudo-signal unless config directive "INACTIVE_HANDLING	 OLD" is used.
       If  Heyu	 has  not  received  any  signal from a	security sensor	with a
       heartbeat, either a normal alert	or its periodic	"alive"	signal,	in the
       interval	specified by the INACTIVE_TIMEOUT directive, it	can  launch  a
       '-sensorfail'  script.  Any  of the global flags	may be included	in the
       launch conditions.
       Example:
	  -sensorfail  armed

LAUNCH CONDITIONS FOR TIMEOUT SCRIPTS
       Heyu can	launch a script	when a countdown timer set by the user reaches
       zero.  The particular timer must	be specified. Any of the global	 flags
       may also	be included.
       Example:
	  -timeout  timer2  flag3

LAUNCH CONDITIONS FOR EXEC SCRIPTS
       Exec script launch conditions may include only global flags, i.e.,
	 State flags, e.g., on:B7, dim:A4
	 flag1 ... flagNN, notflag1 ...	notflagNN
	 czflag1 ... czflagNN, notczflag1 ... notczflagNN
	 night,	notnight, dark,	notdark.
	 disarmed, armed, notarmed, armpending,	home, away, tamper.
       Example:
	   -exec  armed	away night flag1

       If  there  are  no flags	in the launch conditions the "::" separator is
       still required, e.g.,
	   -exec :: <command_line>

LAUNCHERS
       Launchers are an	alternative way	of specifying  the  launch  conditions
       for  a  script.	They can be useful when	you have multiple or very com-
       plex sets of launch conditions, otherwise most users will probably find
       it more convenient (and less confusing) to include all the launch  con-
       ditions in the SCRIPT directive.

       The format for a	launcher directive in the configuration	file is:
	  LAUNCHER  <script_label>  HU functions [keywords] [sources] [flags];
       HU functions [keywords] [sources] [flags]; ...
       where the mandatory script_label	(no -l switch is used here) must match
       the label in the	SCRIPT directive to which it applies.

SCRIPT COMMAND LINE
       The command line	can be any valid command line for the  OS  and	shell,
       including  shell	commands and logic, shell scripts, binary executables,
       and multiple strings of these delimited by semicolons.

       In addition, there are internal engine precommands which	can be used at
       the beginning of	the command line to set	flags  and  countdown  timers.
       These  are processed by the engine before the remainder of the line, if
       any, is actually	launched as a child  process.	Their  use  guarantees
       that  their  functions  are  carried  out  in the order the scripts are
       launched, as opposed to the order in which child	processes might	 actu-
       ally  execute  them  as	direct	commands when there are	multiple child
       processes launched in rapid succession.
       These precommands are: @arm, @disarm,  @setflag,	 @clrflag,  @settimer,
       @setrtimer,  @clrtimers,	 @clrspend,  @vdata, @vmdata, @setcount, @inc-
       count, @deccount, @decskpz, @decskpgz, @decskpgziz,  and	 @null.	  They
       take  the same parameters and operate the same as the corresponding di-
       rect commands without the '@' prefix.  (The @null does nothing and  can
       be used as a placeholder	to serve as an empty command line, which would
       otherwise  generate an error message.)  They are	not used as parameters
       to Heyu but as stand-alone commands, and	must  appear  in  the  command
       line before any normal command.
       Examples:
	 SCRIPT	A1 off :: @settimer 7 0
	 SCRIPT	A1 on :: @setflag 3; @settimer 7 5; heyu on A2

       The  @decskpz,  @decskpgz, @decskpnziz (decrement/skip) precommands and
       @null precommand	don't have corresponding direct	commands.  In addition
       to decrementing the counter, a @decskpxxx also terminates further  exe-
       cution of the command line ("skips") when the decrement and skip	condi-
       tions are met.

       The '@decskpz N'	decrements counter N and skips if the result is	zero.
       The  '@decskpgz	N'  decrements	counter	 N  and	skips if the result is
       greater than zero.
       The '@decskpnziz	N' decrements counter N	and skips  if  the  result  is
       non-zero	 or if the counter is initially	zero.  It emulates the similar
       command in computer languages where the counter is a variable which can
       be considered to	have negative values.  Insofar as Heyu	is  concerned,
       it  will	 skip  when the	result is greater than zero, not skip when the
       counter is first	decremented to zero, but then  skip  on	 further  _at-
       tempted_	 decrements  since  a  zero Heyu counter cannot	be decremented
       further.	In other words its function is to "decrement and skip on  non-
       zero then run only the first time the counter goes to zero".

       Examples:
       If counter 7 has	previously been	set to the value 3 and we have:
	 SCRIPT	A1 on :: @decskpz 7; heyu on A2; ...
       then  the  remainder of the command line	following the @decskpz precom-
       mand will be executed on	the first and second "A1 on" signals  but  ig-
       nored for subsequent "A1	on" signals.  Conversely, if we	start with the
       same counter setting and	have:
	 SCRIPT	A1 on :: @decskpnziz 7;	heyu on	A2; ...
       then  the  remainder  of	 the  command  line  will be ignored until the
       counter reaches zero, when it will be executed.	The remainder  of  the
       command	line  will also	be ignored if the value	of the counter is ini-
       tially zero since it can't be decremented further.

SCRIPT ENVIRONMENT for Heyu scripts
       When the	-xtend option is NOT specified,	Heyu provides a	number of  en-
       vironment  variables which can be used by scripts.  Here	is a summary -
       see below for descriptions and examples:
       X10CONFIG
       X10_A1 ... X10_P16
       x10_<alias> ...	(Note lower case prefix	'x10_')
       whatLevel, isAppl, isSpend, isOff, isOn,	isAddr,	isChg, isDim, isAlert,
       isClear,	isAuxAlert, isAuxClear,	isValid,  isActive,  isInactive,  isS-
       dusk, isSdawn
       isLoBat,	isRollover, isSwMin, isSwMax, isMain, isAux, isTamper, isTmin,
       isTmax, isRHmin,	isRHmax, isBPmin, isBPmax, isSet, isHeat, isInit.
       X10_Housecode,	X10_Unit,  X10_LastUnit,  X10_Function,	 X10_function,
       X10_Source, X10_UnitAlias, X10_Linmap
       X10_PresetLevel
       X10_Xfunc, X10_Xdata
       X10_BrightVal, X10_DimVal, X10_RawVal
       X10_Flag1, X10_Flag2, ... , X10_FlagNN
       X10_Timer1, X10_Timer2, ..., X10_TimerNN
       X10_Counter1, X10_Counter2, ...,	X10_CounterNN
       X10_Year,  X10_Month,  X10_MonthName,  X10_Day,	X10_Hour,  X10_Minute,
       X10_Second,  X10_WeekDay,  X10_WeekDayName,  X10_isDST, X10_DateString,
       X10_GMT
       X10_DawnTime, X10_DuskTime, X10_SysTime
       X10_isNightTime,	X10_isDarkTime
       X10_Vdata, X10_SecLights
       X10_Disarmed, X10_Armed,	X10_ArmPending,	X10_Home, X10_Away
       X10_swMin, X10_swMax, X10_swHome, X10_swAway, X10_LoBat
       X10_Timer, X10_Sensor
       helper, bighelper
       X10_Expire

       The environment variable	X10CONFIG contains the full  pathname  of  the
       configuration  file  in effect for the Heyu state engine.  Unless over-
       ridden, instances of Heyu executed by a script will therefore automati-
       cally use the same configuration	file.

       For each	housecode|unit 'Hu', the state variable	'X10_Hu=bitmap'	 where
       the  bit	 values	 in 'bitmap' are defined by mask variables of the form
       'isXXX'.
       (Run 'heyu masklist' to insure having a current list.)

	 'whatLevel'  (Bits 0 through 7	represent the module dim level,	or for
       security	devices, the security data byte).
	 'isAppl'     Unit has no Dim/Bright attribute.
	 'isSpend'    Status pending bit.
	 'isOff'      Unit is not in the On state
	 'isAddr'     Unit is Addressed
	 'isChg'      Unit is Changed
	 'isDim'      Unit is Dimmed
	 'isValid'    A	supported signal has been sent/received.
	 'isClear'    The sensor is in the Clear state.
	 'isAlert'    The sensor is in the Alert state.
	 'isAuxClear' the sensor is in the AuxClear state.
	 'isAuxAlert' The sensor is in the AuxAlert state.
	 'isSdawn'    The security sensor is in	the sDawn state.
	 'isSdusk'    The security sensor is in	the sDusk state.
	 'isActive'   A	signal or heartbeat has	been received within
			the INACTIVE_TIMEOUT interval
	 'isInactive' No signal	or heartbeat has been received within
			the INACTIVE_TIMEOUT interval.
	 'isOn'	      Unit is in the On	state.

       The module dim level will be either the integer 0  through  100	repre-
       senting	the  percentage	of full	brightness, or the native module level
       (0-210, 1-32, 0-62, or 0-255) if	the -rawlevel script option is	speci-
       fied.  (The dim level for an appliance module will be either the	lowest
       value if	it's Off or the	highest	value if it's On.)

       Note  that  for states controlled by sensor signals, e.g., Alert/Clear,
       the sensor will be in neither corresponding state  following  start  or
       restart	until a	Valid signal is	received, or in	the case of Active/In-
       active until the	INACTIVE_TIMEOUT interval has elapsed.

       For each	single-unit ALIAS defined in the configuration file, the state
       variable	'x10_<alias_label>=bitmap', e.g.,
	 x10_porch_light=<bitmap>
       where <bitmap> is as described above.

       For X10 Security	and other RF devices,  the  variables  'X10_Hu_vFlags'
       and  'x10_<alias_label>_vFlags'.	 These are bitmaps with	bits which may
       also be tested with masks.  Run 'heyu masklist' for a complete  current
       list, but here are some commonly	used ones:
	 'isLoBat'     Low battery flag
	 'isRollover'  Rollover	flag.
	 'isSwMin'     Door/Window sensor Min switch
	 'isSwMax'     Door/Window sensor Max switch
	 'isMain'      Main channel of two-channel sensor
	 'isAux'       Aux channel of two-channel sensor
	 'isTamper'    Tamper flag
	 'isTmin'      Min temperature flag
	 'isTmax'      Max temperature flag
	 'isRHmin'     Min Relative Humidity flag
	 'isRHmax'     Max Relative Humidity flag
	 'isBPmin'     Min Barometric Pressure flag
	 'isBPmax'     Max Barometric Pressure flag
	 'isSet'       DigiMax Setpoint	temperature is Set mode	flag
	 'isHeat'      DigiMax Heat mode flag
	 'isInit'      Digimax Initialation Init flag

       Note  that the prefix for ALIASes is the	lower case 'x10' to avoid pos-
       sible conflict with the other Heyu environment variables	which are pre-
       fixed  with  the	 upper	case  'X10'.   The   configuration   directive
       ENV_ALIAS_PREFIX	 can  be  used	to revert to the upper case prefix for
       compatibility with existing scripts if absolutely necessary but is dep-
       recated.

       Mask variables are used to test the state variables without  having  to
       remember	the bitmap values.

       Example:	In the bash shell, the construct
	 (($x10_porch_light & $isOn))
       will return TRUE	( > 0 )	if the module aliased to porch_light is	in the
       On state, and
	 level=$(($x10_porch_light & $whatLevel))
       will recover the	brightness level of the	module aliased to porch_light.

       Note:  The  bash	 construct above is compact and	convenient, but	is not
       defined by POSIX.  Other	shells will have to use	the  POSIX  compatible
       construct:
	 [ $(($x10_porch_light & $isOn)) -ne 0 ]
       to test the state of the	module.

       The  mask variables should always be used instead of the	numeric	values
       for testing the state of	a module.  The numeric values  (for  the  Heyu
       environment)  may  change in a future release of	Heyu.  (The bit	repre-
       senting 'On' is however guaranteed to always have the  highest  numeric
       value, so that a	test for 'On' like the example in the Xtend documenta-
       tion  $X10_B4>=128  will	 continue  to work so long as the mask is used
       rather than the numeric value, i.e., $X10_B4>=$isOn.)

       Details of the function which launched the (normal) script:
       'X10_Housecode' (A-P)
       'X10_Unit' (1-16)
       'X10_LastUnit' (1-16)
       'X10_UnitAlias'
       'X10_Linmap'
       where 'X10_Unit'	is the last unit _in X10 order_	of the addressed units
       which resulted in launching the script,	while  'X10_LastUnit'  is  the
       last  addressed	unit for that housecode	(which may or may not have re-
       sulted in launching the script).	 'X10_UnitAlias' is the	label  of  the
       alias corresponding to the address 'X10_Housecode' and 'X10_Unit'.
       'X10_Linmap'  is	 a bitmap of all the addressed units which resulted in
       launching the script, with 1 = unit 1, 2	= unit 2, 4 = unit 3, 8	= unit
       4, etc.

       'X10_Source' (<signal_source>)
       where signal_source  is	"rcvi",	 "rcva",  "sndc",  etc.	 (Without  the
       quotes.)

       'X10_Function' (<func>)
       where  <func>  is  one of the following (as appears in the Heyu monitor
       and/or logfile):
       AllOff, LightsOn, On, Off,  Dim,	 Bright,  LightsOff,  Extended,	 Hail,
       HailAck,	 Preset,  DataXfer,  StatusOn,	StatusOff,  StatusReq,	AllOn,
       xPowerUp, vData,	 vDataM,  Panic,  Arm,	Disarm,	 Alert,	 Clear,	 Test,
       sLightsOn,  sLightsOff,	secTamper,  sDusk,  sDawn,  rfxTemp, rfxTemp2,
       rfxRH, rfxBP, rfxVad, rfxPot, rfxVs, rfxLoBat, rfxOther,	rfxPulse, rfx-
       Power, rfxWater,	rfxGas,	rfxCount, dmxTemp, dmxOn, dmxOff, dmxSetpoint,
       oreTemp,	oreRH, oreBP, oreWgt

       'X10_function' (<func>)
       As above, but <func> is lower case and where applicable can be used  as
       a  Heyu command,	e.g., 'heyu $X10_function Hu'.	(Note that the leading
       "X10_" remains upper case.)

       And only	when <func> is 'Preset':
	  'X10_PresetLevel' (1-32)

       And only	when <func> is 'Extended':
	  'X10_Xfunc' (0-255)
	  'X10_Xdata' (0-255)

       And only	when <func> is 'Dim' or	'Bright':
	  'X10_RawVal' (2-210)	(Unsigned for both Bright and Dim)
	  'X10_DimVal' (2-210)	(+ for Dim, - for Bright)
	  'X10_BrightVal' (2-210) (+ for Bright, - for Dim)

       And only	when <func> is 'Arm':
	  'X10_swHome' Logical (0 or 1)
	  'X10_swAway' Logical (0 or 1))

       And only	when <func> is 'Arm' or	'Alert'	or 'Clear':
	  'X10_swMin' Logical (0 or 1)
	  'X10_swMax' Logical (0 or 1)

       And only	for -timeout scripts:
	  'X10_Timer'  (= timer	number 1-NN which launched  script,  or	 "arm-
       timer")

       And only	for -sensorfail	scripts:
	  'X10_Sensor' (= Housecode|Unit of sensor)

       For  RF	data  from  X10	 security, entertainment, RFXSensor, RFXMeter,
       Digimax,	and Oregon transmitters:
	  'X10_Vident' (0-255)
	  'X10_Vdata' or 'X10_vData' (0-255)

       Temperature data	from RCS compatible thermostats	and  remote  thermome-
       ters as X10_H0_Temp and x10_<alias_label>_Temp.

       For RF data from	RFXSensor 1-wire temperature, humidity,	and barometric
       pressure	 sensors:  X10_Hu_Temp,	 X10_Hu_Temp2,	X10_Hu_RH,  X10_Hu_BP,
       X10_Hu_Vs, X10_Hu_Vad, X10_Hu_Vadi, and	X10_Hu_Pot.   Also  the	 alias
       versions	of these variables, i.e., x10_<alias_label>_Temp, etc.

       For RF data from	RFXMeter Power,	Water, Gas, and	Pulse meters and coun-
       ters:   X10_Hu_Power,   X10_Hu_Water,   X10_Hu_Gas,  X10_Hu_Pulse,  and
       X10_Hu_Count.  Also  the	 alias	versions  of  these  variables,	 i.e.,
       x10_<alias_label>_Power,	etc.
       The  variable  X10_rollover  has	 the  Boolian  value  1	or 0 depending
       whether or not the 'rollover' local  flag  was  set  in	the  meter  or
       counter signal which launched the script.

       For  RF data from Oregon	Temp/RH/BP sensors: X10_Hu_oreTemp, X10_Hu_or-
       eRH, X10_Hu_oreBP.  For BP sensors which	transmit a  weather  forecast:
       X10_Hu_oreForecast.   Also the alias versions of	these variables, i.e.,
       x10_<alias_label>_oreTemp. etc.

       For RF data from	Electrisave and	CM113 power  monitors:	X10_Hu_elsCurr
       and X10_Hu_elsPwr, and the alias	version	of these variables.

       For   RF	  data	 from	Owl  CM119  power  monitors:  X10_Hu_owlPower,
       X10_Hu_owlEnergy, and the alias version of these	variables.

       Note: None of the environment variables relating	 to  a	housecode|unit
       and  function  which launches a script exist for	Powerfail, Sensorfail,
       RFFlood,	RFJamming, or Timeout scripts.

       The flag	environment variables, X10_Flag1 ... X10_FlagNN	have values  1
       or 0 when the corresponding flags are respectively set or cleared.

       The   user   coundown   timer  environment  variables,  X10_Timer1  ...
       X10_TimerNN, have the remaining times in	seconds	before timeout.

       Variable	X10_ArmPendingTimer has	the time in seconds  before  the  Arm-
       Pending state will become the Armed state.

       The  counter  environment  variables,  X10_Counter1, ..., X10_CounterNN
       have the	values 0-64K in	those counters.

       The Calendar/Clock variables for	today's	date and time:
       'X10_Year' (e.g., 2004),	'X10_Month' (1-12), 'X10_MonthName' (Jan, Feb,
       etc.),  'X10_Day'  (1-31),  'X10_Hour'  (0-23),	'X10_Minute'   (0-59),
       'X10_Second'  (0-59), 'X10_WeekDay' (0-6), 'X10_WeekDayName' (Sun, Mon,
       etc.).
       'X10_isDST' is a	logical	variable which is TRUE if Daylight Saving Time
       is currently in effect.
       'X10_DateString'	is an ASCII string with	the date and time formatted as
       displayed with events in	the Heyu monitor and log file.

       The variables 'X10_DawnTime', 'X10_DuskTime', and 'X10_SysTime',	 which
       have  the  values for today's Dawn and Dusk time	and the	current	system
       time.  All are expressed	as seconds after  0:00:00  Civil  (wall-clock)
       Time,  although	Dawn and Dusk are computed by Heyu only	to the nearest
       minute.

       (Dawn and Dusk are defined by default to	be synonymous with sunrise and
       sunset, although	this definition	may be changed with the	 configuration
       file directive DAWNDUSK_DEF.  Their calculation require that the	LONGI-
       TUDE  and  LATITUDE of the user's location be defined in	the configura-
       tion file, otherwise these variables will be undefined.	They will also
       be undefined when there is no actual Dawn or Dusk event,	 as  in	 polar
       latitudes during	various	seasons	of the year.)

       The  logical variable 'X10_isNightTime' which is	TRUE between the times
       of Dusk and Dawn.

       The logical variable 'X10_isDarkTime' which is TRUE between  the	 times
       of  Dusk	 and  Dawn  offset by +/- the number of	minutes	defined	by the
       configuration directive ISDARK_OFFSET.	The  default  is  30  minutes,
       meaning this variable will be TRUE between Dusk + 30 minutes and	Dawn -
       30 minutes.

       Example:
	 SCRIPT	 motion_detector  on  :: ( (($X10_SysTime > $X10_DuskTime)) ||
       (($X10_SysTime <	$X10_DawnTime))	) && heyu turn outside_lights on

       will result in turning on the modules aliased to	'outside_lights'  when
       the  motion  detector  module sends the 'on' function, but only between
       Dusk and	Dawn.  Note: This must all be written on one line.
       Somewhat	simpler	in this	case however is	the equivalent:
	 SCRIPT	motion_detector	on :: (($X10_isNightTime)) &&
	   heyu	turn outside_lights on

       The variables 'helper' and 'bighelper'.	These have the same format  as
       the  command line argument passed to the	heyuhelper script when the di-
       rective SCRIPT_MODE HEYUHELPER is chosen, e.g., a1Dim.  They  allow  an
       existing	heyuhelper script to be	run under SCRIPT_MODE SCRIPTS by spec-
       ifying the command line in the SCRIPT directive as
	 SCRIPT	<launch	condition> :: heyuhelper $helper
       or
	 SCRIPT	<launch	condition> :: heyuhelper $bighelper

       This  difference	is that	'bighelper' will supply	the housecode|unit for
       every affected unit  as	successive  command  line  arguments,  whereas
       'helper'	 will  supply  the  housecode|unit  only for the last affected
       unit, the same as in the	heyuhelper feature of Heyu 1.xx.
       For bighelper, the affected unit	arguments will appear in  reverse  X10
       unit order, i.e.,
	 10, 2,	8, 16, 12, 4, 6, 14, 9,	1, 7, 15, 11, 3, 5, 13
       so  the	first  script  argument	 will be the same for either helper or
       bighelper.

       The environment variable	 'X10_Expire'  contains	 the  number  of  days
       (0-365) before expiration of an uploaded	schedule, or a negative	number
       with the	following meaning:
	  -1  SCHEDULE_EXPIRED	(Schedule must be reloaded)
	  -2  NO_EXPIRATION	(Schedule contains no timers)
	  -3  NO_RECORD_FILE	(No schedule has been uploaded)
	  -4  BAD_RECORD_FILE	(File x10record	is corrupted.)

       (These are the same numeric values which	would be displayed upon	execu-
       tion of 'heyu upload cronstatus'.)

SCRIPT ENVIRONMENT for Xtend scripts
       Xtend  (http://www.jabberwocky.com/software/xtend/) by David Shaw is an
       auxilliary program for launching	scripts	based on  received  X10	 power
       line  signals.  Heyu now	provides internally all	the same functionality
       (and more) and Xtend is no longer needed.

       The additional functionality of Heyu requires changes in	 the  environ-
       ment  provided  for  the	script which make it incompatible with scripts
       written for Xtend.  For compatibility with existing Xtend scripts,  the
       -xtend  script option tells Heyu	to instead supply the more limited but
       Xtend-compatible	environment, as	follows:

       The environment variable	X10CONFIG contains the full  pathname  of  the
       configuration  file  in effect for the Heyu state engine.  Unless over-
       ridden, instances of Heyu executed by a script will therefore automati-
       cally use the same configuration	file.

       The state variables 'X10_Hu=xtend_bitmap' for each housecode  and  unit
       'Hu',  where the	bits in	xtend_bitmap now have these values (which cor-
       respond with Xtend's):

	  32  Unit is addressed.
	  64  Unit is an appliance module i.e.,	has no Dim/Bright attributes.
	 128  Unit is On.

       The three mask variables	'isAddr', 'isAppl', and	 'isOn',  with	values
       appropriate for Xtend.

AUTHORS
       Charles W. Sullivan (cwsulliv01@heyu.org)

SEE ALSO
       http://www.heyu.org
       heyu(1),	x10config(5), x10sched(5), x10scripts(5), x10cm17a(5)

				     local			 X10SCRIPTS(5)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=x10scripts&sektion=5&manpath=FreeBSD+Ports+15.0>

home | help