Your if() condition is a bit suspect. The hour needs to be less than 6 and more than 17 at the same time.
The rule will only run when your Item changes to ON but will only do something when it is not ON.
Thx for your input.
i understand time issue but.not sure hov to adress . but will only do something when it is not ON.
I donât know what youâre trying to achieve âŠ
The rule will run when the Item changes to ON
Perhaps thatâs not right - when do you want the rule to run?
A few milliseconds after the rule begins to run âŠ
Your if() only evaluates to âtrueâ (and so runs the code in curly brackets) if your Item is now not-ON. It wonât be of course, because you only get here if its just changed to ON.
Itâs obviously not the right test, but I donât know what you want to test for - if anything.
Maybe put into words your objective.
if (now.getHourOfDay() >= 17 && now.getHourOfDay() > =6 && Kontor_spots.state != ON) {
Would this be after 5 pm and before 6 am in the morningâŠ
No.
You have to use OR.
OR is || in rules.
very briefly
I want to dim my HUE spots in the evening .
So when they are on i want them to be dimmedâŠSo action need to happen after they are on, otherwise they wont dim (hue)
Damn i just dont get itâŠ
Why OR ?
I guess both ârequirementsâ needs to be fullfilledâŠ
Is there a number that is less than 6 and simultaneously greater than 17?
hahaha âŠI have so much to learnâŠ
Okay, youâve got to really think about the rule trigger here.
Youâd want to run your rule when evening begins, fairly obviously.
But to do as asked you would also want to run the rule whenever the spots change in any way. So that if they turn on, they get forced to 40%, If anyone turns them up or down, set back to 40%.
Youâd want two conditions inside your rule -
âIs it evening?â so that the rule does not interfere at other times.
âare the spots on?â so that the rule does not interfere if they are off - they can be turned off even during evening
If thatâs not exactly what you want (do you really want to stop people turning them up or down during the evening?) then you have to modify your requirement.
Setting out what you are trying to do clearly goes a long way to writing a rule.
Let me start from the backâŠ
Setting out what you are trying to do clearly goes a long way to writing a rule.
Absolutely⊠correct .and your input is very valuableâŠ
Youâd want to run your rule when evening begins, fairly obviously.
correct i just set it to 5 oclock for testing ,when live it will be changed to bedtime
But to do as asked you would also want to run the rule whenever the spots change in any way. So that if they turn on, they get forced to 40%, If anyone turns them up or down, set back to 40%.
Ok i need to explain more. i want to dim the light at bedtime ,so bathroom visits will be dimmed.
On top of that i would like the oppertunity to be able to push lightswitch and increase to 100% if needed
Youâd want two conditions inside your rule -
âIs it evening?â so that the rule does not interfere at other times.CORRECT
âare the spots on?â so that the rule does not interfere if they are off - they can be turned off even during evening also CORRECT
If thatâs not exactly what you want (do you really want to stop people turning them up or down during the evening?) then you have to modify your requirement.
Yes as stated above .Turning up IS relevant .turning down not so much,since its for ânight lightâ
does that make sence ?
BTW ligths are controlled by PIR ,so on/off are automatic and only when it is dark
Okay, letâs see if I can restructure that.
At bedtime, if the and only if the lights if are on, dim to 40% (what if they are already less than 40%?)
If someone comes along after bedtime and turns them up, down, off, or on - donât interfere.
That seems to be it.
Trigger a rule at bedtime,
if the light is on set to 40%
(what if they are already less than 40%?)
Very simple question they are not. they have never been dimmed other than for testing..and i dont see why they should other than after bedtime..
If someone comes along after bedtime and turns them up, down, off, or on - donât interfere.
Exactly
That seems to be it.
Trigger a rule at bedtime,
if the light is on set to 40%
yes that was my idea⊠But how to do that is my problemâŠ
Add Jython and the helper libraries withâŠ
Then copy over the script fromâŠ
⊠and configure the metadata in your Items. Thereâs an example very much like what you ware trying to do.
Trigger a rule at bedtime.
Thatâs a time-based trigger, uses a cron
expression
if the light is on set to 40%
Itâs not that difficult, but we can break it down
if the light is on
if ( mylightItem.state == ON ) {
do stuff
}
BUT ⊠itâs a dimmer, the state is numeric
if ( mylightItem.state as Number > 0 ) { // one way to test a dimmer for on
do stuff
}
if the light is on set to 40%
You can do that bit
thank your for your help.
I will look into it,at first chance
Have been playing around with this rules for months.And i just cant seem to get it to do what i want.
Running openHAB 3.1.0.M3 (openhabian ) on a pi.
Works when i run the rule. But it wont âtriggerâ by it self.
I get this warn: 2021-04-08 15:51:02.534 [WARN ] `
Not sure what i means ,and if that is my issue ?
[org.openhab.core.items.GenericItem ] - failed notifying listener âg_kontorlys (Type=GroupItem, BaseType=DimmerItem, Members=3, State=30.00000000, Label=Kontor spot, Category=light, Tags=[Control, Light], Groups=[g_kontor])â about state update of item Kontorspot3_Brightness: Value must be between 0 and 100
`
Solved