PetSafe SmartDoor Model HPA15-13808 (DTH in post 27)

I see the battery reports, so we’re getting somewhere.

/**

 *  PetSafe Smart Door
 *
 *  Copyright 2015 Scott Gibson
 *
 *  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 {
	// Automatically generated. Make future change here.
	definition (name: "PetSafe Smart Door", namespace: "sticks18", author: "Scott Gibson") {
		capability "Battery"
		capability "Polling"
		capability "Actuator"
		capability "Refresh"
		capability "Lock"

		fingerprint profileId: "0104", inClusters: "0000 0001 0003 0009 000A 0101", outClusters: "0000 0001 0003 0009 000A 0101"
	}


		simulator {
		/*  // status "locked": "command: 9881, payload: 00 62 03 FF 00 00 FE FE"
		// status "unlocked": "command: 9881, payload: 00 62 03 00 00 00 FE FE"

		// reply "9881006201FF,delay 4200,9881006202": "command: 9881, payload: 00 62 03 FF 00 00 FE FE"
		// reply "988100620100,delay 4200,9881006202": "command: 9881, payload: 00 62 03 00 00 00 FE FE"  */
	}

	tiles {
		standardTile("toggle", "device.lock", width: 2, height: 2) {
			state "locked", label:'locked', action:"lock.unlock", icon:"st.locks.lock.locked", backgroundColor:"#79b821", nextState:"unlocking"
			state "unlocked", label:'unlocked', action:"lock.lock", icon:"st.locks.lock.unlocked", backgroundColor:"#ffffff", nextState:"locking"
			state "unknown", label:"unknown", action:"lock.lock", icon:"st.locks.lock.unknown", backgroundColor:"#ffffff", nextState:"locking"
			state "locking", label:'locking', icon:"st.locks.lock.locked", backgroundColor:"#79b821"
			state "unlocking", label:'unlocking', icon:"st.locks.lock.unlocked", backgroundColor:"#ffffff"
		}
		standardTile("lock", "device.lock", inactiveLabel: false, decoration: "flat") {
			state "default", label:'lock', action:"lock.lock", icon:"st.locks.lock.locked", nextState:"locking"
		}
		standardTile("unlock", "device.lock", inactiveLabel: false, decoration: "flat") {
			state "default", label:'unlock', action:"lock.unlock", icon:"st.locks.lock.unlocked", nextState:"unlocking"
		}
		valueTile("battery", "device.battery", inactiveLabel: false, decoration: "flat") {
			state "battery", label:'${currentValue}% battery', unit:""
		}
		standardTile("refresh", "device.lock", inactiveLabel: false, decoration: "flat") {
			state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
		}

		main "toggle"
		details(["toggle", "lock", "unlock", "battery", "refresh"])
	}
}

// parse events into attributes
def parse(String description) {
	
    log.trace description
    
    def msg = zigbee.parse(description)
    log.trace msg
    
    
	// TODO: handle 'battery' attribute
	// TODO: handle 'lock' attribute

}

// handle commands
def poll() {
	
    log.debug "Executing 'poll'"
	refresh()
}

def refresh() {
	
    [
	"st rattr 0x${device.deviceNetworkId} 0x0C 0x0101 0", "delay 500",
    "st rattr 0x${device.deviceNetworkId} 0x0C 1 0x20"
    ]
    
}

def updated() {

	configure()
    
}

def lock() {
	
    log.debug "Executing 'lock'"
    sendEvent(name: "lock", value: "locked")
	"st cmd 0x${device.deviceNetworkId} 0x0C 0x0101 0 {}"
    
}

def unlock() {
	
    log.debug "Executing 'unlock'"
	sendEvent(name: "lock", value: "unlocked")
	"st cmd 0x${device.deviceNetworkId} 0x0C 0x0101 1 {}"
    
}

def configure() {

	String zigbeeId = swapEndianHex(device.hub.zigbeeId)
	log.debug "Confuguring Reporting and Bindings."
	def configCmds = [	

        //Lock Reporting
        "zcl global send-me-a-report 0101 0 0x30 0 3600 {01}", "delay 500",
        "send 0x${device.deviceNetworkId} 1 1", "delay 1000",

        //Battery Reporting
        "zcl global send-me-a-report 1 0x20 0x20 5 3600 {}", "delay 200",
        "send 0x${device.deviceNetworkId} 1 1", "delay 1500",

        "zdo bind 0x${device.deviceNetworkId} 1 1 0101 {${device.zigbeeId}} {}", "delay 500",
        "zdo bind 0x${device.deviceNetworkId} 1 1 1 {${device.zigbeeId}} {}"
    
    ]
    return configCmds + refresh() // send refresh cmds as part of config
}

private hex(value, width=2) {
	def s = new BigInteger(Math.round(value).toString()).toString(16)
	while (s.size() < width) {
		s = "0" + s
	}
	s
}

private Integer convertHexToInt(hex) {
	Integer.parseInt(hex,16)
}

private String swapEndianHex(String hex) {
    reverseArray(hex.decodeHex()).encodeHex()
}

