When you create a new command, you can choose from two different ways. The first is the creation of an xml file deployed in the FREEDOMOTIC_ROOT/data/cmd folder. The second option is to use the EventEditor plugin.
The first choice is the best for developers because it guarantees full control of the values. This is because the EventEditor is still under development.
A Freedomotic command is a container of customizable parameters in the
form of parameter = value
.
Standard parameters to guarantee the correct routing of the message to the actuator that can execute the task are name, description and receiver.
Command xml files are messages used to instruct the actuators on which action must be performed.
Some commands are created at runtime, the same way the sensors create events. However, commands can be created at “design” time by the developer to have this command embedded in the plugin (in PLUGIN_NAME/data/cmd folder) or they can be created at runtime by the user/configurator (and it will be saved in FREEDOMOTIC_ROOT/data/cmd folder).
@owner.object.behavior.brightness
contains the starting value not the target value. This is
received only by driver plugins.These are the properties received by a driver plugin which implements communication with X10 hardware.
These are the command properties received by a text to speech plugin
when the automation IF a light turns on THEN say ElectricDevice current state
is performed.
Field| Description ——-|——————- name | A short string that identifies the effect of the command execution (eg: turn on light in the kitchen) description | An extended description of the effect of the command execution. Write it in the form “IF an event occurs THEN the system ... yourDescription receiver | The Channel on which the target plugin is listening to delay | Not Yet Implemented, let this parameter to 0 timeout | waiting time for the plugin reply, if 0 it’s set to 10 seconds by default properties | A set of properties in form “key = value”.
These commands can be used to change objects state in IF this THEN that
automations like
IF it's dark THEN turn on garden lights
.
Here some example of commands sent to the Freedomotic internal BehaviorsManager. It accepts a predefined set of properties keys but any plugin can have its own set.
<command>
<name>Turn on livingroom light</name>
<receiver>app.events.sensors.behavior.request.objects</receiver>
<description>turns on an object called livingroom light</description>
<editable>true</editable>
<properties>
<properties>
<property name="behavior" value="powered"/>
<property name="value" value="true"/>
<property name="object.name" value="Livingroom light"/>
</properties>
<tuples/>
</properties>
</command>
<command>
<name>switch power for all lights</name>
<receiver>app.events.sensors.behavior.request.objects</receiver>
<description>switch power for all lights</description>
<editable>true</editable>
<properties>
<properties>
<property name="behavior" value="powered"/>
<property name="value" value="opposite"/>
<property name="object.class" value="EnvObject.ElectricDevice.Light"/>
</properties>
<tuples/>
</properties>
</command>
<command>
<name>switch power for all kitchen lights</name>
<receiver>app.events.sensors.behavior.request.objects</receiver>
<description>switch power for all kitchen lights</description>
<editable>true</editable>
<properties>
<properties>
<property name="behavior" value="powered"/>
<property name="value" value="opposite"/>
<property name="object.class" value="EnvObject.ElectricDevice.Light"/>
<property name="object.zone" value="Kitchen"/>
</properties>
<tuples/>
</properties>
</command>
<command>
<name>Increase lights brightness</name>
<receiver>app.events.sensors.behavior.request.objects</receiver>
<description>increases light brightness</description>
<editable>true</editable>
<properties>
<properties>
<property name="behavior" value="brightness"/>
<property name="value" value="next"/>
<property name="object.class" value="EnvObject.ElectricDevice.Light"/>
</properties>
<tuples/>
</properties>
</command>
<command>
<name>Decrease lights brightness</name>
<receiver>app.events.sensors.behavior.request.objects</receiver>
<description>decreases lights brightness</description>
<editable>true</editable>
<properties>
<properties>
<property name="behavior" value="brightness"/>
<property name="value" value="previous"/>
<property name="object.class" value="EnvObject.ElectricDevice.Light"/>
</properties>
<tuples/>
</properties>
</command>
Commands parameters can be scripted using javascript syntax like this:
<command>
<name>Say the current temperature converted in Fahrenheit</name>
<receiver>app.actuators.media.tts.in</receiver>
<delay>0</delay>
<timeout>2000</timeout>
<description>say the current temperature using TTS engine</description>
<hardwareLevel>false</hardwareLevel>
<persistence>true</persistence>
<executed>false</executed>
<properties>
<properties>
<property name="say" value="= say="The current temperature in @event.zone is " + Math.round(((@event.temperature+40)*1.8)-40) + " Fahrenheit degrees. In Celsius is @event.temperature degrees"/>
</properties>
<tuples/>
</properties>
</command>
This command uses text to speech to say the current temperature in a zone and makes a on the fly conversion from degrees Celsius to degrees Fahrenheit. The property key is a variable in the scripting context that can be evaluated.
To make a value scriptable it must start with an “=” just like Excel. Values that do not start with “=” are the same as the previous Freedomotic versions.
Here other example of scripting:
//sum the first 10 integer and store the value in myVar property
<property name="myVar" value="= myVar=0; for (i=0; i<10; i++) myVar+=i;"/>
//if one is one myVar property is one
<property name="myVar" value="= if (1==1) myVar=1; else myVar="AREYOUJOKING?";"/>
negate the powered value of a thing if true becomes false, if false become true
<property name="myVar" value="= myVar=!@event.object.powered;"/>