[OBSOLETE] MyQ Garage Door Device Type

I just now tried force closing and starting the app again with no change. Here is more (old when I first created the device type and device) log from the IDE. It’s weird because it was working (at the bottom I opened and closed it) then later it’s not found. Thanks for you hard work! This was the first thing I (unsuccessfully) looked at trying to do late last year when I first got my system.

3 Jun 2014 15:34:17
11 hours ago DEVICE doorStatus door_not_found Garage door 2 door status is door_not_found true
3 Jun 2014 13:56:48
13 hours ago COMMAND close close command was sent to Garage door 2 true
3 Jun 2014 13:56:48
13 hours ago DEVICE doorStatus closed Garage door 2 door status is closed true
3 Jun 2014 13:56:24
13 hours ago DEVICE doorStatus closing Garage door 2 door status is closing true
3 Jun 2014 13:56:16
13 hours ago COMMAND open open command was sent to Garage door 2 true
3 Jun 2014 13:56:16
13 hours ago DEVICE doorStatus open Garage door 2 door status is open true
3 Jun 2014 13:55:57
13 hours ago DEVICE doorStatus opening Garage door 2 door status is opening true
3 Jun 2014 13:52:54
13 hours ago COMMAND poll poll command was sent to Garage door 2 true
3 Jun 2014 13:52:54
13 hours ago DEVICE doorStatus closed Garage door 2 door status is closed false
3 Jun 2014 13:51:36
13 hours ago COMMAND poll poll command was sent to Garage door 2 true
3 Jun 2014 13:51:36
13 hours ago DEVICE doorStatus closed Garage door 2 door status is closed true
3 Jun 2014 13:50:06
13 hours ago DEVICE Garage door 2 is now inactive false
3 Jun 2014 13:43:42
13 hours ago DEVICE doorStatus door_not_found Garage door 2 door status is door_not_found true
3 Jun 2014 13:43:20
13 hours ago DEVICE Garage door 2 is now active false

@acastal @dbmet @a2thejay23 I just released an update on GitHub. It adds significantly more useful logging for device discovery, as well as a new optional preference that lets you just enter your own Door Device ID and skip the whole process of searching based on the door name and device types. You can get the device id from the new logging output.

If the app has a device id cached and won’t do the discovery again, you can trigger the entire process to start over by tapping on the “Preferences” tile on the door detail in the app, and then just tapping “Done”. It will trigger the full discovery.

If you guys can let me know what Type IDs you see during the discovery, I would appreciate it. Both of my doors are type 47. Type 49 is my MyQ Gateway. Finding out these IDs will help other people not have issues down the road.

Thanks
Adam

1 Like

@steveganz @somas1 I just pushed a new version that contains the Contact Sensor capability.

Adam

1 Like

@essidle
this is the output i get for that

92c0f60f-e0b1-408b-94a5-61eeb2c3a387 12:16:08 AM: debug Door Status: unknown
92c0f60f-e0b1-408b-94a5-61eeb2c3a387 12:16:08 AM: debug API Error: [ReturnCode:109, ErrorMessage:Device does not exist]
92c0f60f-e0b1-408b-94a5-61eeb2c3a387 12:16:08 AM: debug Sec Token: HxuHr2r7vkVOr6K0VqMTXzZJGrY3aNvUkvhTEcQKVGX3t4pXDpZWQ0DoOyQbRIPngJDZN7AlrBo/SYoquXdEsw==
92c0f60f-e0b1-408b-94a5-61eeb2c3a387 12:16:06 AM: debug Logging In to Webservice
92c0f60f-e0b1-408b-94a5-61eeb2c3a387 12:16:06 AM: debug Refreshing Door State
92c0f60f-e0b1-408b-94a5-61eeb2c3a387 12:16:06 AM: debug MyQ Garage door Polling
92c0f60f-e0b1-408b-94a5-61eeb2c3a387 12:15:49 AM: error java.lang.NullPointerException: Cannot get property ‘Value’ on null object @ line 360
92c0f60f-e0b1-408b-94a5-61eeb2c3a387 12:15:48 AM: debug Getting MyQ Devices
92c0f60f-e0b1-408b-94a5-61eeb2c3a387 12:15:48 AM: debug Sec Token: /WhegSN6N6heQhbi9deFf6EdTvqXIj01qZfJa3Xo2rMKrpl19ZEIymiQ/9AqjRiMYRY5o7z1mcNuvI1K83ioSQ==
92c0f60f-e0b1-408b-94a5-61eeb2c3a387 12:15:47 AM: debug Logging In to Webservice
92c0f60f-e0b1-408b-94a5-61eeb2c3a387 12:15:47 AM: debug Updating MyQ Garage Door

@essidle I get the same error with the new code:

08688a5d-dd55-4f51-974f-b357f2c51543 6:12:17 AM PDT: error java.lang.NullPointerException: Cannot get property ‘Value’ on null object @ line 360

@a2thejay23 @acastal The errors were from accessing properties on the devices received back from the MyQ API. I added null-safe operators so they wont throw exceptions, but those should not be null so I have no idea what you will see now. I updated the GitHub with a new version with that change.

