anacommsystems Posted November 22, 2022 Share Posted November 22, 2022 I'm working on an occupancy sensor setup with my kitchen. I've had this running for years with HA, but moving to C4, I cannot seem to make this work. Hardware: Motion Sensor; shelly dimmer in kitchen dining light ; shelly 1pm in kitchen vent hood So what i'm trying to accomplish is turning on the light via the motion sensor, and if the 1pm is not drawing current, delay 2 mins and turn off the light. If there is a current draw from the hood, keep the light on until the draw goes away, then wait two mins and turn the light off. The reason for that is if i'm cooking the hood is on, and if i'm sitting down at the table and the hood is on, my lights won't cut off on my if theres no motion but i'm still in the room. Its worked great for years, but I just can't seem to get the C4 programming correct. I've tried it with variables and timers but nothing seems to work. any help would be greatly appreciated Quote Link to comment Share on other sites More sharing options...
cnicholson Posted November 22, 2022 Share Posted November 22, 2022 So it sounds like you want light to turn on if (Motion) OR (Fan) and turn off when (No Motion for 2 mins) AND (No Fan for 2 Mins). There may be a more elegant solution, but i would set up two booleans RecentMotion and RecentFan. When Motion event fires, set the RecentMotion boolean to true, turn on the light and set a timer with 2 min duration. Ditto for Fan on event. On expiration of Motion timer, set Recent Motion to false and, if RecentFan also false, turn off the light. Ditto for expiration of fan timer, although I guess you would want to check to see if the fan is still on and, if so, do not set RecentFan to false, do not turn off the light, and reset the timer to 2 mins. The motion should take care of itself because every motion event will put 2 mins back on the clock (since you will program it that way). I guess you could drive the Fan portion off a change of state of fan load, but using timers takes care of the 'how long since fan was last on?" logic. By checking every two mins, you'll never be too far off. To do it off change in fan load, when Fan changes to ON, set RecentFan to TRUE. On FanOff, set two min timer. At expiration of that timer, if fan still off, set RecentFan to FALSE and if RecentMotion also FALSE, turn off the light. Maybe this is better. An edge case maybe you want to take care of is: if you manually turn on the light and walk into kitchen and turn on the fan (or not), do you want light to turn off after two mins? You could set another Boolean, ManualLightOn, drive it off of key presses and add in this logic. Quote Link to comment Share on other sites More sharing options...
Cyknight Posted November 22, 2022 Share Posted November 22, 2022 WHEN motion stops sensing motion restart 2 min time WHEN fan turns off restart 2 min timer WHEN 2 min timer expires IF fan is off turn off light. Nothing more should be needed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.