It used to be possible to set deviceNetworkId in the device handler programmatically like this:
device.deviceNetworkId = 'C0A80165:0050'
A lot of custom TCP/IP devices relied on this functionality, including WiFi thermostats, network cameras, VLC Things, etc. Then, at some point during infamous infrastructure upgrade, this stopped working, i.e. I can write to device.deviceNetworkId and read it back and it appears correct, but the actual deviceNetworkId value as displayed in the IDE does not change and HTTP responses are not routed to the device handler.
Can someone from ST engineering comment on this please?
I just tried to reproduce your issue with my roomba devicetype, and i am unable to. I can change ipaddress and/or port and my deviceNetworkId changes with it.
Here is a link to my code, to see how i handle it. see ipSetup(). Let me know if you need more help debugging your issue. https://raw.githubusercontent.com/sidjohn1/smartthings/master/ThinkingCleaner.groovy
Quick note here, DNI shouldnât change! You shouldnât be using IP address as DNI instead you should use something unique that doesnât change like MAC address.
Changing DNI only generates instability and this has been the problem with HUE, Wemo, etc.
We are switching to MAC address in all this devices to improve stability and reliability.
If that didnât convince you the function to change DNI is device.setDeviceNetworkId("${newDNI}")
Now itâs totally not working. I uninstalled and re-install the device. I gave it a âfakeâ network ID â12345â when adding a new device and itâs still showing â12345â in the IDE after I configured it with the real IP address and TCP port.
11:26:26 AM PDT: info VLC Thing. Version 1.2.0 (06/28/2015). Copyright (c) 2014 Statusbits.com
11:26:26 AM PDT: trace VLC Thing updated with settings: [âconfIpAddrâ:â192.168.1.118â, âconfTcpPortâ:8080, âconfPasswordâ:â*******â]
11:26:26 AM PDT: trace setNetworkId(192.168.1.118, 8080)
11:26:26 AM PDT: trace deviceNetworkId: C0A80176:1F90
Now, after refresh:
11:38:16 AM PDT: trace refresh()
11:38:16 AM PDT: trace deviceNetworkId: 12345
Is there a way to grab the MAC address and populate automatically DeviceNetworkId, or does that require the user to look it up and type it in correctly?
That depends on how you discover the device. For LAN devices we use UPNP to discover and then we can request the value. If you are hard coding you might need to type it manually.
You can also create a unique DNI but I strongly recommend not to change the value.
If you need to store IP and port you should use something else like a data value.
Appreciate the tip, but itâs not working either. Same behavior: when reading back the value immediately after setting, it returns the correct value, but reading it again from a different command handler (e.g. refresh), returns the old value. This is exactly the same issue that was reported in Dec. 2014 and was âfixedâ in January.
Thanks for the heads up. I will escalate this ASAP but please consider using static DNI. You should be able to store the IP in a data value and request it from there.
Thank you!. However I donât quite understand how âstatic DNIâ is supposed to work. Currently, deviceNetworkId for LAN devices is in the <HEX_IP>:<HEX_PORT> format. This is used for routing IP responses back to the device. I cannot just use a random number can I? So the network ID is not known when I create a new device in the IDE, but I need to input some network ID just to be able to add a device.
Also, with regards to using MAC address as a network ID, wouldnât it mean that you can only have one Smart Device per MAC address? Currently, I can have multiple devices running on the same host, as long as they have different TCP ports.
P.S.
I contacted support:
[SmartThings Support] Support request #112933: Device unable to set its device network Id (DNI)