Jump to content

Simple Christmas tree light issue


bw23198
Go to solution Solved by MrBill,

Recommended Posts

This should be a relatively easy task to accomplish but for some reason I'm struggling.  My Christmas tree has 2 strands of lights; each connected to a separate Kasa wifi outlet.  One is colored and the other is white.  I can control each strand through ISY just fine (using a node server).  My issue is with programming them on a timer.  

I would like to alternate colored lights vs. white lights every 15min from 19:00 until 03:00 the next morning.  I've created 2 programs to accomplish this as follows.  

The first program should take care of the timing.  ($s.Christmas is a state variable that is set to 1 at 19:00 and then set to 0 at 03:00 the next morning.)

Schedule tree - [ID 00C8][Parent 00EF]

If
        $s.Christmas is 1
 
Then
        Wait  15 minutes 
        Run Program 'Alternate Christmas Tree' (If)
        Run Program 'Schedule tree' (If)
 
Else
   - No Actions - (To add one, press 'Action')
 

The second program alternates the lights.

Alternate Christmas Tree - [ID 00C2][Parent 00EF]

If
        'Kasa Controller / Color Christmas tree lights' Status is On
 
Then
        Set 'Kasa Controller / White Christmas tree lights' On
        Set 'Kasa Controller / Color Christmas tree lights' Off
 
Else
        Set 'Kasa Controller / Color Christmas tree lights' On
        Set 'Kasa Controller / White Christmas tree lights' Off
 

 

The problem is that the lights alternate every 30s or so.  Additionally, this continues even after $s.Christmas is set to 0.  What am I doing wrong here?

-Brian

Link to comment
  • Solution

This should do what you want to do....

Schedule tree - [ID 00C8][Parent 00EF]

If
       From 7:00:00 PM
      to  03:00:00 AM (next day)
 
Then
     Enable Program Alternate Christmas Tree
     $s.Christmas = 1
 
Else
     Disable Program Alternate Christmas Tree
     $s.Christmas = -1
     Set 'Kasa Controller / Color Christmas tree lights' Off
     Set 'Kasa Controller / White Christmas tree lights' Off
       

Alternate Christmas Tree - [ID 00C2][Parent 00EF]

If
        $s.Christmas is 1
 
Then
        Set 'Kasa Controller / White Christmas tree lights' On
        Set 'Kasa Controller / Color Christmas tree lights' Off
        Wait 15 Min
        $s.Christmas = 0

Else
        Set 'Kasa Controller / Color Christmas tree lights' On
        Set 'Kasa Controller / White Christmas tree lights' Off
        Wait 15 Min
        $s.Christmas = 1

Disclaimer:  I didn't test it, If you have problems I'll set it up here and see where it goes wrong.

Edited by MrBill
  • Like 2
Link to comment
11 hours ago, bw23198 said:

The problem is that the lights alternate every 30s or so.  Additionally, this continues even after $s.Christmas is set to 0.  What am I doing wrong here?

I'm actually surprised it takes 30 seconds to alternate.  Your second program checks the status of the Color Christmas Tree Lights and then changes that status.  If they're on, it turns them off.  If they're off, it turns them on.  But when you turn them on, or off, you cause the IF of the second program to execute again.  So you've created a runaway program that runs the THEN, followed by the ELSE, followed by the THEN, followed by the ELSE into infinity.

  • Like 1
Link to comment
10 hours ago, kclenden said:

I'm actually surprised it takes 30 seconds to alternate.  Your second program checks the status of the Color Christmas Tree Lights and then changes that status.  If they're on, it turns them off.  If they're off, it turns them on.  But when you turn them on, or off, you cause the IF of the second program to execute again.  So you've created a runaway program that runs the THEN, followed by the ELSE, followed by the THEN, followed by the ELSE into infinity.

I wondered that too.  I gave up trying to figure out why OPs original was behaving and just re-wrote it.  Only thing is Kasa are Node server driven and i think it takes awhile for the node status to update sometimes, probably more when the queue is flooded.

  • Like 1
Link to comment
Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Forum Statistics

    • Total Topics
      36.5k
    • Total Posts
      367.7k
×
×
  • Create New...