-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rules: IF ELSE ELSEIF and AND OR Support #188
Comments
HI, I should have included this information
Thanks |
Hi, I think it is this bug 6405. The "shutter unknown" message confused me. I tried again in 6.6.0 standard and get the same behaviour. When using shutter/window in this configuration I'm not sure I can user most of the shutter code because any movement needs to check with the state of the "interlocked" shutter/window. It may be this is a RFE. |
Please can you use. shutteropen or shutterclose as a command in the rule instead of power on. This makes it more easy. Also please confirm that the shutter operates normal in all other conditions. |
I just read through the 6405. Please let me know, if this is fixed in the original branch. The. I can sync mine again. |
Hi, It's fixed with this one. https://github.com/arendst/Sonoff-Tasmota/pull/6406/files If you could patch the code that would be fantastic. I've been building the logic on the standard dev branch. I did try to see if I could add the patch but I don't have enough understanding. I would prefer to use the shutter functionality. Thanks |
This what I wrote on the latest release of the standard development code and it works. It would be alot easier / better solution if I could run it on your shutter code. The way it is, it has to complete a cycle before you can stop or reverse it. ie if there is something obstruction, you can't stop it completing a close cycle from the inputs once initiated. Shutters arrive Friday, windows are already working on the stefanbode shutter code. mem1 0/1 Shutter1 Open/Closed (Awning Window) rule1 rule2 rule3 |
Please check it out, if it now works for you |
Hi, I have really a hard time to guess what your rules are doing. Anyhow some comments. The power commands could be replaced with shutteropen, shutterclose and shutterstop. more easy to read and save some memory. Interesting: I was not aware than event#shutteropen1 is working. |
HI, Thankyou so much for the prompt response. I would like to be able to contribute more to sofware coding, I have hardware fabrication cability facility. If you ever want a custom switch built I can do that. In fact I am thinking of doing an 8 channel dry relay based on ESP-WROOM2, maybe an input chip for say 12 inputs on a header to take care of open/stop/close per shutter. If only I didn't have to work all the time.. A couple of things
Did you put the defines in user_config_override.h #define USE_EXPRESSION // Add support for expression evaluation in rules (+3k2 code, +64 bytes mem)
So logic just adds 2 conditions. i) Command window open, is window closed, is shutter closed >> open shutter then open window else is window closed, open window ii) Command shutter close, is window open, is shutter open >> close window then close shutter else is shutter closed, close window Yes I very much want to use the shutteropen/close commands and the shutter position capability of your code. At the moment I'm just using rule timers and variables in rules with standard code. Yours will make those rules much simpler and easier to read/debug. To fully utilise your code with the use case I think it may not be possible with rules, I'm going to give it ago. Any close shutter movement needs check if the window is closed and if not close window fully before moving. Any window open movement needs to check the shutter is fully open if not open it fully before moving. It needs to maintain shutter positions through a reboot. Thanks again, awesome code. |
maybe the script is a solution for it I recently added sht[ to get the actual position of a shutter and you can use "=> shutteropen" to move the shutter. This change will be part of the merge process. |
I think that will be perfect. I'm really happy with the window/shutter setup I have used. It's just really clunky doing the programming without the shutter code. I've done everything in 24Vdc so I can use on the Bathroom Window and I have "open" for everything incase of fire. I'd like to add a wiki article, not sure how? I edit in a version of my repository cloned from the latest version and then it's a pull-request?? I'm happy to contribute if it helps others. I think there should be more on the 24V systems, they are a lot safer in case of fire/power and the DC simu roller shutter motors are noticeably faster (more noise as well). The Shutter company says they last longer as well. Thanks rule1 rule2 rule3 |
Maybe I'm just to dump for your rules. Why do you change power1 and power2 when the event is shutteropen1 or shutterclose1. The shutterprogramm takes care to operate for the relays. keep away your fingers. |
You wrote: Any window open movement needs to check the shutter is fully open if not open it fully before moving._ |
I was never able to compile the shutter code with the IF/ELSE bug fix. Th error is in the thread. I really really want to use on event#SHUTTEROPEN1 do shutteropen2. drv_10_rules line 1550 (full error in thread above) with #define USE_EXPRESSION // Add support for expression evaluation in rules (+3k2 code, +64 bytes mem) I couldn't work it out. Thanks |
do you have disabled rules? this is mandatory |
I just try to compile and see the same error if the SUPPORT_IF_STATEMENT is enabled. I check with the original ode, but maybe this is an error in the main code. not the shutter code |
Main code is working, I'm running it. I'm running a window and a shutter together. You might think of it as half the same logic required as the relay interlock to stop a short circuit. shutter1=window window must be fully shut before moving shutter, shutter must be fully open before moving window. Otherwise they collied The picture shows 2x Windows 2x Shutters |
Ohh, this is a very nasty situation. And not easy to solve. |
:) It's not that bad, the rules I'm using work and if you can merge to the main code 90% will be done. It would be a lot more slick if we could add an Interlock between shutter1/2 but it will give me most of what I need with the if/else rules and shutter code function as is. I really should have limit switch inputs for closed loop control. I kinda built it and then realised, open loop is OK. |
Ok, with the recent update it compiles and yes there where many changes required to get the IF THEN ELSE into the rules. Additionally, there is a project ongoing to merge the code for the shutter into the main branch during the next week hopefully. |
I've literally reloading a 4ch Pro, will stop and try your code ! |
2 issues.
If you go back to TasmotaSerial-2.3.3 it compiles and this is coming from the master on theo branch. I have to revert back on the master compile as well.
It seem to be restarting alot as well. I have gone back to master and everything is compiling/config hold so it's not hardware. Thanks -I/Users/paulfish/Documents/Arduino/libraries/TasmotaSerial-2.4.0/src" "-I/Users/paulfish/Documents/Arduino/libraries/TasmotaModbus-1.2.0/src" "-I/Users/paulfish/Documents/Arduino/libraries/NewPing-1.9.1/src" "/Users/paulfish/Documents/Arduino/libraries/TasmotaSerial-2.4.0/src/TasmotaSerial.cpp" -o "/var/folders/sv/s1hvytg927x34vtyhkrhs3sh0000gn/T/arduino_build_416404/libraries/TasmotaSerial-2.4.0/TasmotaSerial.cpp.o" |
It's working!! I haven't tested on Theo's repository yet. I'm wondering if it is possible to reference the shutter position in the if statement?? At moment I'm setting Mem1 / Mem2 at the end of Open/Close cycle trigger. rule1 rule2 |
BUG DESCRIPTION
Hi, I've compiled with the following
#define USE_EXPRESSION // Add support for expression evaluation in rules (+3k2 code, +64 bytes mem)
#define SUPPORT_IF_STATEMENT // Add support for IF statement in rules (+4k2 code, -332 bytes mem)
I've tried the most basic rules.
20:23:19 MQT: stat/------/house/bathroom/RESULT = {"Rule1":"ON","Once":"OFF","StopOnError":"OFF","Free":427,"Rules":"on system#boot do var1 0 endon on POWER1#STATE do if (var1!=1) power3 on endif endon"}
20:23:24 CMD: power1 on
20:23:24 Wait for Motorstop 500
20:23:25 MQT: stat/my/house/bathroom/RESULT = {"POWER1":"ON"}
20:23:25 MQT: stat/my/house/bathroom/POWER1 = ON
20:23:25 RUL: POWER1#STATE performs "if (var1!=1) power3 on endif"
20:23:25 Shutter unknown
REQUESTED INFORMATION
Make sure these boxes are checked before submitting your issue. Thank you
FAILURE TO COMPLETE THE REQUESTED INFORMATION WILL RESULT IN YOUR ISSUE BEING CLOSED
status 0
:(Please use
weblog 4
for more debug information)TO REPRODUCE
Steps to reproduce the behavior:
rule1 on system#boot do var1 0 endon on POWER1#STATE do if (var1!=1) power3 on endif endon
power1 on
EXPECTED BEHAVIOUR
A clear and concise description of what you expected to happen.
if statement should be processed in rule, power3 should turn on
SCREENSHOTS
If applicable, add screenshots to help explain your problem.
ADDITIONAL CONTEXT
Add any other context about the problem here.
I'm using a 4ch-pro R1 with a shutter (shutter-2) and an awning window (shutter-1), which also has an actuator on it.
I need to build logic such that
command window open (shutter-1), checks to see "if" shutter is open (shutter-2), then open window (shutter-1), elseif open shutter (shutter-2), then open window (shutter-1).
command shutter close )shutter-2) checks to see "if" window is closed (shutter-1), then close shutter (shutter-2), elseif close window (shutter-1), then close shutter (shutter-2).
I"m not sure if there is a way to do this without the IF ELSE ELSEIF and AND OR Support, I was thinking I might be able to build it with the break statement, if I can't get it to work.
First time running up the code today, very impressed. I did it on 4ch ProR1 and DualR2. Everything else has been excellent.
The documentation was good, very easy to implement.
(Please, remember to close the issue when the problem has been addressed)
The text was updated successfully, but these errors were encountered: