When I create a new virtaul device or add a new physical device. The DHT file can be correctly apply to the device. But when I modify the DHT file and reapply it, the device cannot be refreshed correctly.
In order to verify the effect of the modification, I had to create a large number of virtual devices. This is a very inefficient practice, isn't it?
How to apply my DHT file to the physical device immediately and correctly?
You’ll be interested in this thread…
What you’re describing sounds like the ‘caching issue’ for custom presentations described there.
Yeah,But how to deal with the trouble? It has troubled me for a long time, making my development efficiency very low.
You’ll also need to install a library to communicate with the DHT sensor. To make sure you’ve installed eveything correctly, iMessage we’re going to test that we can read values from the DHT sensor connected to your device. Create a new file called dht_simpletest.py with nano or your favorite text editor and put.
I’ve found that even creating a new device isn’t a guarantee of picking up all changes to DTHs. Changes in the code yes (that shouldn’t really even need a new device), but changes to metadata like the ‘vid’ no. I now create new DTHs when I need to make modifications.
Yes, I found this too. I have two DTHs files, except that the value of the name field in the definition is different, the others have been changed to the same, but the effect that takes effect to the device is different. The latter file has to be created in order to get the correct effect.
There are some things you need to consider:
- The DTH is cached as mentioned before, to force the update, you need to create the new DTH, using a different name is very important.
- As I understand, you have several DTHs with the same name, I suggest you avoid that, mainly because:
a. When you don’t create a custom VID and use only standard capabilities, a default device presentation is generated when it is installed, it’s named based on the DTH, eg. “SmartThings-smartthings-dth_name” - When you already installed the device and want to change only its handler, you can follow these steps:
a. Close the ST mobile app.
b. Create the new DTH and assign it to the device.
c. Clear the mobile app cache (Android only, mobile device settings > apps > storage).
d. Open the mobile app again.
You can always verify which presentation is exactly used by the device by making a query to the /presentation endpoint and using the complete parameters: presentationId
, manufacturerName
and deviceId
.