-
Notifications
You must be signed in to change notification settings - Fork 36
How to create a new driver in Jemma
In order to create a new driver in Jemma, you have to follow theese steps:
- Into the bundle jemma.osgi.ah.zigbee.appliance, you have to create a new class that extends the abstract class ZclAppliance; In this class you have to:
a. Set the EndPoint Type
b. Add all the Input/output cluster that the devive suppor tinto the endpoint created.
public class ZclWindowCoveringAppliance extends ZclAppliance{
private ZclEndPoint endPoint = null;
private static final Logger LOG = LoggerFactory.getLogger( ZclWindowCoveringAppliance.class );
public ZclWindowCoveringAppliance(String pid, Dictionary config)
throws ApplianceException {
super(pid, config);
endPoint = this.zclAddEndPoint(IEndPointTypes.ZIGBEE_WINDOW_COVERING);
// Server Clusters
endPoint.addServiceCluster(new ZclWindowCoveringServer());
endPoint.addServiceCluster(new ZclBasicServer());
endPoint.addServiceCluster(new ZclIdentifyServer());
endPoint.addServiceCluster(new ZclScenesServer());
endPoint.addServiceCluster(new ZclGroupsServer());
}
protected void attached() {
LOG.debug("ZclWindowCoveringAppliance attached");
}
protected void detached() {
LOG.debug("ZclWindowCoveringAppliance detached");
}
}
- Into the bundle jemma.osgi.ah.zigbee.appliances , you have to create a new class factory that extends the abstract class DriverApplianceFactory and implements the Interface Driver; in this class you have to set:
a. The filter condition in order to select this driver during the installation pocess—Attention, you have to ceate a UNIQUE condition, if exists more driver that match with the same Device, you will have some problems at runtime. b. Instantiate a new DriverImplementaton(Created into the step 1) c. Set the APPLIANCE_FRIENDLY_NAME used during the configuration process
public class ZclWindowCoveringApplianceFactory extends DriverApplianceFactory implements Driver {
public static final String APPLIANCE_TYPE = "org.energy_home.jemma.ah.zigbee.windowcovering";
public static final String APPLIANCE_FRIENDLY_NAME = "Window Covering";
public static final String DEVICE_TYPE = "ZigBee";
public static final IApplianceDescriptor APPLIANCE_DESCRIPTOR = new ApplianceDescriptor(APPLIANCE_TYPE, null,
APPLIANCE_FRIENDLY_NAME);
public IApplianceDescriptor getDescriptor() {
return APPLIANCE_DESCRIPTOR;
}
public Appliance getInstance(String pid, Dictionary config) throws ApplianceException {
return new ZclWindowCoveringAppliance(pid, config);
}
public String deviceMatchFilterString() {
return "(&(DEVICE_CATEGORY=ZigBee)(zigbee.device.device.id=514))";
}
}
Attention: A match filter is based on the DeviceId condition, if you have same devices with same deviceid but they are from differents manufacturer and they have different configurations with the supported cluster; then you have create two driverApplianceFactory with two matchFiltercondition, adding the Manufacturerid into the condition.
Theese are the conditions that is possible to uses for the match filter:
- zigbee.device.ep.id
- zigbee.device.profile.id
- zigbee.device.device.id
- zigbee.device.eps
- zigbee.device.eps.number
- zigbee.device.manufacturer.id