The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024


[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Re: Floorplan Sripting Help



Yep,  that's got it working. Had to change "NightMode" to
".NightMode"
as it's an autoscript.
Looking at the modedesc messages in viewer, they all seem to have double
spaces after user, copy&pasting from viewer into floorplan or notepad
leaves a single space, as does capturing the value as a raw device. How
odd.

Max

James Traynor wrote:
>
> There is definitely a issue here with the double space between user
and 1
>
> AlarmState is -mode: security off, user 1-
> would imply there is no double space but the xAP message
> text=Mode: security off, user  1
> has a double space. So i'm not exactly sure where the space is coming
> and going from. Maybe some events from comfort have the double space
> and some don't.
> An easy fix would be :
> Sub Main()
>
> 
AlarmState=xap.GetText("mi4.homeseer.server.93:comfortplugin.modedesc")
> 'makes any double space a single one
>  AlarmState=replace( AlarmState,"  "," ")
>  x=xap.LogDebug("AlarmState is -" & AlarmState &
"-")
>
> 'note this string doesn't have a double space
>  if lcase(AlarmState) = "mode: security off, user 1" then
>      x=xap.LogDebug("Matched")
>      xap.ScriptRun "NightMode"
>  else
>      x=xap.LogDebug("Not matched")
>  end if
>
>  End Sub
>
> James
>
>
> max wrote:
>> No joy.
>>
>> 03/11/2006 19:03:36          Not matched
>> 03/11/2006 19:03:36          AlarmState is -mode: security off,
user 1-
>> 03/11/2006 19:03:36          Starting
>>
>>
>>
>> Here's the original message as sent from homeseer,
>>
>> xap-header
>> {
>>     v=12
>>     hop=1
>>     uid=FF41400E
>>     class=xAPBSC.info
>>     source=mi4.homeseer.server.93:ComfortPlugin.ModeDesc
>> }
>> output.state
>> {
>>     state=ON
>>     text=Mode: security off, user  1
>> }
>>
>> Max
>>
>> James Traynor wrote:
>>
>>> ok, nearly there:
>>>
>>> Mode: security off, user  1
>>> mode: security off, user 1
>>> if you use =  between two strings then they must be identical,
extra
>>> spaces and different cases will cause it not to match. It
seems there
>>> is something going on in Floorplan that has lower cased the
value
>>> which would of stopped the match. The extra space after the
'user '
>>> would of stopped the match too.
>>> Sub Main()
>>> x=xap.LogDebug("Starting")
>>>
AlarmState=xap.GetText("mi4.homeseer.server.93:comfortplugin.modedesc")
>>> x=xap.LogDebug("AlarmState is -" & AlarmState
& "-")
>>>
>>> if lcase(AlarmState) = "mode: security off, user 1"
then
>>> 	x=xap.LogDebug("Matched")
>>> 	xap.ScriptRun "NightMode"
>>> else
>>> 	x=xap.LogDebug("Not matched")
>>> end if
>>>
>>> End Sub
>>> and you should be there
>>>
>>> James
>>>
>>> max wrote:
>>>
>>>> NightMode script doesn't run. Log returns:
>>>> 02/11/2006 21:30:57 	   	Not matched
>>>> 02/11/2006 21:30:57 	   	AlarmState is -mode: security
off, user 1-
>>>> 02/11/2006 21:30:57 	   	Starting
>>>>
>>>>
>>>> max
>>>>
>>>> James Traynor wrote:
>>>>
>>>>
>>>>> Hi,
>>>>>
>>>>> The debug window shows the last error that has
occurred, the only
>>>>> thing that clears it, other than a restart, is a new
error message. It
>>>>> would be very hard to debug things if it did clear
everytime a script
>>>>> ran as there could be quite a lot of scripts running
at once a heavily
>>>>> used Floorplan.
>>>>>
>>>>> Try this script:
>>>>>
>>>>> Sub Main()
>>>>> x=xap.LogDebug("Starting")
>>>>>
AlarmState=xap.GetText("mi4.homeseer.server.93:comfortplugin.modedesc")
>>>>> x=xap.LogDebug("AlarmState is -" &
AlarmState & "-")
>>>>>
>>>>> if AlarmState = "Mode: security off, user 
1" then
>>>>> 	x=xap.LogDebug("Matched")
>>>>> 	xap.ScriptRun "NightMode"
>>>>> else
>>>>> 	x=xap.LogDebug("Not matched")
>>>>> end if
>>>>>
>>>>> End Sub
>>>>> noting the space between ScriptRun and
"NightMode"
>>>>> Run the script and look at the script debug log
especially the line
>>>>> that says
>>>>> AlarmState is -Mode: security off, user  1-
>>>>> What i am wondering is that there may be a space
before or after the
>>>>> data, hence adding the -- to highlight it.
>>>>> If you mail back with what the log says, as this
should at least
>>>>> highlight where the issue is.
>>>>> Thanks
>>>>> James
>>>>>
>>>>> max wrote:
>>>>>
>>>>>
>>>>>> Found a bug I think, the error persisted with and
without the quotes,
>>>>>> didn't clear until I restarted Floorplan. Is the
debug not refreshing,
>>>>>> or holding onto the original, unmodified script?
>>>>>>
>>>>>> Still having a problem with the script, using your
corrections
>>>>>>
>>>>>> Sub Main()
>>>>>> '
>>>>>>
AlarmState=xap.GetText("mi4.homeseer.server.93:comfortplugin.modedesc")
>>>>>> if AlarmState = "Mode: security off, user 
1" then
>>>>>> xap.ScriptRun"NightMode"
>>>>>> else
>>>>>> end if
>>>>>> '
>>>>>> End Sub
>>>>>> The script runs through debugger with no errors,
but doesn't run the
>>>>>> script when AlarnState is correct. I've tried
changing xap.ScriptRun to
>>>>>>
x=xap.SendBSCState("ersp.x10.server:loungelamp","off")
as a test, and
>>>>>> that runs fine through debugger but doesn't appear
to work either.
>>>>>>
>>>>>> Max
>>>>>>
>>>>>> Using
>>>>>> James Traynor wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Hi,
>>>>>>> Could you check this line
>>>>>>>
>>>>>>>
AlarmState=xap.GetText("mi4.homeseer.server.93:comfortplugin.modedesc")
>>>>>>>
>>>>>>> as the error seems to show it without quotes:
>>>>>>>
>>>>>>>
AlarmState=xap.GetText(mi4.homeseer.server.93:comfortplugin.modedesc)
>>>>>>>
>>>>>>> with quotes being correct
>>>>>>> also
>>>>>>>
>>>>>>> xap.ScriptRun(NightMode)
>>>>>>>
>>>>>>> should be
>>>>>>>
>>>>>>> x=xap.ScriptRun("NightMode")
>>>>>>>
>>>>>>> as it is a function and returns data, also as
you are passing a string
>>>>>>> of text to the function that string needs to
be in quotes. Actually
>>>>>>> since you really dont want the data that it
would return you could just:
>>>>>>>
>>>>>>> xap.ScriptRun "NightMode"
>>>>>>>
>>>>>>> hth
>>>>>>>
>>>>>>> James
>>>>>>>
>>>>>>> max wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> I've have being trying to write Raw script
to check the alarm status of
>>>>>>>> Comfort and run an autoscript dependent on
the outcome. The autoscript
>>>>>>>> is working fine, but Scipt Debug gives the
following error:
>>>>>>>>
>>>>>>>> Script error : *AlarmStateChecking* :
01/11/2006 21:11:46
>>>>>>>> Line : 11
>>>>>>>> Error Text :
>>>>>>>>
AlarmState=xap.GetText(mi4.homeseer.server.93:comfortplugin.modedesc)
>>>>>>>> Error Description :Expected ')'
>>>>>>>>
>>>>>>>> Here is my raw script:
>>>>>>>>
>>>>>>>> Sub Main()
>>>>>>>> '
>>>>>>>> ' gets alarm state, runs NightMode script
if security is off
>>>>>>>> '
>>>>>>>> '
>>>>>>>>
AlarmState=xap.GetText("mi4.homeseer.server.93:comfortplugin.modedesc")
>>>>>>>> '
>>>>>>>> if AlarmState = "Mode: security off,
user 1" then
>>>>>>>> '
>>>>>>>> xap.ScriptRun(NightMode)
>>>>>>>> else
>>>>>>>> end if
>>>>>>>> '
>>>>>>>> End Sub
>>>>>>>>
>>>>>>>> My scripting experience is next to none,
but I just can't see where I'm
>>>>>>>> going wrong with this one.
>>>>>>>>
>>>>>>>> Max
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>




xAP_Automation Main Index | xAP_Automation Thread Index | xAP_Automation Home | Archives Home

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.