[OBSOLETE] SwannOne Key Fob Support (updated 2019 DTH in post #51)

Ok, I think I didn’t upload the code to change the icon, it’s for cosmetics only. But it’s the new device type handler.

/**
 *  Swann One Key Fob
 *
 *  v:1.00 - 12/31/2015 - Initial Configuraton
 *  v:1.01 - 03/11/2019 - James added numberofButtons reporting
 *  v:1.02 - 03/11/2019 - James added icon change function
 *
 *  Copyright 2015 Rudimar Prunzel
 *
 *  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: "Swann One Key Fob", namespace: "RudiP", author: "Rudimar Prunzel") {
		capability "Button"
		capability "Configuration"

        fingerprint profileId: "0104", deviceId: "0401", inClusters: "0000,0003,0500", outClusters: "0003,0501"
    }

    tiles {
	    standardTile("button", "device.button", width: 2, height: 2, canChangeIcon: true, canChangeBackground: true) {
		    state "default", label: "", icon: "st.unknown.zwave.remote-controller", backgroundColor: "#ffffff"
        }
    }
    main (["button"])
    details (["button"])
}

def parse(String description) {	       	            
    if (description?.startsWith('enroll request')) {        
        List cmds = enrollResponse()
        log.debug "enroll response: ${cmds}"
        def result = cmds?.collect { new physicalgraph.device.HubAction(it) }
        return result    
    } else if (description?.startsWith('catchall:')) {
        def msg = zigbee.parse(description)
        log.debug msg
        buttonPush(msg.data[0])
    } else {
        log.debug "parse description: $description"
    }    
}

def buttonPush(button){
    //Button Numbering vs positioning is slightly counterintuitive
    //Bottom Left Button (Unlock) = 0 and goes counterclockwise
    //Securifi Numbering - 0 = Unlock, 1 = * (only used to join), 2 = Home, 3 = Lock
    //For ST App Purposes 1=Lock, 2=Home, 3=Unlock , 4 = * (only used to join)
    def name = null
    if (button == 0) {
        //Home - ST Button 1
        name = "1"
        def currentST = device.currentState("button")?.value
        log.debug "Home button Pushed"           
    } else if (button == 3) {
    	//Away - ST Button 2
        name = "2"
        def currentST = device.currentState("button2")?.value
        log.debug "Away button Pushed"        
    } else if (button == 2) {
        //Night - ST Button 3
        name = "3"
     	def currentST = device.currentState("button3")?.value
        log.debug "Night button Pushed"         
    } else {
        //Panic - ST Button 4
        name = "4"
     	def currentST = device.currentState("button4")?.value
        log.debug "Panic button Pushed"         
    
    }

    def result = createEvent(name: "button", value: "pushed", data: [buttonNumber: name], descriptionText: "$device.displayName button $name was pushed", isStateChange: true)
    log.debug "Parse returned ${result?.descriptionText}"
    return result
}


def enrollResponse() {
    log.debug "Sending enroll response"
    [            
    "raw 0x500 {01 23 00 00 00}", "delay 200",
    "send 0x${device.deviceNetworkId} ${endpointId} 1"        
    ]
}


def configure(){
    log.debug "Config Called"
    def configCmds = [
    "zcl global write 0x500 0x10 0xf0 {${device.zigbeeId}}", "delay 200",
    "send 0x${device.deviceNetworkId} ${endpointId} 1", "delay 1500",
    "zdo bind 0x${device.deviceNetworkId} ${endpointId} 0x01 0x0501 {${device.zigbeeId}} {}", "delay 500",
    "zdo bind 0x${device.deviceNetworkId} ${endpointId} 1 1 {${device.zigbeeId}} {}"
    ]
    return configCmds
}

def installed() {
initialize()
}

def updated() {
initialize()
}

def initialize() {
sendEvent(name: "numberOfButtons", value: 4)
}

Yes, you can use Button Controller smart app, or create a Routine under automation. I’m not sure where you got stuck.

Unfortunately, there’s no ‘‘Routines’’ choice under ‘‘Automations’’ anymore, even in the Classic App… So I guess it’s the SmartApp only.

Thank you very much for the updated DH, now it works for the icon too!

Now, what I’m trying to do is to set arm(away)/arm(stay)/disarm to my Smartthings hub by pressing each of the key fob buttons.

As you can see i my previous post, there’s no choice for such thing at all!

Am I missing something?

Once again, thank you for your time!

It’s called “Modes” in your choices (under Sonos).

Apparently not… So frustrated with this matter…

Any other way, please?

Screenshot_20191223_214206_com.smartthings.android.jpg

Hey, thanks for writing this DTH.

I can see which buttons are being pressed when viewing the live logging, but I cannot get either the Classic App or WebCore to do anything upon the button being pressed.

I really don’t know enough about it, but I did once have a 2 button Xiaomi switch where only 1 button would ever work, I read something about endpoints, but again, something I don’t know anything about.

Has anyone else had the same issue and know how to solve this?

Many thanks.

K.

Could someone help me.
I’m new to creating additional device handlers for things like the swannone keyfob so please be patient lol.
I’ve tried following this thread and others but getting lost.
Is there an easy way to upload using the community installer or do we have to do manually?
If manually, could someone give me a brief outline how to do this cos I’ve tried and whilst the key fob is showing in the online ide I cant see it anywhere in the app.
Many thanks

Hi, I’m new to world ST and device handlers, I have quite a bit of reading on this topic and the issues seemed to be overcome. However I bought a SwannOne key fob and have set it up using device handler code above, looks great everything connected.
However any button pressed on the fob only registers as ‘button’ in the app so the 4 buttons can only be programmed to complete a single task.

I have checked the event log and each of the 4 buttons are being correctly identified on there specific presses 1-4.

I have tried assigning actions to ‘Button 1-4’ in the app but nothing happens, but if I assign a task to ‘button’ and 1 of the 4 buttons perform the assigned task.

Any help would be greatly appreciated, I’m starting to pull my hair out …

Thanks!

Everything above your post referred to the classic app, which is no longer available. Now everyone has to use the new V3 app.

And unfortunately, the way buttons are handled has changed completely with the new platform. So there are a lot of multi button devices which used to work with the old app and don’t work with the new app. :disappointed_relieved:

The first thing to try is to see if it still works the official smartlighting feature. That still uses some of the old methods, so it continues to work with some of the older device type handlers.

However, if that doesn’t work, then someone has to rewrite the DTH to work with the new app, and that’s quite a bit of work.

What country are you in? There may be another similar device which is working with the new platform and might be a better choice.

Hi Thanks for the reply, I realise this is quite an old topic!

Based in the UK, V3 app & Hub.

I was just looking if I can get it to work with a smartapp like button controller, but no luck so far.

I’d love to know if anyone has got these working as Ive got several that are no more than desk ornaments at the moment. If there is anyone in the UK with the ability to recode let me know and I could send you a keyfob for investigation.

I did get mine working but only as a single button, all 4 register as button 1 in the code, I couldn’t resolve the issue myself.

How did you manage to get it working?
I get the following error.

Org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: script_dth_metadata_234d2c78_96b2_4ba1_8491_771e01e59ef8: 1: expecting EOF, found ‘def’ @ line 1, column 1293. ton"]) details ([“button”]) } def parse( ^ 1 error

Using the device handler code in the thread above worked for me, sorry i cant be of much more help.