Creating a new Child Device Handler for the new app (combining defaul capabilities)

Hey Guys,

I am trying to create a new DTH (actually 2 parent/child) combining the default capabilities.

I ‘successfully’ created the parent one, but when it comes to the child devices, they appear as “Checking Status” in the new app and none of the attributes show the Value/State, even though I can see them in the History tab…)

Here are some screenshots to have a better understanding of what I am seeing in the new app.





Has anyone encountered the same problem? This is the DTH for the child device:

/**
 *  Plant Device
 *
 *  Copyright 2020 Diego Antonino
 *
 *  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: "Plant Device", namespace: "DiegoAntonino", author: "Diego Antonino", cstHandler: true) {
    capability "Relative Humidity Measurement"
	capability "Switch"
    capability "Actuator"
    capability "Sensor"
    capability "Refresh"
    capability "Health Check"
    
    attribute "check_in_at", "string"
        
  }

  simulator {
    // TODO: define status and reply messages here
  }

  tiles {
		multiAttributeTile(name: "switch", 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"
				attributeState "off", label: '${name}', action: "switch.on", icon: "st.switches.light.off", backgroundColor: "#ffffff"
			}
		}
        valueTile("humidity", "device.humidity", decoration: "flat") {
			state  "value", label:'Moisture Value\n\n${currentValue}'
	    }
        standardTile("check_in_at", "device.check_in_at", inactiveLabel: true, decoration: "flat", width: 3, height: 1) {
            state  "default", label:'Last Check-in was at:\n\n${currentValue}'
        }
		main "humidity"
		details(["humidity", "switch", "check_in_at"])
	}
}
def installed() {
	updateSettings()
}

def updated() {
	updateSettings()
}

def refresh(){
	log.info("calling refresh from child device: ${device.deviceNetworkId}")
	parent.refresh()
}

def ping() {
    log.error("unexpected ping call from health check")
	parent.refresh()
}

def updateSettings(){
    log.debug "Configured health checkInterval: ${2*60*60} seconds (2hrs) "
    sendEvent(name: "checkInterval", value: 7200, displayed: false, unit: "s")
    //sendEvent(name: "DeviceWatch-DeviceStatus", value: "online", displayed: false, isStateChange: true)
    //sendEvent(name: "DeviceWatch-Enroll", value: groovy.json.JsonOutput.toJson([protocol: "LAN", scheme:"untracked", hubHardwareId: "${device.hub.hardwareID}"]), displayed: false)
}

def on() {
	log.debug "send on"
    sendData("on")
}

def off() {
	log.debug "send off"
    sendData("off")
}

def parse(String description) {
	log.debug "parse called: ${description}"
    def events_in = description.split(",")
    
    events_in?.each { event ->
    	def parts = event.split(":")
    	def name  = parts.length>0?parts[0].trim():null
        def value = parts.length>1?parts[1].trim():null
        
        if (name && value) {
            // Update device
            if (device.currentValue(name) != value) {
                log.debug "Updated Attribute: name: ${name}, value: ${value}"
                sendEvent(name: name, value: value, isStateChange: true)
            }
    	}
    }
    
    def ts = getReceivedTs()
    log.debug "Updated Attribute: name: check_in_at, value: ${ts}"
    sendEvent(name: "check_in_at", value: ts, isStateChange: true)
}

def sendData(String value) {
    def name = device.deviceNetworkId.split("-")[-1]
    parent.sendPumpAction("${name}:${value}")  
}

def getReceivedTs() {
	def df = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
    df.setTimeZone(location.timeZone)
    
    return df.format(new Date())
}

Perhaps there is something very obvious, but already spend the whole day trying to figure it out with no success.

Any hint would be much appreciated :slight_smile:

Thanks!
Diego

1 Like

Sorry I can’t help, but the same thing happened to me with my Qubino child devices when I was forced to change over to the newest SmartThings Alexa skill. None of my child devices work anymore and are not discoverable by Alexa. You might want to take a look at this thread [RELEASE] Qubino Flush 1D Relay, Flush 2 Relays, Flush 1 Relay, & Flush Dimmer from about Aug 20 and on. Some discussion going on about this but nothing in the past couple of days. Tried some troubleshooting with no success and fried a Qubino module in the process!

@Eric_Inovelli figured this out for his most recent version of the LZW31-SN switch children. I had to re-initialize the children but they work way better now. You might look at the changes he implemented here:

4 Likes

Thank you very much! This made the trick!!!