Nursery Automation Switch (dim/bright) Trouble Shooting


#1

1) Give a description of the problem

In our nursery, I have a single light, a two-button aqara switch, and a a motion detector. The idea is that our baby takes naps at various times of the day and night. I’m trying to set up a situation where our lights can be controlled by the switch, as well as set the lighting automation to either an “awake” or “asleep” mode. Asleep mode would be dim automation, Awake mode would level based on changing lux readings from the motion detector. This is so we can keep our lights automated, but be able to manually control both current and automated lighting levels, regardless of time of day.

I have one piston that handles the on/off and mode setting functions (flips a “mode” switch), and another that handles the motion automation based on mode (reads the “mode” switch). Probably an unnecessarily complicated setup. Open to suggestions

2) What is the expected behavior?

So… I want to be able to use the left button to:

  • with a single click (“button 1” in WC) turn lights ON to 100% either from OFF, or from ON and any level under 100%. If the light is already on at 100%, the single click will turn it off.
  • with a double click (“button 4” in WC) turn lights ON to 100% and flip the “nursery mode” switch to ON (“awake” mode)

With the right button:

  • single click (button 2 in WC) turn lights on to 1% either from OFF, or from ON and any level above 1%. If the light is already at 1%, the single click will turn it off.
  • with a double click (“button 5” in WC) turn lights on to 1% and flip the “nursery mode” switch to OFF (“asleep” mode)

If in “awake” mode, motion will turn on lights and set level based on changing lux settings and time out after 8 minutes. If in “asleep” mode, motion will turn on lights to 1% and time out at 6 minutes.

3) What is happening/not happening?
Bolded items are malfunctioning:

So… I want to be able to use the left button to:

  • with a single click (“button 1” in WC) turn lights ON to 100% either from OFF, or ON and any level under 100%. If the light is already on at 100%, the single click will turn it off.
  • with a double click (“button 4” in WC) turn lights ON to 100% and flip the “nursery mode” switch to ON (“awake” mode)

With the right button:

  • single click (button 2 in WC) turn lights on to 1% either from OFF, or from ON and any level above 1%. If the light is already at 1%, the single click will turn it off.
  • with a double click (“button 5” in WC) turn lights on to 1% and flip the “nursery mode” switch to OFF (“asleep” mode)

If in “awake” mode, motion will turn on lights and set level based on lux settings and time out after 8 minutes. If in “asleep” mode, motion will turn on lights to 1% and time out at 6 minutes.

Basically, when lights are supposed to come ON at 1% with the light OFF- either manually with a single click or from the motion sensor- they instead come on at 100%. If the light is already on, it behaves in response to the switch as expected

4) Post a Green Snapshot of the pistonimage
Switch and mode setting piston:

Motion-activation piston:

**5) Attach any logs (From
(PASTE YOUR LOGS HERE BETWEEN THE MARKS THEN HIGHLIGHT ALL OF THE LOGS SND CLICK ON THE </> ICON TO FORMAT THEM)

Can provide logs on request. I’m guessing the issue is my poor coding and code structure…


#2

I’ve looked at the logs and the odd thing is, webcore is sending the correct level commands to the light, but it’s still leveling at 100%. Could it be a problem with my DTH for the dimmer switch I’m using?


#3

You currently have buttons 1 & 2 both set as as a double trigger. I would reduce them to a single trigger each like this:

IF Button 1 gets pushed
Then
    IF Light is 100%
        Then Turn off light
        ELSE Set level to 100%
    END IF
END IF

IF Button 2 gets pushed
Then
    IF Light is 1%
        Then Turn off light
        ELSE Set level to 1%
    END IF
END IF

As a general rule of thumb, I rarely use ELSE unless there is only a single Condition above it. So for example, your two ELSE’s in piston “y5nd” has multiple conditions tied to it, so it may run at unexpected times.

  • Lines 32-45 is reacting to lines 18-23
  • Lines 62-75 is reacting to lines 48-53

Concerning this:

it is worth mentioning that most bulbs will turn on at the same levels they were left at when last turned off. (if the lights are 100% bright, and then turned off, a future command to set level to 1% will briefly come on at 100% for a moment before lowering to 1%)