The Resource Importer provides an automatic way to import configuration files into the Home Automation Manager.
Overview
The Resource Importer simplifies the importing process of HAM resources and their maintenance. When manually importing the configuration files, they can be eventually lost. The Resource Importer tracks bundles with specific HAM resources and imports them automatically.
Using the Resource Importer
There are some specifics that should be taken into consideration.
How it Works?
Once the bundle is started the resourseListener interface is scanning for types that correspond to the needed criteria, meaning that they need to be placed in the corresponding folders: OSGI-INF/ham/conditions; OSGI-INF/ham/commands and OSGI-INF/ham/rules. When a tracked bundle is updated, it is scanned again for any version changes. A callback is thrown after the resources are located and all registered services under the ResourceListener interface are notified when given specific resources are loaded. Particular applications can be notified when specific resources are loaded by registering a service under the same resourseListener interface. Due to the Resource Importer execution mechanism no manifest headers are needed. Since the instances are generally being kept, they could be removed by uninstalling the bundle that includes them.
The Resource Importer can be easily understood and tested by using the provided Resource Importer Demo.
The available predefined conditions can be found in the Predefined Conditions page.
Configurations Structure
The XML files of the imported configurations must follow the same XML structure. When an already tracked bundle with HAM resources is updated by the user, it is scanned again for any new changes. Every condition, command and rule instance should have its version config property for updating purposes, since this is the only way for prioritization of configurations. A different version will overwrite the resources and dismiss the "older" one.
An example covering the rule configuration scheme is shown bellow:
<config name="Rule">
<config name="Rule_ResourceImporterDEMO">
<property key="version" value="1.0.0" type="string"/>
<property key="application" value="test" type="string"/>
<property key="name" value="Logging" type="string"/>
<property key="active" value="true" type="boolean"/>
<property key="condition_type" value="AbsoluteTimerCondition" type="string"/>
<property key="condition_id" value="AbsoluteTimer_ResourceImporterDEMO" type="string"/>
<property key="command_type" value="LogCommand" type="string"/>
<property key="command_id" value="LogCommand_ResourceImporterDEMO" type="string"/>
</config>
</config>
Constraints
Instances containing errors will cause the whole import process to fail and no provided instances will be imported.
The Resource Importer will not work if: