HomeDeviceSpi – com.prosyst.mbs.services.hdm.spi.HomeDeviceSpi, abstracts one physical device. It provides common information related to a device – UID, vendor, version, status, etc. It also provides DeviceClassObjectSpi that represents the functionalities of the physical device. The implementation of HomeDeviceSpi allows to implement com.prosyst.mbs.services.fim.FunctionalItem. In this section we will describe how this is done using the DA API.
An example of the main functionality of HomeDeviceSpi is demonstrated in the DA Adapter demo – com.prosyst.mbs.da.adapter-demo.
For a full list of demos, and how to use them, please refer to How to Work with Demos.
Providing Device Information
HomeDeviceSpi provides a device UID, name and tags to Device Access. If the device has other specific properties of the used protocol, they can be returned in the getAttributes(). The DA Adapter demo demonstrates extending a FunctionalItem.
When the implementation of HomeDeviceSpi is extending a FunctionalItem there's no need to use the following methods:
In case you do want to use those methods, you need to keep in mind some specific rules. They are described in the section at the end of this page - "Implementing methods which are related to protocol adapter implementation to the HDM API".
The following methods are not invoked at all by Device Access and the adapter does not need to implement them:
• FunctionalItem.setName(String)
• FunctionalItem.setTags(Set)
• FunctionalItem.getObjectClass()
• FunctionalItem.getItemMetadata()
For this reason the protocol adapter would throw an exception for each.
Support for Property Update
When the HomeDeviceSpi is related to the DA API implementation, i.e. it implements FunctionalItem, then this method – updateProperties(Map<String, String> properties) does not need to be implemented. When the implementation of the protocol adapter is related to the HDM API this method can be applied. The implementation shown in the the DA Adapter demo is related to the DA API so it does not support update of properties.
Indicate Device Status
The implementation of the getStatus() method returns one of the supported device statuses:
There are specific errors – HomeDeviceErrors that correspond to the device statuses. Every error has a code and a message. The error codes can be:
The home device error is mandatory for the following device statuses:
It is optional for the following device statuses:
If the status HomeDevice.STATUS_ONLINE has an error code, it would be HomeDeviceError.DEVICE_COMMUNICATION_ERROR.
The following device statuses do not have an error:
Default Polling Interval
Device Access provides polling mechanism functionality. The implementation of the protocol adapter allows supporting the polling mechanism – refer to Property Cache page. The adapter used in the DA Adapter demo does not support polling mechanism.
Supported Device Class Objects
The HomeDeviceSpi supports one or many device class objects. The getDeviceClassObjects() returns the supported device class objects. In the DA Adapter demo, when HomeDeviceSpi is initialized, the supported device class objects are created and get returned by getDeviceClassObjects().
Implement Methods Related to Protocol Adapter Implementation for the HDM API (deprecated)
Some methods of the HomeDeviceSpi are related to the implementation of the protocol adapter for the HDM API implementation. These methods are: getType(), getVendor(), getVersion() and updateProperties(Map<String, String). If your implementation of the HomeDeviceSpi extends a FunctionalItem and you want to apply those methods, you need to keep in mind the rules described below.
If your implementation does not extend a FunctionalItem refer to the deprecated Home Device Manager Developer Guide.
HomeDeviceSpi type is added to the device tags.
HomeDeviceSpi vendor and HomeDeviceSpi version are added as device attribute values and the device attribute keys are – Device.HARDWARE_VENDOR and Device.HARDWARE_VERSION respectively.
HomeDeviceSpi additional properties are added to the device attributes and to the device item attributes – these device items that have DeviceClassObjectSpi related to this HomeDeviceSpi.
This method should be implemented only for this protocol adapters that are related to the HDM API.