GHenry Posted February 16 Posted February 16 (edited) Eisy v5.8.0 I have a logic problem! A program sets a state variable to 0 or 1 depending on sunset and luminance. A second program turns lights on or off, depending on the value of that variable. It works very well on gloomy days…until 32 minutes before sunset, which was at 5:27 p.m. At 4:44 p.m. it correctly emailed me that “lux level dropped to 13 lux. Eisy turned on selected lights.” And then at 4:55 p.m. (35-3=32 minutes before sunset) it illogically emailed me that “lux level increased to 13 lux. Eisy turned off selected lights.” Lux level did not increase, and at 13 lux, Eisy should have turned lights on, not off. This happens frequently on gloomy (but not on bright) days. Obviously, I’m missing something here. Can someone please correct my logic? Den Low Lux 15 Variable - [ID 000A][Parent 001D] If From 8:05:00AM To Sunset - 35 minutes (same day) And 'Den Temp and Lux' Luminance <= 15 lux Then // Wait for both conditions to test Wait 3 minutes $Den_Low_Lux = 1 Else // Wait for both conditions to test Wait 3 minutes $Den_Low_Lux = 0 Den Low Lux 15 Send - [ID 0019][Parent 001D] If $Den_Low_Lux is 1 Then Set 'LR1' On Set 'LR2' On Set 'BR' On Set 'Bar' On Send Notification to 'Notification List' content 'Den Low Lux Email' Resource 'Den Low Lux Message' Wait 15 minutes // …to prevent rapid switching Else Set 'LR1' Off Set 'LR2' Off Set 'BR' Off Set 'Bar' Off Send Notification to 'Notification List' content 'Den Low Lux Ended Email' Resource 'Den Low Lux Ended Message' Wait 15 minutes // …to prevent rapid switching Edited February 16 by GHenry formatting
gviliunas Posted February 16 Posted February 16 (edited) I fixed this problem by splitting the first program into 2. One program detects dark as <= 15 lux while the second program detects light as > 25 lux. (And removing any Else clauses) For me, this prevented the little cloud rolling by near sunset from causing the it's-dark....wait no it's light flip-flopping. Edited February 16 by gviliunas 1
Solution dbwarner5 Posted February 16 Solution Posted February 16 I think your programs are running correctly, just the logic is wrong, @gviliunas points out the easist way to fix. What is happening is that at sunset -35 minutes, the first program goes false, running the ELSE. So 3 minutes go by and then the lux variable changes to 0. This triggers the ELSE in the second program which turns off the lights, regardless of what the LUX value actually is, because the variable turned to 0 in the first program. It seems like you expect the lux value to overrule the time condition, which wont happen. If either are false, the first program will turn false due to the AND. After you think thru this a bit, feel free to post your changes and others can comment if you are still having problems accomplishing what you want. 1
GHenry Posted February 16 Author Posted February 16 Wow, thank you both! Sometimes the obvious solution isn't quite the best solution. 1
Recommended Posts