Skip to content
Tinwor edited this page Dec 2, 2014 · 2 revisions

Mapping API - Data model DAL

	DAL Device -> DEVICE_CATEGORY: Smart plug
					SERVICE_UID: ZigBee:Plogg
					SERVICE_DRIVER: ZigBee
					SERVICE_NAME: Plogg
					SERVICE_STATUS: STATUS_ONLINE
					
		Function Switch -> 	SERVICE_UID = ZigBee:Plogg:switch
							SERVICE_DEVICE_UID  = ZigBee:Plogg
						   
						----------------> Operation: turnStatus
												OperationMetadata
													META_INFO_DESCRIPTION: operation to turn on and of the device

		Function SmartPlug -> SERVICE_UID = ZigBee:Plogg:smartplug
							SERVICE_TYPE = energy consumption meter
							SERVICE_DEVICE_UID  = ZigBee:Plogg
							
						----------------> Property: state
												PropertyMetadata
													DESCRIPTION: state of the smart plug
													PROPERTY_ACCESS:  PropertyAccess.READABLE & PropertyAccess.WRITABLE
													
						----------------> Property: sensorData
												PropertyMetadata
													DESCRIPTION: consumption measured by the smart plug
													PROPERTY_ACCESS:  PropertyAccess.READABLE | PROPERTY_ACCESS_EVENTABLE
													UNITS: kW

XMPP Extensions (XEP0326)

List of all available devices

<iq type='get'
   from='[email protected]/client'
   to='[email protected]'
   id='13'>
  <getAllNodes xmlns='urn:xmpp:iot:concentrators' sourceId='MeteringTopology' xml:lang='en'/>

return deviceSRefs = context.getServiceReferences( Device.class.getName(), '(' + Device.SERVICE_STATUS + '=' + Device.STATUS_ONLINE + ')');


Read of device sensor data

 <iq type='get'
   from='[email protected]/amr'
   to='[email protected]'
   id='S0005'>
  <req xmlns='urn:xmpp:iot:sensordata' seqnr='5' momentary='true'>
     <node nodeId='ZigBee:Plogg:smartplug'/>
  </req>
<iq type='result'
   from='[email protected]'
   to='[email protected]/amr'
   id='S0005'>
  <accepted xmlns='urn:xmpp:iot:sensordata' seqnr='5'/>
	deviceSRefs = context.getServiceReferences(
		SmartPlug.class.getName(),
		'(' + Function.SERVICE_UID + '= ZigBee:Plogg:smartplug)');
	
	return deviceSRefs[0].getSensorData();


Read a device control property

<getForm xmlns='urn:xmpp:iot:control' xml:lang='en' />

	deviceSRefs = context.getServiceReferences(
		SmartPlug.class.getName(),
		'(' + Function.SERVICE_UID + '= ZigBee:Plogg:smartplug)');
	
	return deviceSRefs[0].getState();

<x type='form' xmlns='jabber:x:data' <title></title> If the plug is turned on or off. ON


Set a device control property (response to a form)

OFF

	deviceSRefs = context.getServiceReferences(
		SmartPlug.class.getName(),
		'(' + Function.SERVICE_UID + '= ZigBee:Plogg:sensor)');
	
	deviceSRefs[0].setState(ON);


Set a device control property (directly set)

<message from='[email protected]/amr'
        to='[email protected]'>
  <set xmlns='urn:xmpp:iot:control'>
     <node nodeId='ZigBee:Plogg:smartplug'/>
     <string name='State' value='ON'/>
  </set>
	deviceSRefs = context.getServiceReferences(
		SmartPlug.class.getName(),
		'(' + Function.SERVICE_UID + '= ZigBee:Plogg:sensor)');
	
	deviceSRefs[0].setState(ON);

Execution of device command

<iq type='set'
   from='[email protected]/client'
   to='[email protected]'
   id='44'>
  <executeNodeCommand xmlns='urn:xmpp:iot:concentrators' sourceId='MeteringGroups' nodeId='ZigBee:Plogg:smartplug' command='turnStatus' xml:lang='en'/>
	deviceSRefs = context.getServiceReferences(
		Switch.class.getName(),
		'(' + Function.SERVICE_UID + '= ZigBee:Plogg:switch)');
	
	deviceSRefs[0].turnStatus();


Send event

FunctionEvent {
	dal.function.UID=ZigBee:Plogg:smartplug
	dal.function.property.name=”consumption”
	dal.function.property.value=ACMEFuntionData("100")
}

EventAdmin.send(FunctionEvent);

Currently supported via XEP-0060 One collection node for every device one leaf node for every node data

Clone this wiki locally