Getting strange error adding modes

modes

(Glenn Brockett) #1

I am writing a snippet of code to run an exhaust fan when it’s cooler outside and above a certain temp inside. I want this to only run in selected modes. I understand that I just need to add a mode() statement to do this.

With the code in my preferences section:
section ("Active modes") { mode(title: "Set for specific mode(s)") }
I get the thrown error

grails.validation.ValidationException: Validation Error(s) occurred during save():

  • Field error in object ‘physicalgraph.app.InstalledSmartAppData’ on field ‘name’: rejected value []; codes [physicalgraph.app.InstalledSmartAppData.name.blank.error.physicalgraph.app.InstalledSmartAppData.name,physicalgraph.app.InstalledSmartAppData.name.blank.error.name,physicalgraph.app.InstalledSmartAppData.name.blank.error.java.lang.String,physicalgraph.app.InstalledSmartAppData.name.blank.error,installedSmartAppData.name.blank.error.physicalgraph.app.InstalledSmartAppData.name,installedSmartAppData.name.blank.error.name,installedSmartAppData.name.blank.error.java.lang.String,installedSmartAppData.name.blank.error,physicalgraph.app.InstalledSmartAppData.name.blank.physicalgraph.app.InstalledSmartAppData.name,physicalgraph.app.InstalledSmartAppData.name.blank.name,physicalgraph.app.InstalledSmartAppData.name.blank.java.lang.String,physicalgraph.app.InstalledSmartAppData.name.blank,installedSmartAppData.name.blank.physicalgraph.app.InstalledSmartAppData.name,installedSmartAppData.name.blank.name,installedSmartAppData.name.blank.java.lang.String,installedSmartAppData.name.blank,blank.physicalgraph.app.InstalledSmartAppData.name,blank.name,blank.java.lang.String,blank]; arguments [name,class physicalgraph.app.InstalledSmartAppData]; default message [{0} cannot be blank]

when I attempt to initialize the code in the simulator.

Is this just a problem in the simulator? Will it work fine in the smartapp anyway? Did I miss something in the docs for this?

If someone could point me at a prior topic or answer it for me that would be very helpful. I couldn’t find it using a search of the forum.


(Ben W) #2

I have the worse experience with the simulator.

I usually make the smartApp and install it and run it with actual devices.

There is a smartApp already in the marketplace for “Whole House Fan” that may meet your needs.


(Glenn Brockett) #3

I have tried it, but the app wouldn’t use a multi sensor as a thermal input IIRC. I only have one thermostat and it isn’t in the room I want to cool.


(Glenn Brockett) #4

I would do it with real world, except that I develop during slow times at work and don’t want to annoy the wife. I also use a compile/test/patch/compile… method of getting code out. It’s sloppy for development, but ends up teaching me better. (I have worked with Groovy for about 3 hours total and have a difficult time finding the API reference I need when I need it.)


(Ben W) #5

Here is the source for whole house fan, the majority of smartApps are open Source. Its a good starting point.

The IDE is limited, lacking alot of tools a real IDE has.

What device did not show up as an input? It uses the temperatureMeasurement input, so any device that has that capability should show up.


(Glenn Brockett) #6

I found the thermostat issue reading the “Whole House Fan” code. It uses thermostat for determining if it should run. I was trying to use mode to do the same thing. I have a thermostat now so it doesn’t much matter.

The point of my post was more in learning how to code the mode. Yes, I can just take the code and modify it, I was trying to learn.

So back to the original question: [quote=“Ac7ss, post:1, topic:55248”]
Is this just a problem in the simulator? Will it work fine in the smartapp anyway? Did I miss something in the docs for this?
[/quote]


(Ben W) #7

Is this happening whn you are trying to save or when you are trying to use the simulator? Like I said in my post the simulator sucks, but reading the message it seems to be the type when you save.

Is everything defined in the “definition” section? http://docs.smartthings.com/en/latest/smartapp-developers-guide/anatomy-and-life-cycle-of-a-smartapp.html#smartapp-structure

The best way to learn to code in ST is taking existing code and modify it. ST has quirks, and the IDE is limiting.


(Glenn Brockett) #8

When using the simulator. It saves fine.

I am going to have to find some code that uses modes to study. Any suggestions? (I have only had my setup for a week.)


(Ben W) #9

Looks like you are using it right, so I am not sure mode is tossing the error.

you can look at live logging and it may list where the error is happening while you are running the smartapp

Working From home smartApp uses mode, and its not too complicated.


(Glenn Brockett) #10

Thanks for the link, It is definitely the mode function, If I comment it out there is no error and it works fine.


(Glenn Brockett) #11

Looks like the problem is in the emulator: the snippet I needed was:

   section([mobileOnly:true]) { 
        label title: "Assign a name", required: false 
         mode title: "Set for specific mode(s)", required: false 
     } 

Since the programmer seemed to need the [mobileonly:true] section, it tells me that mode cannot be tested in the simulator.


(Glenn Brockett) #12

Ok, Finally got the app to publish onto my phone and discovered something.

The mode thing is on there by default! All this work for nothing.

Now to figure out the github thing.