Trying to create Device Handler for Ikea Zigbee On/Off handheld button

I recently got this Ikea Smart plug bundle (Plug + on/Off Switch) : https://www.ikea.com/us/en/catalog/products/70364803/

I want to use the IKEA “On/Off Switch” separately. Went ahead and was able to add the On/Off Switch as a Thing in ST. As there is not available DT (ZIgbee Switch, etc) working, I started writing by referring the existing DTs to make it work. As of now, it doesn’t work and I am at this stage looking for inputs (Note that this is 1st Zigbee ST I am writing, so more or less guess works and references). Proceeded as follows:

  1. Took base code from the existing Zigbee Switch DT here : https://github.com/SmartThingsCommunity/SmartThingsPublic/blob/master/devicetypes/smartthings/zigbee-switch.src/zigbee-switch.groovy
  2. Updated Metadata fingerprint info above, which I guess would be same as one seen in existing/working IKEA DH for bulbs,Dimmers etc : https://github.com/edvaldeysteinsson/IKEA-Tradfri/blob/master/devicetypes/edvaldeysteinsson/ikea-tradfri.src/ikea-tradfri.groovy
    Correct me, if I am assuming wrong here.
  3. Added some debug lines.

Based on above steps, published the non-working DH here : https://github.com/swapanshridhar/IkeaZigbeeSwitch/blob/master/IkeaZigbeeSwitch.groovy

Coping same code here also :

/**
 *	Copyright 2015 SmartThings
 *
 *	Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *	in compliance with the License. You may obtain a copy of the License at:
 *
 *		http://www.apache.org/licenses/LICENSE-2.0
 *
 *	Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *	on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *	for the specific language governing permissions and limitations under the License.
 *
 */

metadata {
	definition (name: "IKEA ZigBee Switch", namespace: "mycodebits", author: "Swapan Shridhar", ocfDeviceType: "oic.d.switch", runLocally: true, minHubCoreVersion: '000.019.00012', executeCommandsLocally: true, genericHandler: "Zigbee") {
		capability "Actuator"
		capability "Configuration"
		capability "Refresh"
		capability "Switch"
		capability "Health Check"

        fingerprint inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B05, 1000", outClusters: "0005, 0019, 0020, 1000", manufacturer: "IKEA of Sweden",  model: "TRADFRI Button", deviceJoinName: "TRÅDFRI Button" 
     
}

	// 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"
	}

	tiles(scale: 2) {
		multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4, canChangeIcon: true){
			tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
				attributeState "on", label:'${name}', action:"switch.off", icon:"st.switches.light.on", backgroundColor:"#00A0DC", nextState:"turningOff"
				attributeState "off", label:'${name}', action:"switch.on", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn"
				attributeState "turningOn", label:'${name}', action:"switch.off", icon:"st.switches.light.on", backgroundColor:"#00A0DC", nextState:"turningOff"
				attributeState "turningOff", label:'${name}', action:"switch.on", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn"
			}
		}
		standardTile("refresh", "device.refresh", 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 event = zigbee.getEvent(description)
        log.debug "parse(). Event : $event"
        def parseVal = zigbee.parse(description)
        log.debug "parse(). zigbee.parse : $parseVal" 
	if (event) {
		sendEvent(event)
	}
	else {
		log.warn "DID NOT PARSE MESSAGE for description : $description"
		log.debug zigbee.parseDescriptionAsMap(description)
	}
}

def off() {
	zigbee.off()
}

def on() {
	zigbee.on()
}

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

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

