I've got a script that does the following:
1. Stops an animation that is already running (stops animation named "Alert - Red")
2. Starts a second animation (starts animation named "Alert - Cyan")
When the second animation ("Alert - Cyan" animation) finishes running in a minute, the lights do not revert to their original settings (i.e. the settings that were in effect prior to the 1st animation started running). Instead, the lights revert to the 1st animation's settings. For example, if the lights were Off before the 1st animation ("Alert - Red") started running, the lights don't turn back off when the second animation ("Alert - Cyan") finishes. Instead, the lights revert to the 1st animation's settings (so the lights turn Red instead of turning off).
It seems that there is some sort of timing issue? If I only stop an animation (using StopAnimation plug-in call) and I don't start another one, then the lights revert back to their original settings. Or, if an animation ends by itself (after elapsed wait time), then the lights revert back to their original settings. But, if I StopAnimation and then immediately StartAnimation, when the new animation finishes, the lights revert back to the settings of the 1st animation and not the original settings prior to the 1st animation running.
Here is the code in my script:
oldAnimation = "Alert - Red"
rc = CBool(hs.PluginFunction("JowiHue", "", "StopAnimation", {oldAnimation}))
If (rc = False) Then
hs.WriteLog("Error", FuncName & ": 5. StopAnimation failed for " & oldAnimation)
Else
hs.WriteLog("Info", FuncName & ": 5. StopAnimation successful for " & oldAnimation)
End If
targetAnimation = "Alert - Cyan"
rc = CBool(hs.PluginFunction("JowiHue", "", "StartAnimation", {targetAnimation, Nothing}))
If (rc = False) Then
hs.WriteLog("Error", FuncName & ": 5. StartAnimation failed for " & targetAnimation)
Else
hs.WriteLog("Info", FuncName & ": 5. StartAnimation successful for " & targetAnimation)
End If
Below is from the HomeSeer Log (listed in reverse-chronological order):
As the code and the logs show above, the script does StopAnimation on the "Alert - Red" first, and then does StartAnimation on "Alert - Cyan". But the JowiHue log entries seem to show that "Alert - Cyan" starts before "Alert - Red" finishes? Anyway, when "Alert - Cyan" finishes (after about a minute), instead of the lights reverting to their original settings (i.e. their settings before "Alert - Red" started running), the lights revert to the settings done by the "Alert - Red" animation. What I really want is for the lights to revert back to the settings that they had before "Alert - Red" (and not turn Red).
Is the issue because the StopAnimation and StartAnimation plug-in calls are not synchronous so there's some sort of timing issue going on? Any suggestions on settings or code changes if I want to stop one animation and start another one in the same script but I want the lights to revert to their original settings prior to the 1st animation started running?
Below are the animation definitions:
Below are the scenes used by the animations:
Below are the presets used by the scenes ("Alert Preset - Cyan" and "Colorful - Red"):
1. Stops an animation that is already running (stops animation named "Alert - Red")
2. Starts a second animation (starts animation named "Alert - Cyan")
When the second animation ("Alert - Cyan" animation) finishes running in a minute, the lights do not revert to their original settings (i.e. the settings that were in effect prior to the 1st animation started running). Instead, the lights revert to the 1st animation's settings. For example, if the lights were Off before the 1st animation ("Alert - Red") started running, the lights don't turn back off when the second animation ("Alert - Cyan") finishes. Instead, the lights revert to the 1st animation's settings (so the lights turn Red instead of turning off).
It seems that there is some sort of timing issue? If I only stop an animation (using StopAnimation plug-in call) and I don't start another one, then the lights revert back to their original settings. Or, if an animation ends by itself (after elapsed wait time), then the lights revert back to their original settings. But, if I StopAnimation and then immediately StartAnimation, when the new animation finishes, the lights revert back to the settings of the 1st animation and not the original settings prior to the 1st animation running.
Here is the code in my script:
oldAnimation = "Alert - Red"
rc = CBool(hs.PluginFunction("JowiHue", "", "StopAnimation", {oldAnimation}))
If (rc = False) Then
hs.WriteLog("Error", FuncName & ": 5. StopAnimation failed for " & oldAnimation)
Else
hs.WriteLog("Info", FuncName & ": 5. StopAnimation successful for " & oldAnimation)
End If
targetAnimation = "Alert - Cyan"
rc = CBool(hs.PluginFunction("JowiHue", "", "StartAnimation", {targetAnimation, Nothing}))
If (rc = False) Then
hs.WriteLog("Error", FuncName & ": 5. StartAnimation failed for " & targetAnimation)
Else
hs.WriteLog("Info", FuncName & ": 5. StartAnimation successful for " & targetAnimation)
End If
Below is from the HomeSeer Log (listed in reverse-chronological order):
Mar-24 10:49:40 AM | JowiHue | Animation Alert - Cyan Finished |
Mar-24 10:48:40 AM | JowiHue | Animation Alert - Red Finished |
Mar-24 10:48:38 AM | JowiHue | Start of animation Alert - Cyan |
Mar-24 10:48:38 AM | Info | UpdateHueLights: 5. StartAnimation successful for Alert - Cyan |
Mar-24 10:48:38 AM | Info | UpdateHueLights: 5. StopAnimation successful for Alert - Red |
Is the issue because the StopAnimation and StartAnimation plug-in calls are not synchronous so there's some sort of timing issue going on? Any suggestions on settings or code changes if I want to stop one animation and start another one in the same script but I want the lights to revert to their original settings prior to the 1st animation started running?
Below are the animation definitions:
Below are the scenes used by the animations:
Below are the presets used by the scenes ("Alert Preset - Cyan" and "Colorful - Red"):
Comment