Cycle Timer

I’m Android…

Paul

After you have added the app to the ide can you please try logging out of the smartthings app then logging in again?
It seems this might clear the error

No joy - But now I have 8 instances of it :slight_smile:

1 Like

@Paul_Haskins
Haha - I wish it was funny but it’s not
I would just delete them all
Unfortunately I don’t have an android to test on so I’m at a bit of a loss on where to go now unless someone else can try an ios device to see if this is just some kind of android incompatibility or something else
Unfortunately it works perfectly for me.
Searching the forum doesn’t show anything like this except that there habe been a few problems with the android smartthings app in the past

It creates two instances on my parents iPhone but I was able to delete one.

It works on their stuff, which is great because that’s where my system is at for the time being.

I just find it weird that an app that works on Android and iOS doesn’t have the same constituency within it’s own app.

@Shiznorak
Mike
at least you have it working and hopefully this will sort out your original problem.
I have NO idea why it didn’t render correctly on the android app or why it created multiple instances.
Nobody has ever mentioned this to me before

@Shiznorak @Paul_Haskins

Guys what version of the android app are you using (and what version of android os) ?

I think - 6.0 on one and - not sure on the other,

FWIW - know any way to even delete an app when it will not even start? Short of contacting support.

I was thinking to C&P some working code from another app, then delete.

Installed apps can be deleted either direct from the smartapp or (when it won’t display correctly :slight_smile: ) it can be done from the IDE
Once logged in > My Locations > List SmartApps (very bottom) > Click on Edit in the top right corner > Scroll to the bottom and uninstall the instances > Then click on DONE in the top right corner

Thanks - learned something - never even knew that was in there.

Android 7.1.1
Smartthings 2.4.1

@Shiznorak
Mike
Sorry it’s been a while but real life gets in the way sometimes :slight_smile:
I think the android problem might be related to an ‘enum’ command so I have rewritten this a bit to get around it.
Can you try this code please?

Code:

/**
 *  Cycle Switch Timer V1.2
 *
 *  Copyright 2017 Andrew Parker
 *
 *  The code for the days of the week is not mine - Unfortunately I cannot remember where it came from
 *	If this is your code please contact me so that I can credit you properly
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 */
 
 
definition(
    name: "Cycle Switch On Timer V1.2",
    namespace: "Cobra",
    author: "Andrew Parker",
    description: "Sets a switch on for a specified time then off for a specified time then on again... ",
    category: "My Apps",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
    iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")


preferences {
	 section("Which switch to enable/disable App") {
        input(name:"switch1", type: "capability.switch", required: false, multiple: true)
	}
    
    
     section("Which days to run") {
        input "days", "enum", title: "Select Days of the Week", required: true, multiple: true, options: ["Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sunday": "Sunday"]
    }
      
     section("Which switch to cycle...") {
        input(name:"switch2", type: "capability.switch", required: true, multiple: true)
	}
    section("How long to stay on") {
		input(name:"ondelay", type:"number", title: "Minutes", required: true,)
	}
    section("How long to stay off") {
		input(name:"offdelay", type:"number", title: "Minutes", required: true,)
	}
    

}


def installed() {
	log.debug "Installed with settings: ${settings}"

	initialize()
}

def updated() {
	log.debug "Updated with settings: ${settings}"

	unsubscribe()
	initialize()
}

def initialize() {
	 subscribe(switch1, "switch", switch1Handler)
     
    
}


// Config & actions

def switch1Handler(evt){
   state.currS1 = evt.value 
   log.trace " $switch1 is $state.currS1"
   if (state.currS1 != "off" ) {
   runswitchOnNow()
   }
    if (state.currS1 != "on" ) {
   switchOff()
}
}



def runswitchOnNow () {
if (state.currS1 != "off" ) {
 def df = new java.text.SimpleDateFormat("EEEE")
    
    df.setTimeZone(location.timeZone)
    def day = df.format(new Date())
    def dayCheck = days.contains(day)
    if (dayCheck) {


	log.debug "Cycling power on switch(es): $switch2 "
    def delay = 60 * ondelay as int
    switch2.on()
    log.debug "switch: $switch2 is on"
    log.debug " Waiting for ${delay} seconds before switching off"
 
    runIn(delay, switchOff)}
   
}
else {
 log.debug " Not today!"
 }
}



def switchOff (){
log.debug "Switching off"
switch2.off()
log.trace "$switch2 is now off"
switchbackOn()
}


def switchbackOn () {
 if (state.currS1 != "off" ) {
 def df = new java.text.SimpleDateFormat("EEEE")
    
    df.setTimeZone(location.timeZone)
    def day = df.format(new Date())
    def dayCheck1 = days.contains(day)
    if (dayCheck1) {


	log.debug "Turning on switch(es): $switch2 "
    def delay1 = 60 * offdelay as int
    log.debug " Waiting for ${delay1} seconds before switching on"
 
    runIn(delay1, switchOn)}
        
 else {
 log.debug " Not today!"
 }
}
}




def switchOn (){
log.trace "Switching back on"
runswitchOnNow ()

}

Please let me know how you get on

1 Like

I am able to get to the settings this time but when I hit save it comes up with “Error Saving Page.”

Getting closer :slight_smile:

Might be platform issues this time

https://status.smartthings.com

I tried again today and got the error saving message again

When you try to install could you have ‘live logging’ open in an ide browser and let me have any error messages it comes up with?

Hey Cobra, I installed 1.2 of this smartapp of yours today. Everything seems to install normally, setting the options in the app works fine, but the output does not come on. I have it set for 5 minutes on / 15 minutes off every day, on a GE outdoor outlet. The outlet works fine manually triggered in the app and I get no errors in any part of the process, nothing shows up in the live logging during publish or anything.

Any ideas where I can look to get this going? I have the same usage case as the OP, Aquaponics pump, just needs to cycle all the time.