def configure() {
	// Device-Watch allows 2 check-in misses from device + ping (plus 2 min lag time)
	sendEvent(name: "checkInterval", value: 2 * 10 * 60 + 2 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
	log.debug "Configuring Reporting and Bindings."
	zigbee.onOffRefresh() + zigbee.onOffConfig()
} 

From the logs I see the following:

12:25:22 AM: debug [raw:0104 0006 01 01 0000 00 B0E1 00 00 0000 07 01 86000000, profileId:0104, clusterId:0006, sourceEndpoint:01, destinationEndpoint:01, options:0000, messageType:00, dni:B0E1, isClusterSpecific:false, isManufacturerSpecific:false, manufacturerId:0000, command:07, direction:01, data:[86, 00, 00, 00], clusterInt:6, commandInt:7]
12:25:22 AM: warn DID NOT PARSE MESSAGE for description : catchall: 0104 0006 01 01 0000 00 B0E1 00 00 0000 07 01 86000000
12:25:22 AM: debug parse(). zigbee.parse : SmartShield(text: null, manufacturerId: 0x0000, direction: 0x01, data: [0x86, 0x00, 0x00, 0x00], number: null, isManufacturerSpecific: false, messageType: 0x00, senderShortId: 0xb0e1, isClusterSpecific: false, sourceEndpoint: 0x01, profileId: 0x0104, command: 0x07, clusterId: 0x0006, destinationEndpoint: 0x01, options: 0x0000)
12:25:22 AM: debug parse(). Event : [:]
12:25:22 AM: debug description is catchall: 0104 0006 01 01 0000 00 B0E1 00 00 0000 07 01 86000000
12:25:22 AM: debug [raw:0000 8021 00 00 0000 00 B0E1 00 00 0000 00 00 5B00, profileId:0000, clusterId:8021, sourceEndpoint:00, destinationEndpoint:00, options:0000, messageType:00, dni:B0E1, isClusterSpecific:false, isManufacturerSpecific:false, manufacturerId:0000, command:00, direction:00, data:[5B, 00], clusterInt:32801, commandInt:0]
12:25:22 AM: warn DID NOT PARSE MESSAGE for description : catchall: 0000 8021 00 00 0000 00 B0E1 00 00 0000 00 00 5B00
12:25:22 AM: debug parse(). zigbee.parse : SmartShield(text: null, manufacturerId: 0x0000, direction: 0x00, data: [0x5b, 0x00], number: null, isManufacturerSpecific: false, messageType: 0x00, senderShortId: 0xb0e1, isClusterSpecific: false, sourceEndpoint: 0x00, profileId: 0x0000, command: 0x00, clusterId: 0x8021, destinationEndpoint: 0x00, options: 0x0000)
12:25:22 AM: debug parse(). Event : [:]
12:25:22 AM: debug description is catchall: 0000 8021 00 00 0000 00 B0E1 00 00 0000 00 00 5B00
12:25:22 AM: debug parse(). zigbee.parse : SmartShield(text: null, manufacturerId: 0x0000, direction: 0x01, data: [0x00, 0x00, 0x86], number: null, isManufacturerSpecific: false, messageType: 0x00, senderShortId: 0xb0e1, isClusterSpecific: false, sourceEndpoint: 0x01, profileId: 0x0104, command: 0x01, clusterId: 0x0006, destinationEndpoint: 0x01, options: 0x0000)
12:25:22 AM: debug parse(). Event : [name:switch, value:off]
12:25:22 AM: debug description is catchall: 0104 0006 01 01 0000 00 B0E1 00 00 0000 01 01 000086

As soon as the DT is selected and Button pressed (irrespective of On or Off), the above logs show up, where I see :

  • catchall , and
  • Event few times (always off one),

and then after above initial logs, irrespective of how many times I press the button, no further logs/communication happens.

*I am not sure at this point if fingerprint is correct or not. Further, why after initial communication with few Event messages, nothing happens even if i press button. Not sure, if it is some issue at the Ikea switch itself in terms of how it is advertising itself ?

For any one looking, I was able to get this information about this Ikea’s Zigbee Switch specs on Zigbee alliance website (download zip) : https://www.zigbee.org/zigbee-products-2/#zigbeecertifiedproducts/productdetails3/5b7fe983f5ba177bb927668a/ (In case it helps!)

Any inputs on how to proceed would be highly appreciated ?

Anyone who can help for above query :slightly_smiling_face:

At the present time, the IKEA Tradfri smart bulb and plug-in pocket socket work well with smartthings, but there is only partial integration with the handheld buttons and remotes. Many people have been trying to make these work for almost a year. No one has it working yet.

You can add it to your SmartThings network as a “thing“ and then you can use it to control an IKEA Device which is already on your SmartThings network as a parallel means of control. But you can’t make it work for other purposes at present.

It appears that all of the IKEA Tradfri handheld controllers have the same issues.

You might want to take a look at the existing threads and talk to the people there:

1 Like

Thanks @JDRoberts. This explains.

1 Like

Actually I have a different experience with this on-off switch than with previous dimmers and remotes. When I try what worked before,

  1. on-off switch shows as a thing and is online
  2. the other device is also paired and working
  3. when I try to pair the switch to the device (bulb, outlet, doesn’t matter) both devices go off the smartthings network, and stay paired to just each other. Tried several times.

Anyone had success with this particular switch?

1 Like

I have almost the same experience as “boyanski”. Outlet is recognized as an Ikea outlet and is working fine. Can not add on-off switch to smartthings and if i sync it to the outlet the outlet disappears from smartthings.

Update: After rebooting Smartthings could connect Trådfri on-off switch, although i can not do anything with it.

Trådfri Outlet 2.0.022
Trådfri on-off switch 2.0.020
Smartthings V3 25.00027