ive got 2 electric windows connected to a 230V-Contact-Actuator.
Im using 2 contacts of that Device (thing): one to open both windows and one to close both windows.
If i like to operate the windows, i need to set the corresponding signal (to open or to close) for about 30 seconds.
Ideally i would save the position somewhere as i dont have any hardware-contacts at these windows. But thats just a nice-to-have.
I found some logic and changed it a bit to fit my needs, but it doesnt work. For test i put only 5 seconds.
The plan is to check, if one of the 2 contacts (of my switch actuator) are set. If they are set, start a timer. If the timer has passed, reset the signal to avoid that one of the 2 switch-contacts are set too long (window runs about 20-25 Seconds per way).
Things:
Type switch : 1_1_12_Kanal_S_Schalten "Kanal S" [ ga="2/0/6+<2/0/8" ]
Type switch : 1_1_12_Kanal_T_Schalten "Kanal T" [ ga="2/0/7+<2/0/9" ]
I am at the very beginning of OpenHab, so not sure how i could use your code. Maybe you can precise it a bit more
But if i understand correct, i can add Items which are not linked to a thing?!
That would be like internal tags to set and reset (true/false) via rules?!
In that case, i could simulate the status opened/closed, but still i need to reset the order (order to close contact and “send” power to the windows) after 30 Seconds.
Switch dummy // define the label and all the rest as desired
Rule
rule "Trigger the window"
when
Item dummy received command ON
then
1OG_Wohnzimmer_Fenster_Oeffnen.sendCommand(ON)
createTimer(now.plusSeconds(25), [ | 1OG_Wohnzimmer_Fenster_Oeffnen.sendCommand(OFF)
end
So i will create a virtual ITEM -> switch (without {channel=“blabla”}) <- and ill put this virtual switch ITEM to my SITEMAP.
If i trigger that switch, it will start my timer and send an ON-Command to the “real” ITEM which is linked to a THING and will switch my KNX-Device.
After timer passed, it sends OFF-Command to the “real” ITEM and it will switch off the KNX-Device
What would be the way to only check the “real signal” of my KNX-Device regardless of who sent ON-Command?
I mean, to check the state of the ITEMS “1OG_Wohnzimmer_Fenster_Oeffnen” and “1OG_Wohnzimmer_Fenster_Schliessen” which both are connected to a THING (which represents my KNX-Device).
I would just have to change the rule like following or do i have to fulfil additional steps? Im asking because im quite sure i did exactly the following and it didnt work. But i didnt put the “|” in between the “[” and “1OG_” … what does it do?:
rule “Reset ON-Command after 25 Seconds”
when
Item 1OG_Wohnzimmer_Fenster_Oeffnen received command ON
then
createTimer(now.plusSeconds(25), [ | 1OG_Wohnzimmer_Fenster_Oeffnen.sendCommand(OFF)
end
Ok it seems that the rule isnt called at all. I put it into the “rules” folder and the name was knx.rules - i renamed to default.rules but nothing happens still. I dont see anything in the events.log
I also dont see anything regarding rules in paperui
When xxx.rules files are loaded you will see a message in openhab.log
This is different from events.log and you should be looking in both while developing.
It does have a function, it marks off the “lambda” - the block of code that is not to be run now, but later when the timer expires.
Please show us your current rule - the text you posted last does have the | but is missing a ]
It won’t work if you get the syntax wrong.
Most syntax errors get reported to you in openhab.log
Let’s worry about state when this part is working.
OK here you go - the following is a test-rule based on my other thread. Should fire each minute, didnt work. I changed to every 5 seconds - doesnt work still
Ill put this in the “default.rules”
rule “window demo”
when
Time cron “0/5 0 0 ? * * *” // each 5 seconds
then
if (myWindow.state==OPEN) {
myWindow.postUpdate(CLOSED)
}
end
I tried this with “if (myWindow == OPEN)” and “if (myWindow.state==OPEN)”
Openhab.log
2019-07-14 13:45:58.571 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘default.rules’
2019-07-14 13:47:26.435 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘default.rules’
2019-07-14 13:49:21.194 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘default.rules’
Which will never work, assuming myWindow is an Item, it can’t “be” OPEN because it is an object, with several properties like ‘name’, ‘label’, and of course ‘state’.
Okay, so does myWindow ever have the state OPEN?
If it does not, then your rule will run quite happily and make no visible effect. What makes you think it didn’t work?
You can add some diagnostic tell tales.
rule “window demo”
when
Time cron “0/5 0 0 ? * * *” // each 5 seconds
then
if (myWindow.state==OPEN) {
myWindow.postUpdate(CLOSED)
} else {
logInfo ("test" , "Wasn't expecting that " + myWindow.state.toString)
}
end
Can myWindow ever take up the state CLOSED? What type of Item is it?
I’m not sure what this new problem has to do with the rest of the thread.
This “new topic” is just a more simple test for rules because it looks like that rules are not working at all for me.
The Test-Item (for testing rules) is
Contact myWindow “Sample Window [%s]”
In Events ive found this
2019-07-14 13:24:01.218 [vent.ItemStateChangedEvent] - myWindow changed from NULL to OPEN
So i assume the state is now open. Thats what it displays on the sitemap
Even after using your rule, all i get in openhab.log is this
2019-07-14 15:22:05.671 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘default.rules’
2019-07-14 15:22:35.119 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘default.rules’
Ive also installed the experimental rule engine, but no change. I removed it again, no change.
I dont see anything about rules in paperui under configuration - should i?
This experimental feature has absolutely nothing to with “conventional” rules as found in xxx.rules files. Slow down, randomly doing things isn’t going to help at all.
Nope. PaperUI has absolutely no idea of anything to do with xxx.rules files.
“Who did that then” I wonder, it wasn’t spontaneous. Anyway, state should then persist until you boot, or reload any Items file.