One of the issues with debugging this is the logging commands only allow a certain amount of data to be logged and MyQ API calls contain significantly more data than can be logged. I will try experimenting with ways to get API dumps recorded so I can troubleshoot your issues better than using guess and check.

Adam

Do I need to delete my garage “Thing” from my dashboard or will updating the garage door device type with your new code be sufficient?

Updated mine with the new code. Appears to be working fine. Below is what I see in the logs in case it helps. I have a LiftMaster opener.

Thanks for writing this and getting it working! Much appreciated.

9:40:17 AM: debug MyQ Garage Door DOES NOT RESPOND TO CHILD UNINSTALL HANDLER
35e58f3e-3129-4a3d-ac38-19047a5233fe 9:40:05 AM: warn stateCheck(open) called but door is closed: doing nothing
cb37c72d-691d-4151-8d1d-b294a65566b4 9:40:05 AM: debug pageParams: [name:garageDoorOpenClose, title:Know if the garage door is open or closed, nextPage:easingCards]
8a9c25843e67270e013e8128c95d30b6 9:40:03 AM: debug Parse returned [Back Door was closed, Back Door was inactive, Back Door was 68°F, Back Door Battery was 50%, Back Door was -14 dBm, Back Door Signal (LQI) was: 100%]
35e58f3e-3129-4a3d-ac38-19047a5233fe 9:39:36 AM: warn stateCheck(open) called but door is closed: doing nothing
f2c6020f-36bd-409b-aa1f-5590222d4599 9:39:35 AM: warn stateCheck(open) called but door is closed: doing nothing
c1dc340a-228e-4c8f-a243-9bb9864f225f 9:39:21 AM: debug Door Status: closed
c1dc340a-228e-4c8f-a243-9bb9864f225f 9:39:20 AM: debug Sec Token: WHau6AmABfgO70BhhYBNI1ngSjZoc9LMGWbtnmiwD1L83Pc3w/h1BAxz0FAospNWQvA60tbbf8+9QrHAsqXRsQ==
c1dc340a-228e-4c8f-a243-9bb9864f225f 9:39:18 AM: debug Logging In to Webservice
c1dc340a-228e-4c8f-a243-9bb9864f225f 9:39:18 AM: debug Refreshing Door State

@essidle Thanks, the new update worked and I was able to get the device IDs back and hard code them instead of the names. It is working now!

Where can we find the logging output… I’m still getting not found

In the IDE you can watch the Logs or in the iPhone app you can click Activity and watch the logs in there. I tend to have better luck with the logs in the IDE.

Thanks for the update. Now i’m able to get status updates on SmartThings apps and i’m able to open and close the garage door.

I wonder if it makes sense to have my presence sensor operate the door opening and closing.

As far as I can tell, it’s not possible to do that with it yet…I would love to do that too!

You guys have obviously never seen the Ridiculously Automated Garage Door SmartApp :slight_smile:

/**
 *  Ridiculously Automated Garage Door
 *
 *  Author: SmartThings
 *  Date: 2013-03-10
 *
 * Monitors arrival and departure of car(s) and
 *
 *    1) opens door when car arrives,
 *    2) closes door after car has departed (for N minutes),
 *    3) opens door when car door motion is detected,
 *    4) closes door when door was opened due to arrival and interior door is closed.
 */

definition(
    name: "Ridiculously Automated Garage Door",
    namespace: "smartthings",
    author: "SmartThings",
    description: "Monitors arrival and departure of car(s) and 1) opens door when car arrives, 2) closes door after car has departed (for N minutes), 3) opens door when car door motion is detected, 4) closes door when door was opened due to arrival and interior door is closed.",
    category: "Convenience",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/garage_contact.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/garage_contact@2x.png"
)

preferences {

	section("Garage door") {
		input "doorSensor", "capability.contactSensor", title: "Which sensor?"
		input "doorSwitch", "capability.momentary", title: "Which switch?"
		input "openThreshold", "number", title: "Warn when open longer than (optional)",description: "Number of minutes", required: false
		input "phone", "phone", title: "Warn with text message (optional)", description: "Phone Number", required: false
	}
	section("Car(s) using this garage door") {
		input "cars", "capability.presenceSensor", title: "Presence sensor", description: "Which car(s)?", multiple: true, required: false
		input "carDoorSensors", "capability.accelerationSensor", title: "Car door sensor(s)", description: "Which car(s)?", multiple: true, required: false
	}
	section("Interior door (optional)") {
		input "interiorDoorSensor", "capability.contactSensor", title: "Contact sensor?", required: false
	}
	section("False alarm threshold (defaults to 10 min)") {
		input "falseAlarmThreshold", "number", title: "Number of minutes", required: false
	}
}

def installed() {
	log.trace "installed()"
	subscribe()
}

def updated() {
	log.trace "updated()"
	unsubscribe()
	subscribe()
}

def subscribe() {
	log.debug "present: ${cars.collect{it.displayName + ': ' + it.currentPresence}}"
	subscribe(doorSensor, "contact", garageDoorContact)

	subscribe(cars, "presence", carPresence)
	subscribe(carDoorSensors, "acceleration", accelerationActive)

	if (interiorDoorSensor) {
		subscribe(interiorDoorSensor, "contact.closed", interiorDoorClosed)
	}
}

