Hello to all.
I created a rule for my blinds to work depending on the light intensity and it works great, except for the time - it works all the time, although in crontime I prescribed it to work from 8 to 22, but at the same time it is executed every 15 minutes. I have tried various crontime options, but in the end the time interval is not respected.
rule "Jalyzi_Lux"
when
Time cron "* 0/15 8-22 ? * *"
then
{
if (ESP_Easy_Lux.state >= 800)
gShutter.sendCommand(100)
}
{
if (ESP_Easy_Lux.state <= 800)
if (ESP_Easy_Lux.state >= 500)
gShutter.sendCommand(75)
}
{
if (ESP_Easy_Lux.state <= 499)
if (ESP_Easy_Lux.state >= 200)
gShutter.sendCommand(50)
}
{
if (ESP_Easy_Lux.state <= 199)
if (ESP_Easy_Lux.state >= 0)
gShutter.sendCommand(0)
}
end
Itâs not clear what you are asking. Is the problem that the rule triggers every 15 minutes 24 hours a day, or the fact that itâs triggering every 15 minutes at all?
The given cron expression should execute every 15 minutes between the hours of 08:00 and 22:00.
Some other things I notice is that the code itself almost certainly doesnât do what you expect. While itâs syntactically correct it is very odd in the way itâs written. The { should go after the if statement, not before.
if (ESP_Easy_Lux.state >= 800){
gShutter.sendCommand(100)
}
if (ESP_Easy_Lux.state <= 800){
if (ESP_Easy_Lux.state >= 500){
gShutter.sendCommand(75)
}
}
if (ESP_Easy_Lux.state <= 499){
if (ESP_Easy_Lux.state >= 200){
gShutter.sendCommand(75)
}
}
if (ESP_Easy_Lux.state <= 199){
if (ESP_Easy_Lux.state >= 0){
gShutter.sendCommand(75)
}
}
And this code could be made much more concise:
var shutterState = 0
if (ESP_Easy_Lux.state >= 800) {
shutterState = 100
}
else if(ESP_Easy_Lux.state >= 500) {
shutterState = 75
}
else if(ESP_Easy_Lux.state >= 200){
shutterState = 50
}
// the default value of shutterState handles the case of 0-199
gShutter.sendCommand(shutterState)
Thank you for your help.
The problem is that it works 24 hours a day. I tried various options, read many topics and even saw the exact same code somewhere and it worked there.
For the primitiveness of the code, I apologize) this is my first rule and I did it for two days. But it does work as it should, even with the errors you listed.
I just noticed another interesting point - the command is issued a full minute once a second, that is, once every 15 minutes, not one command is issued to execute the rule, but as many as 60 (!) Ńommands.
rule "Zakritiye jalyzi vecherom"
when
Time cron "0 1 22 * * ?"
then
gShutter.sendCommand(DOWN)
end
rule "Otkritiye jalyzi utrom"
when
Time cron "0 1 8 * * ?"
then
gShutter.sendCommand(UP)
end
But I think it cannot affect this rule in any way, since it is performed only twice a day.
Looks interesting, Iâll test it tomorrow and let you know the results. Thank.