Using a Device Handler to Pair your SMART+ Plug to SmartThings

If you are trying to pair your SMART+ plug to SmartThings, and it connects as a “Thing,” you will need to follow a few extra steps in order to get your plug to pair and function properly. Follow the instructions in the PDF below to pair your plug to SmartThings.

Smart Plug.pdf (244.1 KB)

If you are already familiar with creating a device handler, simply create a new device handler From Code, and copy and paste the device handler code below:

metadata {
	definition (name: "SYLVANIA Smart Plug", namespace: "ledvanceDH", author: "Ledvance") {
		capability "Actuator"
		capability "Switch"
		capability "Power Meter"
		capability "Configuration"
		capability "Refresh"
		capability "Sensor"
		capability "Health Check"

		fingerprint profileId: "C05E", inClusters: "1000,0000,0003,0004,0005,0006,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Plug 01", deviceJoinName: "SYLVANIA Smart Plug"
		fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0B05,FC01,FC08", outClusters: "0003,0019", manufacturer: "LEDVACE", model: "PLUG", deviceJoinName: "SYLVANIA Smart Plug"
	}

	// simulator metadata
	simulator {
		// status messages
		status "on": "on/off: 1"
		status "off": "on/off: 0"

		// reply messages
		reply "zcl on-off on": "on/off: 1"
		reply "zcl on-off off": "on/off: 0"
	}

	preferences {
		section {
			image(name: 'educationalcontent', multiple: true, images: [
				"http://cdn.device-gse.smartthings.com/Outlet/US/OutletUS1.jpg",
				"http://cdn.device-gse.smartthings.com/Outlet/US/OutletUS2.jpg"
				])
		}
	}

	// UI tile definitions
	tiles(scale: 2) {
		multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4, canChangeIcon: true){
			tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
				attributeState "on", label: 'On', action: "switch.off", icon: "st.Appliances.appliances17", backgroundColor: "#79b821", nextState: "turningOff"
				attributeState "off", label: 'Off', action: "switch.on", icon: "st.Appliances.appliances17", backgroundColor: "#565C51", nextState: "turningOn"
				attributeState "turningOn", label: 'Turning On', action: "switch.off", icon: "st.Appliances.appliances17", backgroundColor: "#60903A", nextState: "turningOff"
				attributeState "turningOff", label: 'Turning Off', action: "switch.on", icon: "st.Appliances.appliances17", backgroundColor: "#CACACA", nextState: "turningOn"
			}
			tileAttribute ("power", key: "SECONDARY_CONTROL") {
				attributeState "power", label:'${currentValue} W'
			}
		}

		standardTile("refresh", "device.power", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
			state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
		}

		main "switch"
		details(["switch","refresh"])
	}
}

// Parse incoming device messages to generate events
def parse(String description) {
	log.debug "description is $description"

	def finalResult = zigbee.getKnownDescription(description)
	def event = [:]

	//TODO: Remove this after getKnownDescription can parse it automatically
	if (!finalResult && description!="updated")
		finalResult = getPowerDescription(zigbee.parseDescriptionAsMap(description))

	if (finalResult) {
		log.info "final result = $finalResult"
		if (finalResult.type == "update") {
			log.info "$device updates: ${finalResult.value}"
			event = null
		}
		else if (finalResult.type == "power") {
			def powerValue = (finalResult.value as Integer)/10
			event = createEvent(name: "power", value: powerValue, descriptionText: '{{ device.displayName }} power is {{ value }} Watts', translatable: true)
			/*
				Dividing by 10 as the Divisor is 10000 and unit is kW for the device. AttrId: 0302 and 0300. Simplifying to 10
				power level is an integer. The exact power level with correct units needs to be handled in the device type
				to account for the different Divisor value (AttrId: 0302) and POWER Unit (AttrId: 0300). CLUSTER for simple metering is 0702
			*/
		}
		else {
			def descriptionText = finalResult.value == "on" ? '{{ device.displayName }} is On' : '{{ device.displayName }} is Off'
			event = createEvent(name: finalResult.type, value: finalResult.value, descriptionText: descriptionText, translatable: true)
		}
	}
	else {
		def cluster = zigbee.parse(description)

		if (cluster && cluster.clusterId == 0x0006 && cluster.command == 0x07){
			if (cluster.data[0] == 0x00) {
				log.debug "ON/OFF REPORTING CONFIG RESPONSE: " + cluster
				event = createEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
			}
			else {
				log.warn "ON/OFF REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
				event = null
			}
		}
		else {
			log.warn "DID NOT PARSE MESSAGE for description : $description"
			log.debug "${cluster}"
		}
	}
	return event
}

