Temp/level fade Looping over and over!


#1

1) Give a description of the problem
Bathroom lighting automation

Light temp and level fade ups (triggered by humidity) are executing partway and resetting: stopping at a random point and looping over and over again rather than just fading up and staying there. Stopping point seems to be tied to my motion sensor resetting to “inactive.”

New to ST (1 month) and webCore (2 weeks), so thanks for your patience with my clunky code. Please help. We have a new baby and my wife is losing patience quickly! She says I spend way too much time on smart home stuff :stuck_out_tongue_winking_eye::

2) What is the expected behavior?

When humidity is less than 65% (no shower), bathroom lights should turn on with motion to a specific level, temperature setting, and delayed turn off time following inactive motion-- with the aforementioned settings differing according specific to a time of day (“overnight,” morning, day, evening).

When humidity is greater than 65% (shower detected), light level should fade up from its current level (previously triggered by motion of entering the bathroom when humidity was lower) to 100% over two minutes. Following that (or ideally concurrently), the lights should fade up temperature from their previously triggered state from 2700k to 3300k. Motion (in)activated switch off becomes conditional on humidity dropping below 65%. Once humidity is below 65%, lights should turn off after 7 minutes after no motion is detected.

TL;DR
In other words, walk into the bathroom and lights come on at various settings and time out after a certain number of minutes depending on the time of day UNLESS a shower is detected, in which case light level and temp continue to fade up over a period of time and stay that way until humidity decreases and the bathroom is unoccupied.

3) What is happening/not happening?

  1. Lights behave as expected in low humidity conditions. In high humidity conditions, lights begin their level up fade, but make it anywhere from 78-95% before starting over at 30 again. When I reduced the allowed fade time, lights would make it to 100% and the temp fade up would similarly snag and “re-cycle.” Left going long enough, both temp and level would make it a ways, and then recycle from the beginning. The snag-reset cycle seems to be tied to my motion sensor resetting to or toggling from “inactive.”

  2. When commanded off by Alexa, lights turn off, then turn on again on their own if my motion sensor hasn’t reset to inactive. I think this is because I need to change the condition of the motion sensor from “is” active to “changes to” active?

  3. Lights (sengled, no hub) don’t act cleanly in unison. Minor and seemingly random lags rather than them all powering on and off smoothly in unison like my hue bulbs (with hub). It’s like the ST hub fires the command for each bulb sequentially rather than a group. Help?

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach any logs

Wasn’t sure which were relevant. I can dig through them if needed.

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

Hi @jdburke,
just a suggestion (going to bed so I did not look into your piston in detail, sorry about that)
but in my experience when using so many triggers and/or conditions in a single piston, i would avoid using ELSE… I would just go with IF statements only…
I am not a coder so I might be suggesting something extremely stupid here…
#2 For lights, usually the best way is, CHANGES TO ACTIVE and for turn off, STAYS INACTIVE for X amount of time…
#3 Yes some random lags do happen… I believe it’s due to zigbee signal??
Congrats with the new baby… And the wife problem, we are all having the same, you are not alone LOL
Here is how it is in our house:)

  • Ike I need more lights here after 8.00 pm
  • Ok love…(change the piston)
    next day
  • Ike too much light here after 8.00pm, why?
  • But…ok love… (change the piston)
    Next day
  • Ike…I need more lights here…Smart home sucks…
    LOL :joy::joy::joy::joy::joy::joy:

#3

Thanks. I’ll try plugging in the different motion states into the existing else if structure to see if that works for now. In the meantime, if anyone could offer a second opinion or take a look at my code, that would be great.


#4

Ok. Replaced the motion conditions. However, fade behavior is still somewhat erratic and seems to be tied to motion sensor activity. I’m guessing it’s the super convoluted and likely incorrect structure of my code…

Updated piston:


#5

Not sure I follow all your logic but, for example, as long as something keeps triggering this piston the first conditional would indicate that as long as the humidity is high and light is on, keep cycling from 2700 to 3300. If there is another trigger within the 3 minutes, it wills tart again going from 2700 to 3300. I think you need to check the current temperature of the light and cycle from there to 3300 or if already at 3300, then you don’t need to do anything. Make sense?


#6

That does make sense. I tested it this morning and it worked as expected until there was any motion. So I think part of the problem is my code structure. I’m a webcore newb of 2 weeks and just went forging ahead with this not totally understanding the differences between if, else, else than.

I think what I need to do is create two “If” branches:

First “if” will be high humidity, with the fade actions “only if” light temp is below 3300.

The second “IF” will be low humidity with multiple actions stipulating “only if” it’s a certain time of day and humidity is low.

Does that make sense or is there more correct/cleaner logic to this?

To recap, I want the lights to turn on with motion, and set specific levels, temps and auto-off delays based on time of day. UNLESS a shower (high humidity) is detected, in which case I want it to start following a fade-up of temp and level, stay there, and shut off only after humidity is low and motion ceases for a certain period.

Thanks again everyone. I got in over my head here as a newb. Starting a new job and new baby, and would pay someone to build this for me to be done with it if it weren’t probably against the spirit of learning and the community :stuck_out_tongue:. Appreciate the help.


#7

I think the logic you outline above will be better :grin:. Let us know if you need more help once you work it out.


#8

Success! Thanks for the tips.

As suggested, it was key to have the code check the light temp setting to prevent it from cycling over and over. Also helped to change motion triggers to “stays inactive” rather than “changes to inactive” with a wait period. Updated piston attached.


#9

:+1: