In my migration from HS1.7 to HS3, I've started to migrate events. A lot of them require scripts to run, some were easy just a couple of changes. But some, because of the move from X10 to a ubiquitous generic device paradyme (i.e. by Ref) have be a little stumped. I've tried scanning what I could of the scripting documentation. But before I go any further is there a equivalent or a snippet that will do the same as byName?
As some devices can get false triggers (I.E. a phantom X10 signal, or someone manually turning on a fan or light and HS1.7 doesn't know about it, I wrote my 'Critical Devices' script. Basically, the script will read a data file which has the name of the device and the default state that it should be in unless HS really wanted it in another state.
For example, if HS turned on the fan then the it wants the fan on. But if HS thinks the fan should be off and the default Critical state of the fan should be off, then the script will issue an ON or OFF to ensure that the device is in it's 'resting state'.
The file is simply fully qualified the name of the device and it default resting state. If the internal HS status and the resting state agree then the script will send out a command to ensure that they really are in sync. If they do not agree, then HS must have wanted it in another state.
Basic question, is there an EXEC___ByName or ISON_ByName/ref function that I can use, or a quick way that I can get the reference ID by just using the fully formed name so I can issue a simple ON or OFF command generically?
Thanks.
As some devices can get false triggers (I.E. a phantom X10 signal, or someone manually turning on a fan or light and HS1.7 doesn't know about it, I wrote my 'Critical Devices' script. Basically, the script will read a data file which has the name of the device and the default state that it should be in unless HS really wanted it in another state.
For example, if HS turned on the fan then the it wants the fan on. But if HS thinks the fan should be off and the default Critical state of the fan should be off, then the script will issue an ON or OFF to ensure that the device is in it's 'resting state'.
The file is simply fully qualified the name of the device and it default resting state. If the internal HS status and the resting state agree then the script will send out a command to ensure that they really are in sync. If they do not agree, then HS must have wanted it in another state.
Basic question, is there an EXEC___ByName or ISON_ByName/ref function that I can use, or a quick way that I can get the reference ID by just using the fully formed name so I can issue a simple ON or OFF command generically?
Thanks.
do while f.AtEndOfStream = False
line = f.Readline
devname = hs.stringitem(line,1,",") ' pickup device name
val = lcase(hs.stringitem(line,2,",")) ' requested default status
if left(devname,1) <> "*" then ' if a comment, skip line
hs.waitsecs 2
hs.nolog = True
select case val
case "off"
if hs.isoffbyname(devname) then hs.execx10byname devname,"OFF",0
case "on"
if hs.isonbyname(devname) then hs.execx10byname devname,"ON",0
end select
end if
hs.waitevents ' allow HS to do more important stuff
loop
f.close
hs.nolog = False
line = f.Readline
devname = hs.stringitem(line,1,",") ' pickup device name
val = lcase(hs.stringitem(line,2,",")) ' requested default status
if left(devname,1) <> "*" then ' if a comment, skip line
hs.waitsecs 2
hs.nolog = True
select case val
case "off"
if hs.isoffbyname(devname) then hs.execx10byname devname,"OFF",0
case "on"
if hs.isonbyname(devname) then hs.execx10byname devname,"ON",0
end select
end if
hs.waitevents ' allow HS to do more important stuff
loop
f.close
hs.nolog = False
Comment