myServer 6 is a full featured automation system. There are several core capabilities that provide flexible handling of data and events. Click on the name to go to the section that gives detail for that functionality.
Variables: myServer can track, create, update an unlimited number of variables to define a status, a text value, a numeric value, etc. Used by both the user interface and for processing logic. Variables can include tracking "Who is the User", "What room is to be controlled", "What is the current temperature", etc.
Macros: A predefined sequence of actions that can be triggered by a number of means, including a simple click of a UI button.
Commands: Numerous commands exist to help with doing Math functions, conditionals, For / Next Loops etc.
Automation Events: When a variable changes, an associated automation event can be associated to it which can then fire to execute the desired action.
Scheduled Events: Actions can be triggered based on day or time of day.
Conditional: IF (this occurs), THEN (execute this action), ELSE (execute a different action)
myServer Command Syntax and Usage
Understanding the myServer Command syntax is one of the most important aspects of using myServer. This section is designed to help you obtain a better understanding of the myServer command line syntax and how to effectively use it.
Much of the documentation below is out of date and needs improvement (hopefully soon!)
myServer commands can be used from within HTML web pages, myServer, and Drivers. The myServer Command is also how myServer 6 sends and receives commands to other applications.
System Command examples can be found by going to the Dashboard Home Page and click on the "Available Server Commands" dropdown.
This section will guide you through a series of examples on proper usage of myServer commands. They will gradually build in complexity, by the end of this section you should have a good understanding of the myServer command syntax and how it’s used within the suite of myServer products.
To make building commands even easier - myServer each Driver has a "Command Builder". To use it, click on Driver of interest, and you will see the Command Builder choices in myServer Dashboard. Select from the Available Command dropdown you want to interact with. The Target Device Number or Alias dropdown should appear. Select the appropriate one. There may be other command choices to consider. As you select these parameters, you will see the Macro building in the box below. Once you have the command built, you can click Execute Command to try it. It is helpful to have the Event Log open so you can see exactly what your command performed for debugging.
Once the command is built, you can immediately test it, copy to clipboard (to be pasted into a scene as example). Easy way to build powerful capability into your system! For more detailed understanding, read on...
Because there are so many possible variables that can be used (myWeather has over 7,000!) it's easier to go into the Dashboard Management / Server Variables button and filter the list to find the group of variables that are currently defined on your system. Device driver variables all start with "<<familyname>>_<<deviceid>>_" to make it more uniform to find what is applicable. Many variables are created when myServer launches and loads the driver or app. Keep in mind that some variables only get created when an event occurs and the driver creates a new variable on that event. You can use the Name Search field by typing your text of interest, and then click the Filter button to have "starts with" and "contains" to aid your search.
You can manually create a new Variable by clicking the "Create New Variable" button on top left. Just type a name (it is good to maintain a variable name structure to keep things organized) and an initial value. Click "Update" to create the variable. If an Automation Rule was used for this variable, you will see that field have a checkbox.
Variables can be thought of in the myServer "family" structure:
Climate Family:
Energy Family:
Lighting Family:
Security Family:
FamilyName|Command~parameter~parameter
Pipe "|": Always follows plugin name or Macro; Tilde "~": Seperates commands and parameters
Macro|myPluginName|Command~parameter~parameter!myPluginName|Command~parameter
Exclamation "!": Seperates plugin commands when used with Macro. If there are nested macros, each Nest must use unique additional ! end of line charectors. Inside most next uses ! . Next outside next uses !!. Next further out nest uses !!! (etc).
On Startup and Shutdown
ALL server variables are automatically saved and restored every time the server is cleanly shutdown (saved) and started (restored). This is automatic and cannot be disabled.
If there are specific things you would like to perform on system startup and/or system shutdown then you can put them in macros called system.startup and system.shutdown.
If these macros exist then they automatically get executed during the startup or shutdown sequences.
If / Then Else
Normal structured programming languages typically structure If statements like
If Some Condition is true Then
Do something
Else
Do something else
Way back in the day when Adobe flash ruled the world and myServer was at version 1 we came up with a server command that would test for a specified condition and act accordingly.
The rule we had to follow was that the Conditional statement had to allow for embedded macros and we needed to make sure the command line would be properly parsed and not mess with any of the embedded server commands delimiters.
The syntax we came up with at the time was to inject unique identifiers in the statement that would never appear in a normal server command.
It was decided that the Conditional statement would use pairs of punctuation characters for its delimiters. ##, $$, %%, etc.
This generated the base command structure.
Conditional|<Type Of Condition>##<condition variable>##<condition value>>##Then Commands##Else Commands
Fast forward 22 years and the conditional command has changed very little. With the exception of Conditional| changing to If| everything else remains the same.
So in myServer we have
If|<Type Of Condition>##<condition variable>##<condition value>>##Then Commands##Else Commands
Here's an example
If {{current_hour}} = 12 then
SetVariable|lunchtime~Is here
Else
SetVariable|lunchtime~Still waiting
in myServer it becomes
If|IsEqual##{{current_hour}}##12##SetVariable|lunchtime~Is here##SetVariable|lunchtime~Still waiting
Note the ELSE clause is optional.
If|IsEqual##{{current_hour}}##12##SetVariable|lunchtime~Is here
is just as valid.
If you need to embed an If statement in a If statement then that requires using different sets of delimiters
If|{{current_hour}} = 5 then
If|{{current_day}} = Friday then
SetVariable|happy_hour~engaged
We'll use ## for the outer and $$ for the inner pair.
If|IsEQ##{{current_hour}}##5##
If|IsEQ$${{current_day}}$$Friday$$SetVariable|happy_hour~engaged
Just remember the rule that you must use a different pair of delimiters for every nested if statement.
Then and Else clauses can contain macros.
A simple way to do AND tests is by combining the variables into the condition variable
If|{{current_hour}} = 5 and {{current_day}} = Friday then
SetVariable|happy_hour~engaged
Lock The Doors
Turn Off The Lights
If|IsEQ##{{current_hour}}{{current_day}}##5Friday##
Macro|
SetVariable|happy_hour~engaged!
Security|1~Mode~Away!
Lighting|5~Off
If|IsEQ##{{current_hour}}{{current_day}}##5Friday##Macro|SetVariable|happy_hour~engaged!Security|1~Mode~Away!Lighting|5~Off
Here are the types of conditions currently supported in myServer 6.
If|isRunning##<name of program>>##Then
Is the specified program currently running.
If|isEqual##<server variable>##<value>##Then
If|isEQ##<sever variable>##<value>>##Then
Is the value of the server variable equal to the test value?
If|isLTE##<sever variable>##<value>>##Then
Is the value of the server variable less than or equal to the test value?
Is|isLT##<sever variable>##<value>>##Then
Is the value of the server variable less than the test value?
If|isGTE##<sever variable>##<value>>##Then
Is the value of the server variable greater than or equal to the test value?
If|isGT##<sever variable>##<value>>##Then
Is the value of the server variable greater than the test value?
If|isNE##<sever variable>##<value>>##Then
Is the value of the server variable is not equal to the test value?
If|FileExists##<path to file##Then
Does the file exist
If|StartsWith##<sever variable>##<value>>##Then
Does the value of the server variable start with the test value?
If|Contains##<sever variable>##<value>>##Then
Does the value of the server variable contain the test value?
If|EndsWith##<sever variable>##<value>>##Then
Does the value of the server variable end with the test value?
If|isTrue##<sever variable>##Then
If|isOn##<sever variable>##Then
Does the value of the server variable test true?
True means the value is equal to 1 or True or On
If|isFalse##<sever variable>##Then
If|isOff##<sever variable>##Then
Does the value of the server variable test false?
False means the value is equal to 0 or False or Off
If|isPingable##<ip address>##Then
Can the IP Address be pinged
If|isNotPingable##<ip address>##Then
Is the IP Address NOT pingable
If|isReachable##<url>##Then
Can the URL be opened?
If|isNotReachable##<url>##Then
Can the URL not be opened?
If / Then Example:
if a=3 then gggg else hhh
Is written:
if|isequal##a##3##gggg##hhh
(If|IsEqual##arg1##arg2##Command to execute if true##Command to execute if false)
If / Then valid delimiters (for nesting) $$ ## @@ %% &&
Example of triggering overlays dependent on variable values, and launching the main webpage but only if it hasn't already been launched:
macro|SetVariable|surfgate_tab_control~1!SetVariable|surfgate_ballast_control~0!SetVariable|surfgate_surf_control~1!if|isNE##{{activescene_{{clientname}}}}##surf-home##webcmd|{{clientname}}~loadscene|surf-home
For the inline myServer If statement there is an easy test for AND where you can append the variables in the test.
For instance
if ((variable_x = on) AND (variable_y = off)) then
do something interesting
The myServer version can be
If|isEQ##{{variable_x}}{{variable_y}}##onoff##do something interesting
For Next Loop:
FOR|LOOP##start##end##do these commands
Example:
FOR|LOOP##1##10##Macro|pause|.5!
Math|Subtract~surfgate_port_position~{{surfgate_port_position}}~1!
Example of Nested If statements with multiple delimeters:
If|IsNe##{{surfgatesurfside}}##Retracted##If|IsNe&&{{surfgateport_position}}&&0&&Macro|
// Extends Port side tab!
Lighting|6~on!
// Extends Starboard side tab!
Lighting|7~on!
// Resets the position for gauge readout - used until actual sensor values are available or position is tracked!
SetVariable|surfgateportposition~40!
SetVariable|surfgatestarboardposition~40!
//!
Surfgate.Retract2!
//!
Lighting|6~off!
Lighting|7~off!
// Resets the position for gauge readout!
SetVariable|surfgatestarboardposition~0!
SetVariable|surfgateportposition~0!
// Resets the Tab status variable!
SetVariable|surfgate_surfside~Retracted&&##
myServer Command Line Special Characters
myServer uses several special characters within its command line syntax. The following table defines each of these symbols and provides an example of their usage.
myServer Command Line Symbol – Quick Reference Symbol Name Definition ! Exclamation An exclamation is used to separate commands in a macro.
Example:
Macro|SetVariable| <>~MLCallerID| <>!SetVariable| <>~MLCallerID| <>
Note the exclamation symbol used before the second SetVariable to separate the two SetVariable commands in the macro. | Pipe The pipe symbol is used to separate a plug-in name from the actual command.
Example:
MLCallerID Legacy:
MLCallerID|SendCID:Name~Number
Plug-in Command Arguments In this example the Pipe is used to separate the MLCallerID plug-in from the SendCID command.
. Period A period is used to separate the myServerCmd prefix from the actual plug-in name.
Example:
MLCallerID|SendCID:Name~Number
Plug-in Anytime a command it entered, it must precede ~ Tilde A tilde is used to separate arguments within a command.
Example:
MLCallerID|SendCID:Name~Number
Argument #1 Argument #2 In this example the tilde is used to separate the Name and Number argument when sending CallerID information. {{ }} Double Brackets Double brackets are used to place hold variable names or parameter names. To see a listing of available variables, click on View in Window under the Variables section in myServer.
Example:
To display a variable within a Button Label use the following syntax: {{Variable name}}
XMLobby is legacy:
In this example we are pulling a dynamic variable from the XMLobby plug-in. Many of the myServer plug-ins have predefined dynamic variable that can be displayed in myServer user interfaces (templates). To view a list of available variables for each plug-in, simply select the plug-in within myServer and click on the Help option. <<>> Double Arrows Double surrounding arrows are used to signify variables local to the application/client instance.
Example:
SetVariable| <>~MLCallerID| <> Double Pound
The double pound symbols are only used in conditionals to separate the argument from the actions to be performed.
myServer Command Examples In this section we will be adding a button to a myServer Scene that will communicate with myServer to perform several tasks.
The actual myServerCMD we will use in this example is:
Macro|MLFileOpen|notepad.exe!MLPause|3!MLWindowFunctions|Notepad~SENDKEYS~Hello
We will breakdown the entire command line at the end of this example to provide you with a better understanding of how it works.
The following assumptions are being made for this example:
- myServer is running on the same machine as the client
- myServer is started
- The client is connected to myServer
-
9. Click the drop-down arrow and select Macro from the list. IMPORTANT: When you select a command from the drop-down list, you will be presented with a command syntax example as well. In this case, the example is: Macro|MLFileOpen|notepad.exe!MLPause|3!MLWindowFunctions|Notepad~SENDKEYS~Hello As mentioned in the Glossary of Terms, a macro is defined as a saved sequence of commands or keyboard strokes that can be stored and then recalled with a single command or keyboard stroke. When you wish to embed a macro within a macro, since myServer parses the Macro by breaking everything at the ! delimiters, it does not know how to distinguish the inner Macro from the outer. The solution is to put the inner macro in its own command map and call that instead
10. Place your mouse pointer in the window and click once next to the Macro| text.
11. Finish the command by typing the following text: MLFileOpen|notepad.exe!MLPause|3!MLWindowFunctions|Notepad~SENDKEYS~Hello Note: Ensure there are no spaces in the command line syntax above.
12. Select OK to close the myServerCMD Panel. The myServerCMD field should now be populated with the command we just entered (Figure 1.7). Figure 1.7 myServerCMD
13. Select OK to close out the Button Properties Panel.
14. Select Launch in the Main Menu to enter Launch mode.
15. Click the button we created on the myDesigner stage. You should see the Windows Notepad load and after a three second delay, the text HELLO appears.
-
In the table below, we will breakdown each piece of myServerCMD used in this example.
myServer Command (Input)
Macro|MLFileOpen|notepad.exe!MLPause|3!MLWindowFunctions|Notepad~SENDKEYS~Hello
Command Line Syntax Breakdown
-
Inner macros use ! outer use !! and !!! and !!!! as delimiters for nesting of macros
- Example:
-
Macro|
If|IsEqual##<P1>##A##Macro|surfgate.surf.port!WebCmd|all~toast|info~Surfer~Port Button <P1> pressed~2500##!!
If|IsEqual##<P1>##B##Macro|surfgate.surf.starboard!WebCmd|all~toast|info~Surfer~Starboard Button <P1> pressed~2500##!!
If|IsEqual##<P1>##C##Macro|WebCmd|all~toast|info~Surfer~C Button <P1> pressed~2500##!!
If|IsEqual##<P1>##D##Macro|WebCmd|all~toast|info~Surfer~D Button <P1> pressed~2500## -
myServerCMD The myServerCMD is similar to a RUN statement. It is how all myServer commands are initiated and it is required for any action on the myServer command line. The period is used to separate the myServerCMD initiator from the actual plug-in name.
. The period symbol is used to separate the myServerCMD operator from the plug-in.
Macro The Macro plug-in allows you to build a sequence of commands on the command line.
| The pipe symbol is used to separate the plug-in from its command which happens to be MLFileOpen in this example.
MLFileOpen The MLFileOpen command allows myServer to launch any file on a Windows PC.
| The pipe symbol is used again to separate the MLFileOpen plug-in from its command, which in this case happens to be an executable file. notepad.exe The Windows application we intend to launch.
! An exclamation symbol is then used to separate commands within a macro, in this example it separates the MLFileOpen command from the MLPause command.
MLPause The MLPause plug-in allows you to pause a macro for a user defined number of seconds. In this example, the macro pauses for 3 seconds.
| The pipe symbol is used again to separate the MLPause plug-in from its command.
3 The number of seconds used to pause the macro.
! An exclamation symbol is used again to separate the commands within the macro.
MLWindowFunctions The MLWindowFunctions plug-in allows you to control various aspects of the Windows environment. For a detailed description of what features you can control, see the end of this guide for a detailed listing of the plug-ins included with myServer.
| The pipe symbol is used again to separate the MLWindowFunctions plug-in from its command.
-
Notepad Notepad identifies the application used to perform the MLWindowFunctions on.
~ A tilde is used to separate the arguments within the command. SENDKEYS The SENDKEYS argument sets focus on the Notepad window and emulates keystrokes.
~ Again a tilde is used to separate the arguments within the command.
HELLO The text that is typed in Notepad.
This concludes example #1.
MLCallerID is Legacy:
-
Example #2:
-
Description In this example we will walk through setting up and using the MLCallerID plug-in. The MLCallerID plug-in allows you to use a modem to display caller ID information and photos on MainLobby clients. The MLCallerID plug-in allows users to capture and display a callers name, phone number, time of call and display a picture of caller (if properly configured).
The myServerCMD we will use in this example will send CallerID Name and Number information to one or many MainLobby clients.
The following assumptions are being made for this example:
- myServer is running on the same machine as myServer client
- myServer is started
- The myServer client is connected to myServer (Figure 1.2)
- A modem is installed in the computer running myServer and its CallerID capable.
IMPORTANT: This plug-In requires CallerID service from your local telecom service provider. Contact your service provider for additional details.
You must also have at least on caller ID name/number setup in the MLCallerID plug-in.
myServer Command (Input)
MLCallerID|SendCID:Name~Number
Command Line Syntax Breakdown
myServerCMD The myServerCMD is similar to a RUN statement. It is how all myServer commands are initiated and it is required for any action on the myServer command line. The period is used to separate the myServerCMD initiator from the actual plug-in name. myServer processes all server variable names as lowercase, regardless how they are typed.
. The period symbol is used to separate the myServerCMD operator from the plug-in. MLCallerID
-
SetVariable Creates a variable in myServer. SetVariable|VariableName~VariableValue
All variables created get sent to all clients and get sent to the myServer event processor that can then act on those changed variable values.
SetVariableFast Creates a variable in myServer. SetVariableFast|VariableName~VariableValue
All variables created get sent to all clients and DO NOT get sent to the myServer event processor. So, any variables created or updated using SetVariableFast cannot be used as a trigger for automation events. But, the variable gets created much faster for scene updates (as example).
- myServer Math command:
Math|Divide~Output Variable Name~First Number~Second Number
or
Math|Divide~result~{{blml2hs_blmhs zonnepaneel_value}}~10
The server variable {{result}} will contain the computed value. Change {{result}} to any variable name that makes sense. -
Math|divide~surfgatetraveltimer~{{value}}~2
-
URL Encoding URL Encoding is used by myServer client and Server when sending Server variables to clients. This resolves issue with adding in multi-line text fields. Requires MainLobby version 3.0.6 or higher. Displays client version number in clients window.
Time and Dates It is suggested that all sunrise / sunset event rules use the currentdate server variable as the reference variable. Set the update frequency to 60 seconds in MLDateTime. (If you need more frequent time updates then set the update frequency to the value you want)
Health and Status Report Access the report via the built in web server at http://servername:6246/ServerStatus.
Commonly used command examples:
Change Scene example: You can change scenes from any client or web browser, by sending:
MLCmd|ChangeScene~PROGEAR~musiclobby.mls
You can also choose ALL for the client to tell all connected clients to open the scene
MLCmd|ChangeScene~[Client/All]~[mls]
MLCmd|Msg~[Client/All]~[Title]~[Text]
MLCmd examples (used to invoke actions on the MainLobby Client, instead of on the server):
Syntax:
- myServer replaced by webcmd|{{clientname}}~back
- Overlays are still used in myServer webcmd|{{clientname}}~show|overlay-name or hide|
-
Examples:
MLCmd|MLCommand~ALL~MLExit MLCmd|MLCommand~server1~MLBackScene
MLCmd|MLCommand~server1~MLminimize (note this is case sensitive!)
MLCmd|MLCommand~HTPC1~MLminimize Note “MLmaximize” is not supported.
MLCmd|ChangeScene~XPPro~Login1.mls (must be run on the myServer that the client is pointed to)
MLCmd|MLCommand~clientname~Monitor.TurnOff
MLCmd|MLCommand~clientname~Monitor.TurnOn
To close client connections to myServer:
Macro|MLCmd|MLCommand~Downstairs~myServerConnection|connect~10.1.2.210~5004!CloseConnection
myServerConnection|connect~localhost~5004 ie: myServerConnection|connect~192.168.0.2~5004
PC Shutdown techniques
Commands to shutdown myServer PC: MLSShutdown MLSRestart
Technique to shutdown any PC on the LAN: Create a button within MainLobby that shuts down your computer, simply create a batch file and assign it to the button. The following provides proper syntax and optional command switches. Shutdown allows you to shut down or restart a local or remote computer. Used without parameters, shutdown will logoff the current user.
Syntax shutdown [{-l|-s|-r|-a}] [-f] [-m [\\ComputerName]] [-t xx] [-c "message"] [-d[u][p]:xx:yy]
Parameters
-l Logs off the current user, this is also the defualt. -m ComputerName takes precedence.
-s Shuts down the local computer.
-r Reboots after shutdown.
-a Aborts shutdown. Ignores other parameters, except -l and ComputerName. You can only use -a during the time-out period.
-f Forces running applications to close.
-m [\\ComputerName] Specifies the computer that you want to shut down.
-t xx Sets the timer for system shutdown in xx seconds. The default is 20 seconds.
-c "message" Specifies a message to be displayed in the Message area of the System Shutdown window. You can use a maximum of 127 characters. You must enclose the message in quotation marks.
-d [u][p]:xx:yy Lists the reason code for the shutdown. The following table lists the different values. Value Description u Indicates a user code. p Indicates a planned shutdown code. xx Specifies the major reason code (0-255). yy Specifies the minor reason code (0-65536).
/? Displays help at the command prompt. Remarks If you indicate a major and minor reason code, you must first define these reason codes on each computer for which you plan to use the particular reason. If the reason codes are not defined on the target computer, Event Viewer cannot log the correct reason text. Examples To shut down \\MyServer in 60 seconds, force running applications to close, restart the computer after shutdown, indicate a user code, indicate that the shutdown is planned, log major reason code 125, and log minor reason code 1, type:
C:\windows\system32\shutdown -r -f -m \\MyServer -t 60 -d up:125:1
C:\windows\system32\shutdown -s -f -t 00
-
Example Commands
myCmd is Legacy: Can be called from an myServerCMD of another computer:
-
MLCmd|MLCommand~clientname~Application|sendToBack
Application|Move~ <>~ <>
Application|Shift~ <>~ <>
Application|hide (Hides MainLobby but still is running in Task Manager)
Application|show Application|maximize
Application|restore Application|exit
Application|onTop~true (Keeps MainLobby on Top of other Applications)
Application|onTop~false Application|sendToBack System|shutdown myServerConnection|connect~ <>~ <> • ie: myServerConnection|connect~localhost~5004 • ie: myServerConnection|connect~192.168.0.2~5004
MLDVDLobby|DLnextMovie • From myServerCMD line: • MLCmd|MLCommand~htpc2~MLDVDLobby|DLnextMovie
MLFileOpen|nameoffile.exe
MLFileOpen|{{Myfilename}}
MLCmd|MLCommand~htpc2~MLFileOpen|{{Myfilename}}
setProperty|BackgroundFX~visible~true setProperty|BackgroundFX~visible~false setProperty|BackgroundFX~visible~toggle
setProperty|RemoteFX~visible~true setProperty|RemoteFX~visible~false
setProperty|RemoteFX~visible~toggle setProperty|OverlayFX~visible~true
setProperty|OverlayFX~visible~false setProperty|OverlayFX~visible~toggle MLHome (Loads user specified Startup Scene from Startup Options Panel)
MLCmd|MLCommand~htpc2~Web.NavigateURL~ http://www.allonis.com
MLCmd|MLCommand~htpc2~loadOverlayScene~ 0014_nav_games.mls
Macro|MLSliders|Set~1~{{value}}!SetVariable|slider1~{{value}} (used when using a graphical slider. Sets a Variable at the target value, waiting for the device the then update the new value. Reduces slider bounce)
Advanced Users
Command Maps
Command Maps or Command Mapping allows a user to leverage large collections of myServer commands using simple "English Language" notation.
Example:
With a command map, instead of typing MLVolume|WaveVolumeUp in the MLServCmd field, you could simply type Volume.Wave.Up and achieve the same results.
This is easily accomplished because myServer already includes a command map called Volume.Wave.Up.
RunCmdMap| = Command Map Command
By reviewing the Command Mapping option, you can see a description of what the command does and the commands actual myServer syntax. This allows you to look at how the original syntax was constructed.
Macros become much more manageable as users migrate to the Macro Builder system in command mapping.
The Import File becomes a central repository of "Known Good Commands" that help users in debugging because they could be assured that it's not a syntax problem.
The command maps are stored in the command.mdb Access tables in the MLS root dir. To add a new command map, simply right click on the Commands tree where you want to insert the new command, and click New. Then, populate the appropriate new command name, description and myServerCMD Run fields. Click Save and then Close.
You can also Import command maps by right clicking on Macros (in the navigation tree) and selecting Import. Browse to the <>.cmd file and click the Open button. You can also Export command maps by right clicking on the command you want to export (in the navigation tree) and clicking Export. Name the file appropriately. You can then share your command maps with another MainLobby3 Server user. Note, that you need to delete a command map before importing the same name command map or you will have double entries.
Command map trick
Using an MLConditional command to test for and run the application as follows:
Macro|MLConditional|IsRunning##Yahoo! Music Jukebox Plus####MLFileOpen|C:\Program Files\Yahoo!\Yahoo! Music Jukebox\YahooMusicEngine.exe##
The problem is that since the running application name includes a '!', myServer thinks that a new command begins after 'IsRunning##Yahoo' and does not execute correctly.
Is there any way to make myServer ignore the '!' and execute correctly? Answer: Do that as a Macro (which then looks for the !) and do that portion in a command map. Then call that command map from a Macro.
myServerCmds can also be invoked externally:
http:// <>:6246/command? <>
Example of use with IFTTT service:
Setup your router to ONLY forward port "X" to 6246 both TCP/UDP on whatever IP myServer runs. Make port X something odd like 8567. This will be the example going forward.
Make sure you have a static IP or use noip or something similar.
Start your trigger in IFTTT, and for the "that" use the Maker channel and:
Make a web request: http://mrsmith.noip.com:8567/command? command in ml, macro, etc>>
Method = GET
Content Type = Text/plain
Body (leave blank)
And Viola - now you can use IFTTT. I've been playing with Echo, but there's limited echo "ifs" - but it works.Playing audio sounds:
You can play any audio file from the server including all the TechTalker files.
The command syntax is
PlaySound|<<path to any audio file>>
PlaySound|sounds\test.mp3
You can also chain Playsound commands together in a Macro like
Macro|PlaySound|sounds\At the Tone The Time Is.mp3!PlaySound|sounds\{{currenthr}}.mp3!PlaySound|sounds\{{currentampm}}.mp3
The myAVAgent also supports a similar PlaySound command. The only difference is that you must pass the full UNC path to the audio file to make sure the Agent can correctly access it.
AV|<<id>>~PlaySound|<<UNC path to any audio file>>
AV|2~PlaySound|\\mlserver\v4mlserver\sounds\test.mp3System Timers:
"System Timers" window and native "Timers" server command to the UI. The Timer functions are a direct replacement for the legacy MLTimer plugin. See the attached.
There is no practical limit to the number of system timers that can get defined (the system may get a little sluggish after 4000 or so).
Each system timer runs asynchronously in its own thread.
The same command set is supported as the legacy MLTimer.
Timers|SetTimer~Timer#~Style~Interval~Units~Macro~Enable
Timers|Enable~Timer#
Timers|Disable~Timer#
Timers|Toggle~Timer#
Timers|Delete~Timer#Task Scheduling:
Task Scheduling functionality built into the server. This new Task Scheduler replaces the legacy MLScheduler V3 plugin. Using the new scheduler you will be able to set up an unlimited number of tasks that can either be executed on a timed schedule or on demand. You'll see the new Task Scheduler icon on the server toolbar in the Configuration Aides sections.
Six types of tasks can be defined. Hourly, Daily, Monthly, On Startup, On Demand and On Shutdown.
Hourly tasks will run each hour on the minute value specified in the Time Of Day field as long as the task is active for the current Month and Day.
Daily tasks will run each day on the hour and minute value specified in the Time Of Day field as long as the task is active for the current Month and Day.
Monthly tasks will run each month on the Day of Month specified and on the hour on the minute value specified in the Time Of Day field as long as the task is active for the current Month.
On Startup tasks will run when the server starts.
On Shutdown tasks will run when the server shuts down.
On Demand tasks will only be executed via command.
You also have the option of defining the task as a System task. A System task will never be exposed to a user via the web service.
Finally, you have the option of the sending an email when the task was run. The email address the message gets sent to is the primary notification email address as defined in the Server's Tools Notification section.
myServer Command Tasks - with this command to can Enable/Disable/Run a task.
Tasks|<<Task#>> or <<TaskName>>~Enable,Disable,Toggle,Run
There will also be a collection of Tasks_<<id>>_ server variables that can be used with the commands.
There is a web service that can be used to build a dynamic list of tasks using the InfiniteScroll object. The myDesigner has been updated and you will see the Scheduled Tasks prototype when editing the object.Ping Device:
Command called PingDevice
You'll pass it one parameter and it is the IP Address of the device to ping. e.g. PingDevice|192.168.1.112
It will ping the device and create 3 server variables
Ping_<<ipaddress>>_Online - 1 (online) or 0 (offline)
Ping_<<ipaddress>>_Status - text result of the ping status
Ping_<<ipaddress>>_Time - round trip time of the ping in milliseconds.
Client Commands
In no particular order
SetLaunchProperties: Define new client settings.
SetLaunchProperties|project~serverip~clientname
SetupWifi: Jump to Wifi settings on the SmartRemote
ExitApp: Exit the SmartRemote app.
SendIR: Send an IR string out the SmartRemote emitter
SendIR|<ir command string>>
Restart: Restart the SmartRemote apk
Internal Audio or Video player transport commands
Stop: Stop|<object id> - typically the players unique id
Pause: Pause|<object id>
Play: Play|<object id>
PlayPause: PlayPause|<object id>
Volume: Volume|<object id>~Up, Down or 0..100
Mute: Mute|<object id>~On, Off or Toggle
Navigation Commands
Home: Home - back to the index page
Back: Back - return to the previous page
LoadScene: LoadScene|<page name> e.g. Loadscene|sonos
LoadProject: LoadProject|<project name>
LastProject: LastProject - return to the previous project
Overlay Commands - case sensitive overlay names!
Toggle: Toggle|<overlay name> - show / hide an overlay
Show: Show|<overlay name> - make the overlay visible
Hide: Hide|<overlay name> - make the overlay hidden
RefreshPage: RefreshPage - reload the current page
ShowDimensions: ShowDimensions - pop up a window showing current page height and width
Macro: Run a series of "client" commands using ! delimiter
Macro|cmd1!cmd2!cmdN
Macro|hide|overlay1!hide|overlay2!show|overlay3
SetClientname: SetClientname|<new name> - no spaces! a..z and 0..9
DeleteClientname: Remove a stored clientname and revert to a new random name
Toast: Pop up a Toast message
Toast|type~title~message~time
type = success,warning,error,info,mic,speaker,phone = icon shown
title = title on dialog
message = messsage displayed
time = display time in milliseconds
Toast|warning~Wake Up~Time to make the donuts~5000
Launch: Launch|<URL> - open a new window at the specified url
Printpage: Printpage - print the current page
RemoteButton: Simulate a remote hard button press
RemoteButton|ok
RemoteButton|back
RemoteButton|power
RemoteButton|menu
RemoteButton|more
RemoteButton|home
RemoteButton|mute
RemoteButton|volumeup
RemoteButton|volumedown
RemoteButton|up
RemoteButton|down
RemoteButton|left
RemoteButton|right
RemoteButton|pageup
RemoteButton|pagedown
RemoteButton|rewind
RemoteButton|playpause
RemoteButton|fastforward
RemoteButton|stop
RemoteButton|f1
RemoteButton|f2
RemoteButton|f3
Commands in the macro editor will be preserved in the original way the creator typed them in. So whitespace is maintained on Save.
The whitespace will only be removed when the server parses the command during processing.
A new macro will simply be a list of server commands. There is a required "END OF COMMAND" delimiter. It is shown as a semicolon below but it could be a new line character instead.
Macro|first|command~p1!second|command~p1~p2~p3!nth|command
Will become
first|command~p1;
second|command~p1~p2~p3;
nth|command;
IF conditional logic examples: Similar to Visual Basic syntax. A bit more readable. ( ) below are for readability not really needed.
Keywords are CAPITALIZED.
IF (something = something else) THEN // supported: =, <, >, <=, >=, != (!= is "not equal")
some command;
some other command;
and another command;
...
ELSE
some else command;
some other else command;
and another else command;
...
ENDIF
IF (something = something) AND (today != tomorrow) THEN //Note that each expression is encased in ( )
some command;
some other command;
and another command;
...
ENDIF
IF (something >= something) OR (today != tomorrow) THEN
some command;
some other command;
and another command;
...
ENDIF
IF (something >= something) AND (today != tomorrow) OR (last week != this week) THEN
some command;
some other command;
and another command;
ENDIF
IF (something = something else) THEN
some command;
some other command;
and another command;
ELSEIF (tomorrow > today) THEN
some else command;
some other else command;
and another else command;
ELSE
some else command;
some other else command;
and another else command;
ENDIF
FOR LOOPS will look like
FOR 1 to 12 STEP 1 // STEP is OPTIONAL defaults to 1
command;
command;
command;
ENDFOR
A WHILE STATEMENT
WHILE today != tomorrow
command;
command;
command;
ENDSWHILE
Example:
IF (<P1> = A) THEN
surfgate.surf.port; //Runs this macro that moves the actuators
WebCmd|all~toast|info~Surfer~Port Button <P1> pressed~2500; //Pops up a message of what button was pushed
ENDIF
IF (<P1> = B) THEN
surfgate.surf.starboard; //Runs this macro that moves the actuators
WebCmd|all~toast|info~Surfer~Starboard Button <P1> pressed~2500; //Pops up a message of what button was pushed
ENDIF
Original V5 Macro for same:
If|IsEqual##<P1>##A##Macro|
surfgate.surf.port!
WebCmd|all~toast|info~Surfer~Port Button <P1> pressed~2500##!
!
If|IsEqual##<P1>##B##Macro|
surfgate.surf.starboard!
WebCmd|all~toast|info~Surfer~Starboard Button <P1> pressed~2500##!
SWITCH {{something}} // in Visual Basic it is called SELECT
CASE valueA
Command;
Command;
CASE valueB
Command;
Command;
CASE valueC
Command;
Command;
DEFAULT
Command;
Command;
ENDSWITCH
Example:
Logically
If Anthem = on then
AV|<anthem id>~Volume~<P1>
else if Sonos = on then
AV|<sonosid>~Volume~<P1>
else
AV|<tv id>~Volume~<P1>
To do this in myServer we need to use nested if statements. If statements are nested by using different sets of delimiters at each nesting level. Here we use pairs of ## and %%
If|isEQ##{{av_<anthemid>_power}}##on## <<<< if Anthem is on
AV|<anthemid>~Volume~<P1>## <<<< then Anthem volume
If|isEQ%%{{av_<sonosid>_power>%%on%% <<<< else if Sonos is on
AV|<sonosid>~Volume~<P1>%% <<<< then Sonos volume
AV|<tvid>~Volume~<P1> <<<< else TV volume
If Anthem id = 22, and Sonos id = 33 and TV id is = 44 the command becomes
If|isEQ##{{av_22_power}}##on##AV|22~Volume~<P1>##If|isEQ%%{{av_33_power>%%on%%AV|33~Volume~<P1>%%AV|44~Volume~<P1>
Valid delimiters for nesting ifs are ##, @@, $$, %% and &&
Alternately you could use the Switch command to do things based on the active source. The Switch command acts just like the Switch statement in programming languages
Switch|<reference variable>##
case1##command 1##
case2##command 2##
case3##command 3##
default##default command
Using the above example
Switch|{{activesource_sourcename_{{clientname}}}}##
anthem##AV|22~Volume~<P1>##
sonos##AV|33~Volume~<P1>##
default##AV|44~Volume~<P1>
Legacy commands (not supported)
Formatting of Variables: myServer has a built in function called FormatVariable
Syntax is FormatVariable|Value~Variable~Type~Mask
Where Value = data to be formatted
Variable = name of server variable to hold formatted data
Type = Type of data in Value (must be one of DATE, NUMBER, STRING)
Mask = formatting mask
For example:
FormatVariable|{{Currentdate}}~mydate~date~dddd, mmm d yyyy
Will take the current value of the server variable currentdate and create a new variable called mydate.
If currentdate = 6/2/2006 then mydate = Saturday, Jun 3 2006
Here are some valid masks
DATE "h:m:s" Returns "17:4:23" "hh:mm:ss AMPM" Returns "05:04:23 PM" "dddd, mmm d yyyy" Returns "Wednesday, Jan 27 1993"
NUMBER "##,##0.00" Returns "5,459.40" "###0.00" Returns "334.90. "0.00%" Returns "500.00%"
STRING "LC" Returns "hello" "UC" Returns "HELLO"
All of the valid Format masks can be used.
Command Line Processing
If you want to initiate a command to myServer from a command line: (replace 127.0.0.1 with ipaddress of myServer):
Tell myServer to shutdown myServer and shutdown OS:
curl http://127.0.0.1/api/docommand?command=poweroff
Tell myServer to reboot OS:
curl http://127.0.0.1/api/docommand?command=reboot
To tell myServer to backup database:
curl http://127.0.0.1/api/docommand?command=backupdatabase