private byte[] reverseArray(byte[] array) {
    int i = 0;
    int j = array.length - 1;
    byte tmp;
    while (j > i) {
        tmp = array[j];
        array[j] = array[i];
        array[i] = tmp;
        j--;
        i++;
    }
    return array
}

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

Ok is that updated code to try secondly the battery doesn’t report in the smartthings app fyi

That is new code. I know this is frustrating, but it’s the best I can do without the device.

I haven’t written the parse to read the battery messages, but I did see them in the last set of logs. What kind of batteries does it use?

The code appears to be responding real time now but the door isn’t doing anything here’s the log

eddf6518-7f4c-4425-b2e3-a00cff9b8298 9:17:52 PM: trace SmartShield(clusterId: 0x0065, command: 0x0b, data: [0x00, 0x81], destinationEndpoint: 0x01, direction: 0x01, isClusterSpecific: false, isManufacturerSpecific: false, manufacturerId: 0x0000, messageType: 0x00, number: null, options: 0x0100, profileId: 0x0104, senderShortId: 0x222f, sourceEndpoint: 0x0c, text: null)
eddf6518-7f4c-4425-b2e3-a00cff9b8298 9:17:52 PM: trace catchall: 0104 0065 0C 01 0100 00 222F 00 00 0000 0B 01 0081
eddf6518-7f4c-4425-b2e3-a00cff9b8298 9:17:51 PM: debug Executing 'lock’
eddf6518-7f4c-4425-b2e3-a00cff9b8298 9:17:44 PM: trace SmartShield(clusterId: 0x0065, command: 0x0b, data: [0x01, 0x81], destinationEndpoint: 0x01, direction: 0x01, isClusterSpecific: false, isManufacturerSpecific: false, manufacturerId: 0x0000, messageType: 0x00, number: null, options: 0x0100, profileId: 0x0104, senderShortId: 0x222f, sourceEndpoint: 0x0c, text: null)
eddf6518-7f4c-4425-b2e3-a00cff9b8298 9:17:44 PM: trace catchall: 0104 0065 0C 01 0100 00 222F 00 00 0000 0B 01 0181
eddf6518-7f4c-4425-b2e3-a00cff9b8298 9:17:43 PM: debug Executing 'unlock’
eddf6518-7f4c-4425-b2e3-a00cff9b8298 9:17:27 PM: trace SmartShield(clusterId: 0x0065, command: 0x0b, data: [0x00, 0x81], destinationEndpoint: 0x01, direction: 0x01, isClusterSpecific: false, isManufacturerSpecific: false, manufacturerId: 0x0000, messageType: 0x00, number: null, options: 0x0100, profileId: 0x0104, senderShortId: 0x222f, sourceEndpoint: 0x0c, text: null)
eddf6518-7f4c-4425-b2e3-a00cff9b8298 9:17:27 PM: trace catchall: 0104 0065 0C 01 0100 00 222F 00 00 0000 0B 01 0081
eddf6518-7f4c-4425-b2e3-a00cff9b8298 9:17:27 PM: debug Executing 'lock’
eddf6518-7f4c-4425-b2e3-a00cff9b8298 9:17:20 PM: trace null
eddf6518-7f4c-4425-b2e3-a00cff9b8298 9:17:20 PM: trace read attr - raw: 222F0C00010A2000002039, dni: 222F, endpoint: 0C, cluster: 0001, size: 0A, attrId: 0020, result: success, encoding: 20, value: 39
eddf6518-7f4c-4425-b2e3-a00cff9b8298 9:17:20 PM: trace null
eddf6518-7f4c-4425-b2e3-a00cff9b8298 9:17:20 PM: trace read attr - raw: 222F0C006506000086, dni: 222F, endpoint: 0C, cluster: 0065, size: 06, attrId: 0000, result: unsupported attr
eddf6518-7f4c-4425-b2e3-a00cff9b8298 9:17:07 PM: trace SmartShield(clusterId: 0x0065, command: 0x0b, data: [0x01, 0x81], destinationEndpoint: 0x01, direction: 0x01, isClusterSpecific: false, isManufacturerSpecific: false, manufacturerId: 0x0000, messageType: 0x00, number: null, options: 0x0100, profileId: 0x0104, senderShortId: 0x222f, sourceEndpoint: 0x0c, text: null)
eddf6518-7f4c-4425-b2e3-a00cff9b8298 9:17:07 PM: trace catchall: 0104 0065 0C 01 0100 00 222F 00 00 0000 0B 01 0181
eddf6518-7f4c-4425-b2e3-a00cff9b8298 9:17:06 PM: debug Executing ‘unlock’

D size batteries is what it takes

Here’s device-type code for this door. The door must be in automatic mode to be controlled via ST. Basic lock/unlock and battery reporting. Thanks to @aquaria1984 for the patience to test the iterations!

5 Likes

You’re the best @Sticks18

Glad you got it working!

Just a quick reminder: to rebuild the routing table for zigbee devices like this one, unplug the hub for at least 15 minutes, then restart. You don’t need to do anything else, the rebuild will happen automatically.

