Difference between revisions of "Floorplan Script Functions"

From XAP Automation
Jump to: navigation, search
(GetLastChange(xAPName) As Date)
(SendxAP(xBody, xClass, Optional xTarget))
Line 62: Line 62:
 
=Sending=
 
=Sending=
 
====SendxAP(xBody, xClass, Optional xTarget)====
 
====SendxAP(xBody, xClass, Optional xTarget)====
 +
This sends an xAP message to a non BSC device.
 +
<pre>
 +
body="display.text" & chr(10) & "{" & "line1=Lounge temp " & y & chr(10)& "duration=10" & chr(10)& "}" & chr(10)
 +
SendxAP body, "message.display",  "mmwave.lcdswitch.lounge1"
 +
</pre>
 +
 
====SendxPL(xBody, xClass, Optional xTarget)====
 
====SendxPL(xBody, xClass, Optional xTarget)====
 
This sends an xPL message. Here a TTS message to all devices.
 
This sends an xPL message. Here a TTS message to all devices.

Revision as of 19:14, 2 March 2007

Available functions:

Contents


Globals

GetGlobal(Globalname)

SetGlobal(Globalname, NewData) As Boolean

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(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(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(xAPName) As String

GetLevelMax(xAPName) As String

GetDisplayText(xAPName) As String

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(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(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(xAPName) As String

GetDisplayValue(xAPName) As String

SetDisplayValue(xAPName, NewValue) As Boolean

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(xAPName, NewValue) As Boolean

Sending

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(xBody, xClass, Optional xTarget)

This sends an xPL message. Here a TTS message to all devices.

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

SendBSCState(xTarget, NewState)

SendBSCLevel(xTarget, NewLevel)

SendBSCText(xTarget, NewText)

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(TimerName As String) As Boolean

Example

DeleteTimer ("UFHPumpRun")

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

DawnTime() As String

DuskTime() As String

IsDay() As Boolean

IsNight() As Boolean

Database

ExecuteSQL(SQL)

RunSQL(SQL) As Variant

Rooms

GetRoomMode(RoomName)

GetRoomState(RoomName)

GetRoomOccupancy(RoomName) As Boolean

SetRoomMode(RoomName, RoomMode As Integer) As Boolean

SetRoomOccupancy(RoomName) As Boolean

Custom Page specific

GetLastEvents() As Variant

TitleStripGreen(xTitle, xURL)

====TitleStripBlue(xTitle, xURL)====</pre>