App no longer receiving events from ThingShield?


(Joe Angell) #1

Kind of an odd one here. I have my Washer/Dryer Finished ThingShield working great (details here: http://www.tmproductions.com/projects-blog/2015/5/25/washerdryer-finished-alert-via-smartthings ).

Last weekend I deleted the custom SmartApp from SmartThings so that I could clean up the installation, extend the wires on the shield and put the covers back on the appliances. I reinstalled the app, whose sole job is to send a notification whenever the washer or dryer reports that its done. While this worked in the past, it seems that the SmartApp is not receiving events for some reason.

To be clear, the ThingShield is sending events correctly – that is confirmed by watching the activity log. I can also easily force the hardware to send an event by touching two contacts for testing purposes. I see the activity show up as expected, but it’s like the app just isn’t getting the message.

I was going to look at it in the IDE, but for some reason I can’t choose the ThingShield as a physical device from the Home location, but only a virtual device. The physical device is available from the SmartThings app, and was chosen when I reinstalled the app through my phone yesterday (just to be sure it was working).

Everything else appears to be working properly. It’s just this one app. The icons on the Washer/Dryer device are changing as expected, so I know the device is working – it’s just the app. I tried republishing the app, but hat didn’t see to have any effect. The app also has as print statements, but I don’t see anything showing up in the output from them.

Is there a way to debug the SmartApp, monitor its output, etc? Or any way to tell why my app isn’t getting messages from the device all of a sudden?

Thanks!


(Keith Croshaw) #2

I had some issues with an app writing to the thingshield yesterday, perhaps related?


(Joe Angell) #3

I tried rebooting the Hub (i.e.: I unplugged it for a moment), but I’m getting the same results. At least I know my shield is working, insomuch as the icons are changing color for the device in the iPhone app, but I have no idea how to diagnose the problem with the SmartApp.


(Keith Croshaw) #4

I guess post your code and I’ll at least look over it to see if I see anything. Are you using log.debug "" to output your variables states?


(Joe Angell) #5

I do have some log.debug() calls to indicate when functions are called, at least. The log (at https://graph.api.smartthings.com/ide/logs ) simply shows “Updated with settings: [wdmon:Washer/Dryer Finished]”, and nothing else, implying that I’m not receiving events from the device. The log for the device does show the state changing, so I know that part is working.

The link above has the code for the app and device type, but it would make more sense if I posted the app code here. It’s awful simple, and did work before:

/**
*  Washer/Dryer Finished Alert
 *
 *  Copyright 2015 Joe Angell
 *
 *  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.
 *
 */
definition(
    name: "Washer and Dryer Finished Alert",
    namespace: "",
    author: "Joe Angell",
    description: "Sends a notification when the washer or dryer have finished.  Linked to my custom ThingShield.",
    category: "My Apps",
    iconUrl: "http://cdn.device-icons.smartthings.com/Appliances/appliances1-icn.png",
    iconX2Url: "http://cdn.device-icons.smartthings.com/Appliances/appliances1-icn@2x.png",
    iconX3Url: "http://cdn.device-icons.smartthings.com/Appliances/appliances1-icn@2x.png")


preferences {
	section("Title") {
		input "wdmon", "device.WasherAndDryerFinishedMonitor"
	}
}

def installed() {
	log.debug "Installed with settings: ${settings}"

	initialize()
}

def updated() {
	log.debug "Updated with settings: ${settings}"

	unsubscribe()
	initialize()
}

def initialize() {
	subscribe( washerAndDryerFinishedMonitor, "washer", handleWasher )
    subscribe( washerAndDryerFinishedMonitor, "dryer",  handleDryer  )
}

def handleWasher(evt) {
	log.debug "washer monitor reports done"
    if (wdmon.currentValue("washer") == "done") {
 		sendPush( "Washer is done!" )
	}
}

def handleDryer(evt) {
	log.debug "dyer monitor reports done"
    if (wdmon.currentValue("dryer") == "done") {
 		sendPush( "Dryer is done!" )
	}
}

Thanks!


(Keith Croshaw) #6

Is wdmon something in your arduino device type?


(Joe Angell) #7

wdmon is the input representing the device, which in this case is my ThingShield, device.WasherAndDryerFinishedMonitor.

Here’s the Device Type implementation, which seems to be working fine:

/**
 *  Washer/Dryer Finished Monitor
 *
 *  Author: jangell@tmproductions.com
 *  Date: 2013-06-30
 */
// for the UI
metadata {
	definition (name: "Washer and Dryer Finished Monitor", author: "jangell@tmproductions.com") {
		capability "Sensor"

		attribute "washer", "string"
		attribute "dryer", "string"
	}

	tiles {
        standardTile("washer", "device.washer", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true)
        {
            state "pending", label: 'Washer',       backgroundColor: "#ffffff", icon: "st.Appliances.appliances1"
            state "done",    label: 'Washer Done',  backgroundColor: "#69AF1A", icon: "st.Appliances.appliances1"
        }

        standardTile("dryer", "device.dryer", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true)
        {
            state "pending", label: 'Dryer',       backgroundColor: "#ffffff", icon: "st.Appliances.appliances8"
            state "done",    label: 'Dryer Done',  backgroundColor: "#69AF1A", icon: "st.Appliances.appliances8"
        }

		main(   ["washer","dryer"])
        details(["washer","dryer"])
    }
}

// Parse input and send events.
def parse(String description) {
//	log.debug "Parsing '${description}'"

	def cmd = zigbee.parse(description)
	if (!cmd) {
		log.debug "zigbee.parse() returned NULL:  ${description}"
        return
	}

	def parts = cmd.text.split( /:/ );

	if(parts[0] != "washer" && parts[0] != "dryer")
    	return

    def result = createEvent(name:parts[0], value:parts[1]) 
    log.debug "Parse returned ${result?.descriptionText}"
    return result
}

(Keith Croshaw) #8

I don’t see any mention of wdmon as a command in your Device Type.

I’m not a groovy expert but if I would expect wdmon to be a device attribute which it is not. I think that’s your problem, I don’t know your solution. I personally would just try to forward the washer and the dryer to two virtual switches then you could use standard applications.

ST needs “Location wide variables” that you could just toggle true false or write a number to and every SmartApp in your location could read/write to it if so desired. just wishing.


(C Chen) #9

Perhaps this should be
subscribe( wdmon, “washer”, handleWasher )
instead?


(Joe Angell) #10

I’m pretty fuzzy on this as well, but my understanding is that wdmon is the name of a variable in my SmartApp:

preferences {
	section("Title") {
		input "wdmon", "device.WasherAndDryerFinishedMonitor"
	}

So, my app takes a device of type “device.WasherAndDryerFinishedMonitor” and stores it in “wdmon”. My calls to things like wdmon.currentValue() is to get the state of the device.WasherAndDryerFinishedMonitor instance stored in wdmon.

I mostly got this from the IR Bridge code.

However, it doesn’t seem like it’s even calling the event functions, since my log.debug() calls aren’t being hit.

Thanks again


(Joe Angell) #11

AHA! This was a bug in my code. It was the subscribe() calls in initialize(), which should have looked like this:

subscribe( wdmon, "washer", handleWasher )
subscribe( wdmon, "dryer",  handleDryer  )

Instead of wdmon, it was using washerAndDryerFinishedMonitor, which is an undeclared variable and really should have been giving me an error, IMO. I think I used washerAndDryerFinishedMonitor at one point, got it working, and change dir to the much shorter wdmon so that the code was easier to maintain, but didn’t change it in all places. Since it wasn’t subscribing to device, it wasn’t receiving evens (obviously). I clearly did not realize I had made this change after I’d gotten it working (probably doing too many other things at once and lost track).

I just tested it and everything seems to be working. Thanks for pointing me towards wdmon.

– Joe


(Keith Croshaw) #12

Haha no problem. Funny how accidents always seem to be the fix after you’ve tried everything you think you know.