Getting strange error adding modes

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 ‘’ on field ‘name’: rejected value []; codes [,,,,,,,,,,,,,,,,,,,blank]; arguments [name,class]; 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.

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.

1 Like

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.

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.)

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.

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?

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?

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

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.)

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.

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

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.

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.

1 Like