+2 votes
by (580 points)
CUSTOM DEVICE HANDLER question for developers - I have an issue with getting state changes on a custom device handler that I have modified from other open source code. As part of the device creation process, I enter preferences, and it updates the device network ID field with a hex value of the IP address, among other things. I am creating multiple test devices with this handler, and deleting them quickly and repeating as I test. Each test device will have the same network ID, but the devices never exist at the same time. In Live Logging, I notice that the handler makes a device query, and then SmartThings associates the response with the first device test name I created this morning, and does not return the results to the current device name. The original test device from this morning has been deleted for over 2 hours. Has anyone else had this situation when testing devices in custom work?  
CUSTOM DEVICE HANDLER question for developers - I have an issue with getting state changes on a cust

1 Answer

+2 votes
by (580 points)
Update on this - I have performed testing and I think there’s a bit of a bug. The combination of IP and Port in a HEX format appears to be linked to the first instance of a device being used in our hubs. If I simply change the port on the device, it works. Otherwise, if I go back to the original port, it associates LAN messages with the deleted object. The quick answer is to not delete the object once created, unless you want to have to change the IP or port. I may end up emailing support to see if any developer can look at it, unless there’s one here.  
by (5k points)
I haven't done played with that sort of thing for a while but I don't recall ever encountering that problem, though I suppose it is possible I may have just continually updated the same device rather than deleting and creating them. It seems unlikely though. Indeed I can't recall ever seeing logging to a deleted device. I actually use the MAC as the DNI so I can receive unsolicited messages rather than just responses.  
by (580 points)
@navarro interesting results today. I am inclined to believe the incorrect association is fixed after 24 hours from the creation of the first usage of the network ID. I left the original DTH code alone overnight that was triggering on the deleted device. I check it this morning and it was successfully reporting to the current device. I changed my code to set the DNI to the MAC address to see if it would resolve the issue, and I was still receiving messages. As soon as I deleted the object and created another, the same problem appeared, even with MAC address. My conclusion: network IDs cannot be successfully reused for 24 hours when the handler needs to use the HubAction function.  
The SmartThings Group is where you can always find questions, answers, advice, reviews & recommendations from other community members about home automation with the Samsung SmartThings hub.
...