Question about creating and customizing device handlers from template


(Jihao Liu) #1

Hi,
I tried to create and customize device handlers from template. Everything seems OK. However, when I test the created device handlers in the online simulator, errors happened, as follows:

   According to the error, I modified the original code of device handlers. Although the error disappears, the device handler does not work when tested in the simulator.
   
   Does anyone know how to solve this?
   Thanks a lot.

(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #2

First rule: Never trust the simulator. It doesn’t work consistently; even sometimes for the most simple cases.

Second rule: If you’re asking for debugging help, please provide a GitHub or Gist link to the full code you are trying to debug. That way folks here can (A) see the problem in context, and (B) can paste the code into their own IDE to see if they trap the same error.


(Jihao Liu) #3

Thank you again. Actually, I have kept your advice in mind. I know the simulator can never be trust. However, I’m doing related security research. I have no other choice ( I have tried other methods)

As for my question, I just follow the instructions on the SmartThings github, create a device handlers (i.e., [Z-Wave Motion Sensor]), and create a virtual device (i.e., [My Motion Sensor] based on this device handlers. Then, I encountered this error, and the test on the device handlers does not work. If I tried to use the default virtual device (i.e., Virtual) in the simulator, I found that the device handler works normally and no this error. I don’t know why

My created device handlers (i.e., [Z-Wave Motion Sensor]) is as follows:


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #4

Very few Device Handlers are compatible with the Simulator. Most are not!

This one isn’t … there is no {simulator} data section.

The simulator is mostly for testing SmartApps … and barely that.


(Jihao Liu) #5

OK,I see. Recently, I try to reproduce the experiments of one paper. The author instrumented multiple device handlers, apps and logged some security related information through running the smartthings apps in simulator. That is the reason why I tried to do this.

Maybe, I should modify these device handlers one by one.

Thanks


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #6

Sure…

But keep in mind that any research you are doing is not valid if run in the simulator.

It doesn’t accurately simulate real devices, and thus any security issues found or not found are irrelevant.


(Jihao Liu) #7

OK, thanks for your advice.

By the way, there is indeed a {simulator} data section in my given device handlers.


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #8

You’re right… I overlooked it, sorry.

Not sure what exact research you’re doing; but also keep in mind that SmartThings has a completely new IDE and Device API in Beta, … so far it doesn’t even support local device types, but there’s hope for a new and better simulator.


(Jihao Liu) #9

Yes, I have tried the new IDE. It seems to be very nice and can run in local simulator. However, the Groovy language has been deprecated. Thus, it can not be used for the experiments of the paper I want to reproduce.