Zwave devices are a different story. You have to specifically request the rebuild, just powering off doesn’t do it. The utilities are probably all for zwave (I haven’t looked for sure.)

Also, zwave devices cannot act as repeaters for zigbee and vice versa, just another thing to keep in mind.

This looks interesting but can you detect the presence of your cats with the fobs they wear? I always bring my cats in at night and sometimes I have no idea if they are both in, a sleeping cat has little initiative to get up and let you know where they are when you call.

Will this allow the door to be locked/unlocked based on modes? For instance, when no one is home at the house, the door will remain locked, and when we’re home the dogs can come and go?

1 Like

@daven unfortunately the implementation with ST does not work with the fobs. It only provides ability to lock/unlock via ST, not automatically via the fobs. It’s very basic functionality with this devicetype.

@John_Esher yes, it uses the generic lock capability, so you should be able to have it operate based on mode/presence by using built-in ST actions for locks.

2 Likes

Okay I can verify that the programming that @Sticks18 did will make the doog door function like any other door lock integrated into the smartthings platform. The keyfobs that came with the door are not part of the device type programing. The door will work consistently with the device type programming if set to automatic mode on the door. I can tell you i use it daily and is great. Even if the keyfobs worked I wouldn’t use them due to them overriding the door schedule.

Need anything else let me know

1 Like

This conversation is the reason purchased a hub! So glad I found this.Thanks for the work that went into figuring this all out! V2 hub arrived yesterday and the newly installed Petsafe door is locking and unlocking via the smartthings mobile app. I am hoping to figure out a way to track if my Dog is inside or outside after I have unlocked the door for him. Is there any way to do this with the just the dog door or am I going to need to add some other sensors or a camera?

1 Like

Door was working great for about 6 hrs. When it stopped responding I took the batteries out of the hub and
unplugged it for 15 min. Once the hub was up and running again the door
responded as expected for about 12hrs. I tried resetting the hub again
and this time there was no change. I’m pretty new to all this and I’m
not sure where to start troubleshooting. How can I tell if there is a
connection issue? I don’t want to run out and buy a zigbee device to act
as a repeater if that wont solve the problem. The mobile app shows the
battery percentage and changes from locked to unlocked when I tap the
icon. How do I tell if there is something going on with the code or the way I implemented it? Any
help would be appreciated.

@aquaria1984 do you still have your door in use? Have you experienced any problems with it?

I have no problems with my door it is working perfectly even on hub v2.

2 Likes

Make sure door is set to the yellow light. Once you have the door paired to SmartThings app do not manually touch the door. Or it will get out of sync with the app. Ive had my door up and running for at least a year with no problems. Let me know if this helps

1 Like

I installed and a Petsafe dog door and got it working for about 6 hrs per this discussion.

When it stopped responding I took the batteries out of the hub and unplugged it for 15 min. Once the hub was up and running again the door responded as expected for about 12hrs. I tried resetting the hub again and this time there was no change. I’m pretty new to all this and I’m not sure where to start troubleshooting. How can I tell if there is a connection issue? I don’t want to run out and buy a zigbee device to act as a repeater if that wont solve the problem. The mobile app shows the battery percentage and changes from locked to unlocked when I tap the icon. How do I tell if there is something going on with the code? Any help would be appreciated.

It’s unusual for a device to have a range issue that works for six hours and then stops working. Unless you reached a point where the batteries died and that doesn’t sound like that’s what’s going on.

More commonly that would be an interference problem. In particular boosted Wi-Fi can interfere with ZIgbee.

I Have a major problem at my house every afternoon about 15 minutes after the school bus arrives where some of my Zigbee devices drop off-line. I’m pretty sure one of my neighbors has boosted Wi-Fi, their teenager gets home from school, and the Wi-Fi traffic zooms up.

You can also get intermittent interference. It’s pretty much the same principle as when you turn on the microwave and Netflix starts buffering. As Soon as the Microwave goes off again, everything is fine. Even though the microwave is not actually on your Wi-Fi network, it’s causing interference.

If the problem is local interference, it could be very hard to diagnose without professional tools. Usually the easiest thing is just to put in a repeater nearby and see if that helps. I can understand why you don’t want to spend the additional money though.

I know that doesn’t help very much, but it might give you a place to start researching.

You can also write to support@smartthings.com and ask for their help in diagnosing the signal strength of the device it’s getting lost. They might be able to see something from their side.

I would also definitely go back and post in the original thread where you got the device type and see if the author or anyone else using it has any more advice. Sometimes are quirks specific to a particular device or device type that it helps to know about and asking in that thread is the fastest way to get the attention of people who are actually using it.

1 Like

To double check a signal strength issue move your hub closer to your door and see if the problem goes away. If it does then you may want to think about leaving your hub there or getting a ZigBee repeater. A strong signal from a repeater will lessen the effect of external radio interference.

1 Like

Thanks. That makes a lot of sense. It has stopped working at about the same time both days. Ive only had it for 2 days so there isn’t a lot of data to go off of here, but interference seems logical. I’ll check in with the original thread as well to see if there is any ideas there too.