Update status of device

Hello,
How do I make a device update it’s current status such as ON or OFF on the Smartthings app. Right now I have a certain device that doesn’t update it’s status to the app when I manually turn it ON and OFF on the device. The only way I can update the device’s status is when I press the refresh button on the app. How can I make it so the device handler automatically refreshes the status of the device?

If I remember correctly, try with

device.sendEvent(name: “switch”, value: “on”)

It’s depends what device it is. If it is a dimmer switch, it is prevented by patent from informing the hub of the manual change immediately unless it has licensed the Lutron patent. The way around this is to use association and to put the hub into the Association group.

My device is a ZigBee Switch. Is it prevented by patent?

How does this refresh the device status on the app when I manually turn the device ON and OFF?

The Lutron patent applies to both zwave and zigbee dimmers, but not to plain on/off switches.

Would doing, device.sendEvent(name: “switch”, value: “on”), work and update the status of a ZigBee switch? If so where would I place this line of code in the device handler?

  1. Have you even tried to read the Developer Documentation? http://docs.smartthings.com

  2. Have you looked at (and “played with” to the point of understanding how it works) sample simple Devices Type Handlers like basic ZigBee Switch? https://github.com/SmartThingsCommunity/SmartThingsPublic

SmartThings is a documented development platform. All of the stuff your are asking has been answered in the Docs, in published examples, and throughout the Forum.

  1. Yes. New to it.
  2. Yes, quite a bit.

Why doesn’t ZigBee switch device handler automatically refresh the current status on the app when I manually turn the device on or off manually?

Do you have a SmartThings (CentraLite, Lowes, PEQ) ZigBee outlet? It is an “instant reporting” ZigBee based Switch (not a wall switch… Most of them are prohibited by patent from instant reporting… you need a refresh() method.

When the Outlet button is pressed or anything changes its State, it will send a message to the DTH parse() method with, which, if you follow the example, will result in implicit sendEvent call which will update the State and automatically the App.

Earlier JDRoberts said that a ZigBee switch device handler isn’t prohibited by patent and also the ZigBee device handler has a refresh method:

def refresh() {
zigbee.onOffRefresh() + zigbee.onOffConfig()
}

So I am not sure why it won’t update the status. I’ve been looking at this page: http://docs.smartthings.com/en/latest/device-type-developers-guide/building-zigbee-device-handlers.html

Why doesn’t this method update the status like it’s supposed to?

The Lutron patent only covers dimmers. But who knows what’s been put in the device type handlers. Certainly not me, I can’t read them. :wink:

1 Like

Can you share the whole code please? It’s impossible to debug from just one method.
Also need the brand and model of the Device.

Be sure to use the </> button in the editor to format your code (or paste GitHub link instead).

Built off of the ZigBee device handler.

metadata {
definition (name: “Switch”, namespace: “Ion”, author: “Jack”) {
capability "Actuator"
capability "Configuration"
capability "Refresh"
capability “Switch”

fingerprint profileId: “0104”, inClusters: “0000, 0003, 0004, 0005, 0006”, deviceJoinName: “Switch”
//fingerprint profileId: “0104”, inClusters: “0000, 0003, 0006”, outClusters: “0003, 0006, 0019, 0406”, manufacturer: “Leviton”, model: “ZSS-10”, deviceJoinName: “Leviton Switch”
}
// simulator metadata
simulator {
// status messages
status “on”: “on/off: 1"
status “off”: “on/off: 0”
// reply messages
reply “zcl on-off on”: “on/off: 1"
reply “zcl on-off off”: “on/off: 0”
}
tiles(scale: 2) {
multiAttributeTile(name:“switch”, type: “lighting”, 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:”#79b821”//, nextState:“turningOff"
attributeState “off”, label:’${name}’, action:“switch.on”, icon:“st.switches.light.off”, backgroundColor:”#ffffff"//, nextState:“turningOn”
//attributeState “turningOn”, label:’${name}’, action:“switch.off”, icon:“st.switches.light.on”, backgroundColor:"#79b821", nextState:“turningOff”
//attributeState “turningOff”, label:’${name}’, action:“switch.on”, icon:“st.switches.light.off”, backgroundColor:"#ffffff", nextState:“turningOn”
}
}
standardTile(“refresh”, “device.refresh”, inactiveLabel: false, decoration: “flat”, width: 2, height: 2) {
state “default”, label:"", action:“refresh.refresh”, icon:“st.secondary.refresh”
}
main "switch"
details([“switch”, “refresh”])
}
}

// Parse incoming device messages to generate events
def parse(String description) {
log.debug "description is $description"
def event = zigbee.getEvent(description)
if (event) {
sendEvent(event)
}
else {
log.warn "DID NOT PARSE MESSAGE for description : $description"
log.debug zigbee.parseDescriptionAsMap(description)
}
}

def off() {
zigbee.off()
}

def on() {
zigbee.on()
}

def refresh() {
zigbee.onOffRefresh() + zigbee.onOffConfig()
}

def configure() {
log.debug "Configuring Reporting and Bindings."
zigbee.onOffConfig() + zigbee.onOffRefresh()
}

1 Like

Thanks for the code… I may have a chance to look at it sometime: Be sure to check your Live Logging too.

Meanwhile, my PEQ (Centralite = SmartThings) ZigBee Appliance outlet is definitely instant reporting (the SmartThings App is updated immediately).


BUT one of my SmartApps is not receiving events for it consistently at the moment. SmartThings Platform may be having problems, which may be affecting your testing.

Check with @tslagle13, perhaps.

2 Likes

Thanks. Let me know when you know if there’s a problem with the code or a way to resolve my problem please.

What does your Live Logging output say??? Debugging by Forum messages requires a lot more detailed info.

(For further assistance from me, please contact by PM / email for personal tutoring services by Skype at my usual billing rate.)

My logs say:

So… You’re lucky I’m patient… You have a way to narrow down the problem now.

  1. Where is that log output coming from?

  2. What does that ZigBee message mean according to the ZigBee HA documentation?

  3. Now you’re closer to an answer as to what line of code isn’t working and perhaps why.

We’re here to coach a support each other, not write video for custom devices over long distance messages.

1 Like

I was able to find the log output and add some code to find the current status, but I still am not getting how to automatically refresh the status of the device on the app when I manually toggle the device. Could you please guide me through how to resolve this?

Code:

// Parse incoming device messages to generate events
def parse(String description) {
log.debug "description is $description"

def event = zigbee.getEvent(description)
if (event) {
    sendEvent(event)
    log.info "Name: ${event.name}, Value: ${event.value}" // <<----Wrote to tell me current status!
}
else {
    log.warn "DID NOT PARSE MESSAGE for description : $description"
    log.debug zigbee.parseDescriptionAsMap(description)
}
}

Logs: