Difference between revisions of "Floorplan Script Functions"

From XAP Automation
Jump to: navigation, search
m (SendxPL(xBody, xClass, Optional xTarget))
Line 4: Line 4:
  
 
=Globals=
 
=Globals=
====GetGlobal(Globalname)====
+
==GetGlobal==
====SetGlobal(Globalname, NewData) As Boolean====
+
'''GetGlobal(Globalname)'''
====GetDBGlobal(Globalname) As Variant====
+
==SetGlobal==
 +
'''SetGlobal(Globalname, NewData) As Boolean'''
 +
==GetDBGlobal==
 +
'''GetDBGlobal(Globalname) As Variant'''
 
GetDBGlobal returns a Variant, as you can have an array of DBGlobals. Most users are frequently only going to use a single item (the zero'th) as in this case.<pre>
 
GetDBGlobal returns a Variant, as you can have an array of DBGlobals. Most users are frequently only going to use a single item (the zero'th) as in this case.<pre>
 
if GetDBGlobal("HouseEmpty")(0) then
 
if GetDBGlobal("HouseEmpty")(0) then
Line 13: Line 16:
 
</pre>
 
</pre>
 
The DBGlobal being used here is storing Boolean.
 
The DBGlobal being used here is storing Boolean.
 
+
==SetDBGlobal==
====SetDBGlobal(Globalname, NewData, Overwrite As Boolean) As Boolean====
+
'''SetDBGlobal(Globalname, NewData, Overwrite As Boolean) As Boolean'''
 
The following will set the HouseEmpty global variable to TRUE, overwriting an existing value.<pre>
 
The following will set the HouseEmpty global variable to TRUE, overwriting an existing value.<pre>
 
SetDBGlobal "HouseEmpty", TRUE, TRUE
 
SetDBGlobal "HouseEmpty", TRUE, TRUE
Line 20: Line 23:
  
 
=Devices=
 
=Devices=
====GetState(xAPName) As String====
+
==GetState==
 +
'''GetState(xAPName) As String'''
 
This returns the state of the device which can be referenced by the xAP full source string.<pre>
 
This returns the state of the device which can be referenced by the xAP full source string.<pre>
 
y=GetState("phaedrus.netiom.node2-1:heating.outstatus.go")
 
y=GetState("phaedrus.netiom.node2-1:heating.outstatus.go")
Line 27: Line 31:
 
y=GetState("Heating GO")
 
y=GetState("Heating GO")
 
</pre>
 
</pre>
 
+
==GetLevel==
====GetLevel(xAPName) As String====
+
'''GetLevel(xAPName) As String'''
====GetLevelMax(xAPName) As String====
+
==GetLevelMax==
====GetDisplayText(xAPName) As String====
+
'''GetLevelMax(xAPName) As String'''
====GetText(xAPName) As String====
+
==GetDisplayText==
 +
'''GetDisplayText(xAPName) As String'''
 +
==GetText==
 +
'''GetText(xAPName) As String'''
 
This gets the string from the Text name/value pair for the BSC device.
 
This gets the string from the Text name/value pair for the BSC device.
 
<pre>
 
<pre>
 
Temp=GetText("mmwave.tom10.g8kmh_hapc2:lounge")
 
Temp=GetText("mmwave.tom10.g8kmh_hapc2:lounge")
 
</pre>
 
</pre>
 
+
==GetLastUpdate==
====GetLastUpdate(xAPName) As Date====
+
'''GetLastUpdate(xAPName) As Date'''
 
This returns the date and time xAP Floorplan updated the device from the received xAP message.<pre>
 
This returns the date and time xAP Floorplan updated the device from the received xAP message.<pre>
 
x=GetLastUpdate("mmwave.lcdswitch.bedroom1:07")
 
x=GetLastUpdate("mmwave.lcdswitch.bedroom1:07")
 
</pre>
 
</pre>
 
+
==GetLastChange==
====GetLastChange(xAPName) As Date====
+
'''GetLastChange(xAPName) As Date'''
 
This returns the date and time xAP Floorplan updated the device from the received xAP BSC Event message.<pre>
 
This returns the date and time xAP Floorplan updated the device from the received xAP BSC Event message.<pre>
 
x=GetLastChange("mmwave.lcdswitch.bedroom1:07")
 
x=GetLastChange("mmwave.lcdswitch.bedroom1:07")
 
</pre>
 
</pre>
 
+
==GetValue==
====GetValue(xAPName) As String====
+
'''GetValue(xAPName) As String'''
====GetDisplayValue(xAPName) As String====
+
==GetDisplayValue==
====SetDisplayValue(xAPName, NewValue) As Boolean====
+
'''GetDisplayValue(xAPName) As String'''
====SetDisplayText(xAPName, NewValue) As Boolean====
+
==SetDisplayValue==
 +
'''SetDisplayValue(xAPName, NewValue) As Boolean'''
 +
==SetDisplayText==
 +
'''SetDisplayText(xAPName, NewValue) As Boolean'''
 
Use this to change the displayed text on the map. For example to change the colour of the display which in this example is a Temperature
 
Use this to change the displayed text on the map. For example to change the colour of the display which in this example is a Temperature
 
<pre>
 
<pre>
Line 57: Line 67:
 
</pre>
 
</pre>
 
Note the use of ScriptExtras which holds the xAPName of the device calling the script. This allows a single script or function to be used by many similar devices.
 
Note the use of ScriptExtras which holds the xAPName of the device calling the script. This allows a single script or function to be used by many similar devices.
 
+
==SetDisplayTooltip==
====SetDisplayTooltip(xAPName, NewValue) As Boolean====
+
'''SetDisplayTooltip(xAPName, NewValue) As Boolean'''
  
 
=Sending=
 
=Sending=
====SendxAP(xBody, xClass, Optional xTarget)====
+
==SendxAP==
 +
'''SendxAP(xBody, xClass, Optional xTarget)'''
 
This sends an xAP message to a non BSC device.
 
This sends an xAP message to a non BSC device.
 
<pre>
 
<pre>
Line 67: Line 78:
 
SendxAP body, "message.display",  "mmwave.lcdswitch.lounge1"
 
SendxAP body, "message.display",  "mmwave.lcdswitch.lounge1"
 
</pre>
 
</pre>
 
+
==SendxPL==
====SendxPL(xBody, xClass, Optional xTarget)====
+
'''SendxPL(xBody, xClass, Optional xTarget)'''
 
This sends an xPL message. Here a TTS message to all devices. Note that xPL messages should not have braces '{' and '}'.
 
This sends an xPL message. Here a TTS message to all devices. Note that xPL messages should not have braces '{' and '}'.
 
<pre>
 
<pre>
 
SendXPL "speech="&CurrMsg,"tts.basic", "*"
 
SendXPL "speech="&CurrMsg,"tts.basic", "*"
 
</pre>
 
</pre>
 
+
==SendBSCState==
====SendBSCState(xTarget, NewState)====
+
'''SendBSCState(xTarget, NewState)'''
====SendBSCLevel(xTarget, NewLevel)====
+
==SendBSCLevel==
====SendBSCText(xTarget, NewText)====
+
'''SendBSCLevel(xTarget, NewLevel)'''
====SendBSC(xTarget, NewState, NewLevel, NewText)====
+
==SendBSCText==
 +
'''SendBSCText(xTarget, NewText)'''
 +
==SendBSC==
 +
'''SendBSC(xTarget, NewState, NewLevel, NewText)'''
  
 
=Timers=
 
=Timers=
====AddTimer(TimerName As String, TimerTime As Date, Script As String, Optional RawCode) As Boolean====
+
====
 +
'''AddTimer(TimerName As String, TimerTime As Date, Script As String, Optional RawCode) As Boolean'''
 
Here a timer is set to run 5 minutes from now and execute a script.
 
Here a timer is set to run 5 minutes from now and execute a script.
 
<pre>
 
<pre>
Line 86: Line 101:
 
</pre>
 
</pre>
 
You can check the timer is set by going to the 'Timers' tab.
 
You can check the timer is set by going to the 'Timers' tab.
 
+
==DeleteTimer==
====DeleteTimer(TimerName As String) As Boolean====
+
'''DeleteTimer(TimerName As String) As Boolean'''
 
Example
 
Example
 
<pre>
 
<pre>
 
DeleteTimer ("UFHPumpRun")
 
DeleteTimer ("UFHPumpRun")
 
</pre>
 
</pre>
 +
==EditTimer==
 +
'''EditTimer(TimerName As String, TimerTime As Date, Script As String, Optional RawCode) As Boolean'''
 +
==CheckTimer==
 +
'''CheckTimer(TimerName As String) As Variant'''
 +
==ScriptRun==
 +
'''ScriptRun(ScriptName)'''
 +
==LogDebug==
 +
'''LogDebug(Message)'''
 +
==GetFromRaw==
 +
'''GetFromRaw(RawMessage, ItemToFind)'''
  
====EditTimer(TimerName As String, TimerTime As Date, Script As String, Optional RawCode) As Boolean====
 
====CheckTimer(TimerName As String) As Variant====
 
 
====ScriptRun(ScriptName)====
 
====LogDebug(Message)====
 
====GetFromRaw(RawMessage, ItemToFind)====
 
  
 
=Time=
 
=Time=
====DawnTime() As String====
+
==DawnTime==
====DuskTime() As String====
+
'''DawnTime() As String'''
====IsDay() As Boolean====
+
==DuskTime==
====IsNight() As Boolean====
+
'''DuskTime() As String'''
 +
==IsDay==
 +
'''IsDay() As Boolean'''
 +
==IsNight==
 +
'''IsNight() As Boolean'''
  
 
=Database=
 
=Database=
====ExecuteSQL(SQL)====
+
==ExecuteSQL==
====RunSQL(SQL) As Variant====
+
'''ExecuteSQL(SQL)'''
 +
==RunSQL==
 +
'''RunSQL(SQL) As Variant'''
  
  
 
=Rooms=
 
=Rooms=
====GetRoomMode(RoomName)====
+
==GetRoomMode==
====GetRoomState(RoomName)====
+
'''GetRoomMode(RoomName)'''
====GetRoomOccupancy(RoomName) As Boolean====
+
==GetRoomState==
====SetRoomMode(RoomName, RoomMode As Integer) As Boolean====
+
'''GetRoomState(RoomName)'''
====SetRoomOccupancy(RoomName) As Boolean====
+
==GetRoomOccupancy==
 +
'''GetRoomOccupancy(RoomName) As Boolean'''
 +
==SetRoomMode==
 +
'''SetRoomMode(RoomName, RoomMode As Integer) As Boolean'''
 +
==SetRoomOccupancy==
 +
'''SetRoomOccupancy(RoomName) As Boolean'''
  
 
=Custom Page specific=
 
=Custom Page specific=
====GetLastEvents() As Variant====
+
==GetLastEvents==
====TitleStripGreen(xTitle, xURL)====
+
'''GetLastEvents() As Variant'''
====TitleStripBlue(xTitle, xURL)====</pre>
+
==TitleStripGreen==
 +
'''TitleStripGreen(xTitle, xURL)'''
 +
==TitleStripBlue==
 +
'''TitleStripBlue(xTitle, xURL)'''

Revision as of 11:07, 3 March 2007

Available functions:


Globals

GetGlobal

GetGlobal(Globalname)

SetGlobal

SetGlobal(Globalname, NewData) As Boolean

GetDBGlobal

GetDBGlobal(Globalname) As Variant

GetDBGlobal returns a Variant, as you can have an array of DBGlobals. Most users are frequently only going to use a single item (the zero'th) as in this case.
if GetDBGlobal("HouseEmpty")(0) then
....some code
end if

The DBGlobal being used here is storing Boolean.

SetDBGlobal

SetDBGlobal(Globalname, NewData, Overwrite As Boolean) As Boolean

The following will set the HouseEmpty global variable to TRUE, overwriting an existing value.
	SetDBGlobal "HouseEmpty", TRUE, TRUE

Devices

GetState

GetState(xAPName) As String

This returns the state of the device which can be referenced by the xAP full source string.
y=GetState("phaedrus.netiom.node2-1:heating.outstatus.go")
Or by the xAP Floorplan friendly name
y=GetState("Heating GO")

GetLevel

GetLevel(xAPName) As String

GetLevelMax

GetLevelMax(xAPName) As String

GetDisplayText

GetDisplayText(xAPName) As String

GetText

GetText(xAPName) As String This gets the string from the Text name/value pair for the BSC device.

Temp=GetText("mmwave.tom10.g8kmh_hapc2:lounge")

GetLastUpdate

GetLastUpdate(xAPName) As Date

This returns the date and time xAP Floorplan updated the device from the received xAP message.
x=GetLastUpdate("mmwave.lcdswitch.bedroom1:07")

GetLastChange

GetLastChange(xAPName) As Date

This returns the date and time xAP Floorplan updated the device from the received xAP BSC Event message.
x=GetLastChange("mmwave.lcdswitch.bedroom1:07")

GetValue

GetValue(xAPName) As String

GetDisplayValue

GetDisplayValue(xAPName) As String

SetDisplayValue

SetDisplayValue(xAPName, NewValue) As Boolean

SetDisplayText

SetDisplayText(xAPName, NewValue) As Boolean Use this to change the displayed text on the map. For example to change the colour of the display which in this example is a Temperature

DisplayString="<fontcolor=""red"">"&Temp&"</font>"
SetDisplayText ScriptExtras, DisplayString

Note the use of ScriptExtras which holds the xAPName of the device calling the script. This allows a single script or function to be used by many similar devices.

SetDisplayTooltip

SetDisplayTooltip(xAPName, NewValue) As Boolean

Sending

SendxAP

SendxAP(xBody, xClass, Optional xTarget) This sends an xAP message to a non BSC device.

body="display.text" & chr(10) & "{" & "line1=Lounge temp " & y & chr(10)& "duration=10" & chr(10)& "}" & chr(10) 
SendxAP body, "message.display",  "mmwave.lcdswitch.lounge1"

SendxPL

SendxPL(xBody, xClass, Optional xTarget) This sends an xPL message. Here a TTS message to all devices. Note that xPL messages should not have braces '{' and '}'.

	SendXPL "speech="&CurrMsg,"tts.basic", "*"

SendBSCState

SendBSCState(xTarget, NewState)

SendBSCLevel

SendBSCLevel(xTarget, NewLevel)

SendBSCText

SendBSCText(xTarget, NewText)

SendBSC

SendBSC(xTarget, NewState, NewLevel, NewText)

Timers

==

AddTimer(TimerName As String, TimerTime As Date, Script As String, Optional RawCode) As Boolean Here a timer is set to run 5 minutes from now and execute a script.

AddTimer "UFHPumpRun", DateAdd("n", 5, Now()), "UFHPumpRunOff"

You can check the timer is set by going to the 'Timers' tab.

DeleteTimer

DeleteTimer(TimerName As String) As Boolean Example

DeleteTimer ("UFHPumpRun")

EditTimer

EditTimer(TimerName As String, TimerTime As Date, Script As String, Optional RawCode) As Boolean

CheckTimer

CheckTimer(TimerName As String) As Variant

ScriptRun

ScriptRun(ScriptName)

LogDebug

LogDebug(Message)

GetFromRaw

GetFromRaw(RawMessage, ItemToFind)


Time

DawnTime

DawnTime() As String

DuskTime

DuskTime() As String

IsDay

IsDay() As Boolean

IsNight

IsNight() As Boolean

Database

ExecuteSQL

ExecuteSQL(SQL)

RunSQL

RunSQL(SQL) As Variant


Rooms

GetRoomMode

GetRoomMode(RoomName)

GetRoomState

GetRoomState(RoomName)

GetRoomOccupancy

GetRoomOccupancy(RoomName) As Boolean

SetRoomMode

SetRoomMode(RoomName, RoomMode As Integer) As Boolean

SetRoomOccupancy

SetRoomOccupancy(RoomName) As Boolean

Custom Page specific

GetLastEvents

GetLastEvents() As Variant

TitleStripGreen

TitleStripGreen(xTitle, xURL)

TitleStripBlue

TitleStripBlue(xTitle, xURL)