Why does the icon not update? Compare time between events? Smartthings Shield and ardriuno

(Lord Saibat) #1

My device is sending ping but my icon will not update.

Is there a way to count to number of pings also or compare the time between events?

How do you send messages back to the device? Like a handshake to know the cloud received the message?

Here is my code below:

 *  Input Monitor
 *  Copyright 2014 
 *  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: "Input Monitor (36 inputs)", author: "", oauth: true) {
		capability "Contact Sensor"
		capability "Sensor"

		fingerprint profileId: "0104", deviceId: "0402", inClusters: "0000,0001,0003,0009,0500", outClusters: "0000"

	// simulator metadata
	simulator {
		// status messages
        status "Red" : "Status reported within the last 5 minutes"
		status "Yellow": "Status reported within the last 2 minutes"
        status "Green": "Status reported within the last 60 seconds"

	// UI tile definitions
	tiles {
		standardTile("contact", "device.contact", width: 2, height: 2) {
            state "Red", label: '${name}', icon: "st.Home.home2", action: "red", backgroundColor: "#ff0000"
			state "Yellow", label: '${name}', icon: "st.Home.home2", action: "yellow", backgroundColor: "#cccc00"
            state "Green", label: '${name}', icon: "st.Home.home2", action: "green", backgroundColor: "#00ff00"

		main "contact"
		details "contact"

// Parse incoming device messages to generate events
def parse(String description) {
	def value = zigbee.parse(description)?.text
	def name = value && value != "ping" ? "response" : null
	def result = createEvent(name: name, value: value)
	log.debug "Parse returned ${result?.descriptionText}"
	zigbee.smartShield(text: "updated").format()
    if (value == "ping"){
    log.debug "Ping Received!"
    log.debug("Test count $test")

    zigbee.smartShield(text: "green").format()
    return result


(Lord Saibat) #2

Figured it out. It took a good amount of coding to correct the issues.