def off() {
	zigbee.off()
}

def on() {
	zigbee.on()
}
/**
 * PING is used by Device-Watch in attempt to reach the Device
 * */
def ping() {
	return zigbee.onOffRefresh()
}

def refresh() {
	zigbee.onOffRefresh() + zigbee.electricMeasurementPowerRefresh()
}

def configure() {
	// Device-Watch allows 2 check-in misses from device + ping (plus 1 min lag time)
	// enrolls with default periodic reporting until newer 5 min interval is confirmed
	sendEvent(name: "checkInterval", value: 2 * 10 * 60 + 1 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])

	// OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity
	refresh() + zigbee.onOffConfig(0, 300) + powerConfig()
}

//power config for devices with min reporting interval as 1 seconds and reporting interval if no activity as 10min (600s)
//min change in value is 01
def powerConfig() {
	[
		"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 0x0B04 {${device.zigbeeId}} {}", "delay 2000",
		"zcl global send-me-a-report 0x0B04 0x050B 0x29 1 600 {05 00}",				//The send-me-a-report is custom to the attribute type for CentraLite
		"delay 200",
		"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000"
	]
}

private getEndpointId() {
	new BigInteger(device.endpointId, 16).toString()
}

//TODO: Remove this after getKnownDescription can parse it automatically
def getPowerDescription(descMap) {
	def powerValue = "undefined"
	if (descMap.cluster == "0B04") {
		if (descMap.attrId == "050b") {
			if(descMap.value!="ffff")
				powerValue = zigbee.convertHexToInt(descMap.value)
		}
	}
	else if (descMap.clusterId == "0B04") {
		if(descMap.command=="07"){
			return	[type: "update", value : "power (0B04) capability configured successfully"]
		}
	}

	if (powerValue != "undefined"){
		return	[type: "power", value : powerValue]
	}
	else {
		return [:]
	}
}

Hi guys.

This device handler doesn’t seem to work for me.

I own some Osram SMART+ “Plugs”, EAN 4058075036239. They registered fine as “ledvanceDH : SYLVANIA Smart Plug”, after I had privately published the above Device Handler. But they seem to be non-functional in the Samsung SmartThings app (V1.7.17-25) when I use this Device Handler. I can’t even see device status, leave alone switch on/off the socket.

In the IDE I can see the device status properly. I can also see a wattage, although 40 W seems to be a dummy value, the actual value that should be displayed must be much lower (as I use an LED lamp connected to the plug, which draws less than 10 W, maybe 4 W, so that it’s off by a factor of 10?).

The below is the “raw description” as found in the IDE:

03 C05E 0010 02 08 1000 0000 0003 0004 0005 0006 0B04 FC0F 01 0019

It matches the fingerprint in the above Device Handler code for manufacturer: "OSRAM", model: "Plug 01".

(BTW, there is a typo above as follows: manufacturer: "LEDVACE")

Can you help me getting this working? Has the above code ever been successfully tested? Is my plug incompatible with the above Device Handler? (If yes, why? Because the “raw description” seems to match?)

Thanks a lot for any help.

Kind regards,

Ralf

Forgot to mention that I can manually change the device type to ZigBee Switch or ZigBee Switch Power, in which case I can operate the socket. But the current wattage will never be correctly shown.

Hi there, we have since been able to get both SMART+ and LIGHTIFY plug versions integrated directly with SmartThings. You should no longer need the device handler to connect. If you’re experiencing issues connecting, try resetting your plug to make sure it’s in pairing mode.

Hi Christine.

Thanks very much for your response.

Indeed I don’t need the device handler to connect, BUT if I connect without a custom device handler I can just switch on/off the attached load. (Or should I manually pick another device type from the built-in types? Please advise.) From the above device handler it seems the plug can measure the attached load, which would be a HUGE plus.

Also, should the above device handler not work nevertheless? If there’s a reason for it not to work (any longer), should you not retract it from here to avoid confusion? Or at least modify it so that it doesn’t match the Osram SMART+ “Plugs?”

Thank you very much.

@SMART.Staff May I kindly ask for a reply to my previous message?

It would be really cool if the plug could indeed measure the current load the attached device draws. Is that possible, as the custom device type suggests?

Also, can you explain why the SMART+ Plug doesn’t respond if I use the custom device type? Again, my understanding is that per the fingerprint the device type should be uniquely identified, so it can’t be that the custom device type doesn’t match the hardware type I’m using?!

Thanks in advance for your help.

@SMART.Staff, kind reminder to respond, please!

©2017 LEDVANCE, LLC. All Rights Reserved. View our Privacy Policy.