If you plan to develop a plugin for Freedomotic you will need to access the framework data structures.
These types of data are used with building automation and the Freedomotic architecture:
Environment data are accessible by the static reference. It returns the Environment’s instance which gives you access to all of the Environment’s properties
Freedomotic.environment.getPojo();
Freedomotic.environment.getZones()
Zones are logical (virtual) portions of the environment. To retrieve the list of physical environment rooms (rooms are also considered Zones) use:
Freedomotic.environment.getRooms()
The ‘things’ (lights, doors, couches, ...) in the environment can be retrived in different ways:
EnvObjectPersistence.getObject(String name)
EnvObjectPersistence.getObject(String protocol, String address)
EnvObjectPersistence.getObjectByProtocol(String protocol)
EnvObjectPersistence.getObjects()
Use the following import to access this method:
import com.freedomotic.objects.EnvObjectPersistence;
AddonManager.getLoadedPlugins()
Returns an ArrayList of Plugin type.
AddonManager.getPluginByName(String name)
Remember to import com.freedomotic.plugins.AddonManager;
You can access configuration file of a plugin in this way:
int myVar = configuration.getIntProperty("PROPERTY-NAME", 1);
The second parameter in getIntProperty is the default value to use if the PROPERTY-NAME cannot be found or cannot be converted to the proper type (int, double, string, ...)
other methods are:
boolean myVar = configuration.getBooleanProperty("PROPERTY-NAME", true);
double myVar = configuration.getDoubleProperty("PROPERTY-NAME", 1.5f);
String myVar = configuration.getStringProperty("PROPERTY-NAME", "some text");
read tuple properties from config file:
boolean myVar = tuple.getBooleanProperty(tupleIndex, "PROPERTY-NAME", true);
double myVar = tuple.getDoubleProperty(tupleIndex, "PROPERTY-NAME", 1.5f);
String myVar = tuple.getStringProperty(tupleIndex, "PROPERTY-NAME", "some text");
The onMessage method has a Command c parameter. Is possible to access the received parameters this way:
String saveItInAVariable = c.getProperty("COMMAND-PARAM-NAME");
This is done through a REST connection which serves the data. More info can be found at https://github.com/freedomotic/freedomotic/wiki/Freedomotic-APIs.