myServer Advanced Scripting

Welcome to the myServer Advanced Scripting documentation

myServer represents Allonis's media management and home automation software components. myServer supports two way external integration that can be leveraged by advanced users and software developers.

Some of the documentation below has been gathered from user Forum contributions.


If you are using the legacy plugin you would use the MLScript|Script... command syntax. When you switch to using the V4 scripting you change MLScript| to Scripting| and everything else remains the same.

The scripts are stored in the database. However if you can make calls to external script files. Just pass the full path to the script file as the first parameter. e.g. Scripting|scripts\myscript.vbs. Then you can maintain all your scripts outside of myServer.

myServer adds the functionality of the legacy MLScript plugin directly into myServer. You will see a new "Server Scripting" button on the main toolbar. The new command verb is called "Scripting" and it works just like the old plugin did.

Scripting|NameOfScript~NameOfSubroutine(Optional)~Param1(Optional)~Param2(Optional) etc.

The Script Library window has an import feature that will allow you to import your old scripts from the legacy plugins database file.

The one new option in this is that the "NameOfScript" can reference an external .vbs file. It will always try to resolve the name with the internal database first. If the "NameOfScript" does not exist it checks to see if it is really a file name.

Display a text file in the infinite scroller

Example: You have a text file written from my DSC alarm events (window open, door open, etc.) and would like to display the file in a scrollable text box. 

You could write a MLScript that would read in the contents of the text file and then store it in a server variable. Once the data lives in the server variable, just reference that variable in the text scroller object. Once that is working you could set a timer or other automation rule to periodically run the script to update the variable. Use the generic list infinite scroller type to display.

Basic example of scripting:


where Testing is the name of the script as defined in the scripting library module
where foo is the parameter that is passed to the sub.

Example of VBScript open a text file and then write out the server variables and close the file:

Set objFSO=CreateObject("Scripting.FileSystemObject")

dim np
np = myServer.GetVariable("weather_forecast_7_dayf") 
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write (np)

 VBScript How to (click to Read)

myScript example:

How to have set-up a script on myServer which reads the contents of a file into an myServer variable (or, preferable, a series of variables).

Option Explicit
Const ForReading = 1
Dim objFSO, objReadFile, filecontents
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objReadFile = objFSO.OpenTextFile("C:\TextToRead.txt", ForReading, False)

Do Until objReadFile.AtEndOfStream
  filecontents = objReadFile.ReadLine
  parts = Split(filecontents, " ")
  MLServer.SetVariable cstr("light_" & parts(0)), cstr(parts(1))
Set objFSO = Nothing
Set objReadFile = Nothing


Since this is a sub with parameters it should be something like


where Testing is the name of the script as defined in the scripting library module
where foo is the parameter that is passed to the sub.


To start a script:

Scripting|NameOfScript~NameOfSubroutine(Optional)~Param1(Optional)~Param2(Optional) etc.

1) NameOfSubroutine(Optional) is only optional if you not trying to fire a sub or a func.
2) Param1(Optional)~Param2(Optional) etc. didn't work in the beginning (may still not work) but I use this as a workaround:
Param1@Param2@Param3, etc.

An example of a simple (and totally useless) script:


Sub DoThis(params)
'PARAMS handler:
oReceivedArray = Split(params(0), "@")
oUnit = CInt(oReceivedArray(0))
oCommand = LCase(oReceivedArray(1))
oSetVar = "something_command"
If oUnit > 0 then
SetVar oSetVar, oCommand
SetVar oSetVar, GetVar(oSetVar)
End If
End Sub

Sub SetVar(oVar,oResult)
myServer.SetVariable oVar, oResult
End Sub

Function GetVar(oVar)
GetVar = myServer.GetVariable(oVar)
End Function

You would not need to use the my "PARAMS handler" if myserver has been fixed and is handling the Scripting command as stated (and it could be but I have never checked). If so, then each param sent would be extracted as:
oUnit = params(0)
oCommand = params(1)