Rules that use but only if it is a weekend or weekday do not work

Over the past few weeks I have been running 2 rules to test the weekend and weekday but only if option selected.

Screenshot from 2021-03-08 08-33-42

I asked another OH3 user to do the same test rules and he had the same results.

Conclusion: If I create the rules on a weekday then the weekday will run all the time. If I create the rules on a weekend then the weekend rule will run all the time.

Is anyone else using the only if it is weekday option?

Is my rule wrong?

My test etc from previous forum entries are here:

Please don’t double- or triple-post new threads on the same topic. That’s bad forum etiquette, and it’s really confusing for anyone who wants to contribute to the discussion. It means that we have to read all of the posts (which are repetitive), and then put it all together before answering your many questions. And after all of that, which of your three posts would you have us respond to?

I get that you’re frustrated by this, and you’re trying to bump it up for visibility. The way to do that is to add new posts to your original thread and build on your earlier findings, not to keep editing your posts and then creating new threads every few days. It may also help to reduce how many questions you ask, so that it’s easier to focus on solving the problem. Show us what you’ve done in a way that makes it easy for others to grasp, explain what it should do, and then what it’s actually doing.

Unfortunately, I can’t help you as I don’t use this feature. If you come across something that seems to be a bug, it’s always worth checking Github. Here’s a search of “ephemeris”, and there are some very similar open issues.

Good luck!

I am new to the forum. Thought I was doing it correctly. I just wanted to keep the new findings on the one topic by editing it.

When you say “The way to do that is to add new posts to your original thread and build on your earlier findings” does that mean I rely to myself? Is that how I add the new posts to the original findings?

Getting used to the forum still.
Thanks for the reply.

Yep, just reply to yourself. Then people see that you’re still working on the issue, and it’s easy to understand your progress.

You just want to avoid overwhelming others with information. The more focus and structure there is to the information you provide, the easier it is to figure out how to help.

There’s a balance to this, of course. We often get new members posting one line that essentially reads, “help me”. And then we have to go back and forth trying to get enough detail from them to actually help. It’s exhausting in a different way.

I have looked in the github open issues for ephemeris and nothing like what I am seeing is there probably because the ephemeris is working but the rule isn’t seeing it. That is the part I don’t know. What I do know is is I just press save or disable and re-enable the rule it works, so I think it may be more rule related. It seems like the rule just keeps the setting at that point of time and never changes.

I have written other rules in the meantime in javascript to check for weekend or weekdays and they are working OK.

I was wondering more if anyone else has noticed this.

The OH3 is great once you get used to it. I have come from OH2.5 and I have done everything in OH3 via the GUI (I do like the text files better and like vim) and I have converted all the DSL to javascript and this is why I noticed the weekend rule issue.

Thanks again.

Here is my JavaScript for checking if a weekend. Not sure if there is a better way to do it but it works:

var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);

var Exec = Java.type("org.openhab.core.model.script.actions.Exec");
var Duration = Java.type("java.time.Duration");

//calculate the day number
var datetoday = new Date();
var numberofweek = datetoday.getDay();

//The ephemeris doesn't seem to work so I have created this rule to run on weekends
//See if Saturday or Sunday if not then it is a week day

if ( numberofweek == 0 
    || numberofweek == 6) {
  events.sendCommand("Subfloorfan_Subfloorfan", 'ON');
     logger.info('Weekend sub floor fan ON ' + numberofweek );
}


Here is the weekday rule:

var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);

var Exec = Java.type("org.openhab.core.model.script.actions.Exec");
var Duration = Java.type("java.time.Duration");

//calculate the day number
var datetoday = new Date();
var numberofweek = datetoday.getDay();

//The ephemeris doesn't seem to work so I have created this rule to run on weekdays and weekends
//See if Saturday or Sunday if not then it is a week day

if ( numberofweek != 0 
    && numberofweek != 6) {
  events.sendCommand("Subfloorfan_Subfloorfan", 'ON');
     logger.info('Week day sub floor fan ON ' + numberofweek );
}
  

Good stuff. You can also just have one rule with an if/else statement to capture both options.