def doorOpenCheck()
{
	final thresholdMinutes = openThreshold
	if (thresholdMinutes) {
		def currentState = doorSensor.contactState
		log.debug "doorOpenCheck"
		if (currentState?.value == "open") {
			log.debug "open for ${now() - currentState.date.time}, openDoorNotificationSent: ${state.openDoorNotificationSent}"
			if (!state.openDoorNotificationSent && now() - currentState.date.time > thresholdMinutes * 60 *1000) {
				def msg = "${doorSwitch.displayName} was been open for ${thresholdMinutes} minutes"
				log.info msg
				sendPush msg
				if (phone) {
					sendSms phone, msg
				}
				state.openDoorNotificationSent = true
			}
		}
		else {
			state.openDoorNotificationSent = false
		}
	}
}

def carPresence(evt)
{
	log.info "$evt.name: $evt.value"
	// time in which there must be no "not present" events in order to open the door
	final openDoorAwayInterval = falseAlarmThreshold ? falseAlarmThreshold * 60 : 600

	if (evt.value == "present") {
		// A car comes home

		def car = getCar(evt)
		def t0 = new Date(now() - (openDoorAwayInterval * 1000))
		def states = car.statesSince("presence", t0)
		def recentNotPresentState = states.find{it.value == "not present"}

		if (recentNotPresentState) {
			log.debug "Not opening ${doorSwitch.displayName} since car was not present at ${recentNotPresentState.date}, less than ${openDoorAwayInterval} sec ago"
		}
		else {
			if (doorSensor.currentContact == "closed") {
				openDoor()
				sendPush "Opening garage door due to arrival of ${car.displayName}"
				state.appOpenedDoor = now()
			}
			else {
				log.debug "door already open"
			}
		}
	}
	else {
		// A car departs
		if (doorSensor.currentContact == "open") {
			closeDoor()
			log.debug "Closing ${doorSwitch.displayName} after departure"
			sendPush("Closing ${doorSwitch.displayName} after departure")
		}
		else {
			log.debug "Not closing ${doorSwitch.displayName} because its already closed"
		}
	}
}

def garageDoorContact(evt)
{
	log.info "garageDoorContact, $evt.name: $evt.value"
	if (evt.value == "open") {
		schedule("0 * * * * ?", "doorOpenCheck")
	}
	else {
		unschedule("doorOpenCheck")
	}
}


def interiorDoorClosed(evt)
{
	log.info "interiorContact, $evt.name: $evt.value"

	// time during which closing the interior door will shut the garage door, if the app opened it
	final threshold = 15 * 60 * 1000
	if (state.appOpenedDoor && now() - state.appOpenedDoor < threshold) {
		state.appOpenedDoor = 0
		closeDoor()
	}
	else {
		log.debug "app didn't open door"
	}
}

def accelerationActive(evt)
{
	log.info "$evt.name: $evt.value"

	if (doorSensor.currentContact == "closed") {
		log.debug "opening door when car door opened"
		openDoor()
	}
}

private openDoor()
{
	if (doorSensor.currentContact == "closed") {
		log.debug "opening door"
		doorSwitch.push()
	}
}

private closeDoor()
{
	if (doorSensor.currentContact == "open") {
		log.debug "closing door"
		doorSwitch.push()
	}
}

private getCar(evt)
{
	cars.find{it.id == evt.deviceId}
}

It can be found and modified inside the web-based IDE by clicking Browse SmartApps in the upper right.

In general, our answer is anything is possible, just depends on how much time we have or if someone from the community wants to take it on

@nomisr @chevyman142000 The MyQ device implements the Switch and Contact Sensor capabilities, so you can use any of the Smart Apps that turn switchs on or off (On opens the door, Off closes the door) or any Smart App that uses contact sensors to do something in response to the door opening or closing.

Adam

@acastal That’s great. Do you remember what Device IDs you saw in the logging output? And were your door names listed as “null”?

Adam

Thanks @Ben. I’ll check that out. I’ve been avoiding using any other apps and just trying to use stuff building into the app/dashboard.

Yeah - that is a good way to do it - and we will continue to move functionality into the dashboards and app, but we’ll never be able to match what the community can do with SmartApps, custom device types, and more.

@essidle

i got mine to work as well with the new code and hardcoding the device ID, see type ID and device names below:
I “X”'d out the actual device ID in case thats sensitive info, once i manually specified the device id for the one called “Garage Door” it worked…not sure what the null device is…maybe thats the tilt sensor thats on the garage door itself.? or the unit that mounts to the ceiling

92c0f60f-e0b1-408b-94a5-61eeb2c3a387 12:02:51 PM: debug Device Discovered: Type ID: 259, Device Name: Garage Door, Device ID: XXXXXXXXXX
92c0f60f-e0b1-408b-94a5-61eeb2c3a387 12:02:51 PM: debug Device Discovered: Type ID: 49, Device Name: null, Device ID: XXXXXX

I believe the null device is the MyQ gateway itself, the part that is separate from the door opener.