Help with a loop (Runs too fast / Ignores timers)

Hi everyone

I’m trying too make a loop for my security lighting rule

i have wrote it and tested but it does not behave as expected it send more than 38 commands in less than one second this took my hue bidge offline and also made OH go unresponsive

I have looked and looked but cant see why it would do this its like it was just ignoring the timers

rule "Away from home lighting"
when
    Item Away_from_home changed to ON
then
    createTimer(now.plusMinutes(60), [| 
        while(Away_from_home.state==ON) { 
            if (now.getMinuteOfDay > 421 && now.getMinuteOfDay < 1320 ) { // 7AM >< 10PM
                Ghouselights.sendCommand ("100")
                createTimer(now.plusMinutes(15), [| 
                    Ghouselights.sendCommand ("0")
                    createTimer(now.plusMinutes(25), [| 
                    ])
                ])
            }
            if (now.getMinuteOfDay > 1321 || now.getMinuteOfDay < 420 ) { // 7AM <> 10PM
                Guslights.sendCommand ("30")
                createTimer(now.plusSeconds(60), [| 
                    Guslights.sendCommand ("0")
                    createTimer(now.plusMinutes(132), [| 
                    ])
                ])
            }   
        }
    ])
end

from the log

2018-08-23 22:27:28.997 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:28.999 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:29.007 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:29.157 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:29.163 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:29.167 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:29.170 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:29.191 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:29.200 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:29.205 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:29.208 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:29.211 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:29.216 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:29.255 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:29.267 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:29.270 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:29.272 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 30 to 0
2018-08-23 22:27:29.276 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 30 to 0
2018-08-23 22:27:29.284 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 30 to 0
2018-08-23 22:27:29.287 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 0 to 30
2018-08-23 22:27:29.303 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:29.305 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:29.306 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:29.308 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:29.310 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:29.321 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:29.333 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 0 to 30
2018-08-23 22:27:29.341 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:29.343 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:29.345 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 0 to 30
2018-08-23 22:27:29.351 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:29.362 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:29.365 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:29.370 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:29.373 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:29.443 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:29.446 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 30 to 0
2018-08-23 22:27:29.448 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 30 to 0
2018-08-23 22:27:29.457 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 30 to 0
2018-08-23 22:27:29.462 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 0 to 30
2018-08-23 22:27:29.467 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 0 to 30
2018-08-23 22:27:29.471 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 0 to 30
2018-08-23 22:27:29.481 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:29.500 [GroupItemStateChangedEvent] - Guslights changed from 0 to 30.00000000 through BULB3LAMAIN_Brightness
2018-08-23 22:27:29.504 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:29.507 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 30 to 0
2018-08-23 22:27:29.510 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 30 to 0
2018-08-23 22:27:29.516 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:29.521 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:29.524 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:29.527 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 30 to 0
2018-08-23 22:27:29.531 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 0 to 30
2018-08-23 22:27:29.536 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 0 to 30
2018-08-23 22:27:29.538 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:29.540 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 0 to 30
2018-08-23 22:27:29.542 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:29.546 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:29.551 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:29.556 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:29.561 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:29.565 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:29.573 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:29.577 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:29.582 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:29.584 [GroupItemStateChangedEvent] - Guslights changed from 0 to 30.00000000 through BULB8USBATHROOM_Brightness
2018-08-23 22:27:29.588 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:29.590 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:29.611 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:29.615 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:29.642 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:29.649 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:29.653 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:29.666 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 30 to 0
2018-08-23 22:27:29.669 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 30 to 0
2018-08-23 22:27:29.673 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 30 to 0
2018-08-23 22:27:29.680 [GroupItemStateChangedEvent] - Guslights changed from 30.00000000 to 0.00000000 through BULB8USBATHROOM_Brightness
2018-08-23 22:27:29.682 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:29.687 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:29.689 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:29.695 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:29.704 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:29.718 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:29.721 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:29.731 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:29.854 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:29.860 [GroupItemStateChangedEvent] - Guslights changed from 0 to 30.00000000 through BULB3LAMAIN_Brightness
2018-08-23 22:27:29.863 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 0 to 30
2018-08-23 22:27:29.869 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 0 to 30
2018-08-23 22:27:29.872 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 0 to 30
2018-08-23 22:27:29.875 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:29.881 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:29.888 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:29.891 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:29.905 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 30 to 0
2018-08-23 22:27:29.909 [GroupItemStateChangedEvent] - Guslights changed from 0 to 30.00000000 through BULB3LAMAIN_Brightness
2018-08-23 22:27:29.912 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 30 to 0
2018-08-23 22:27:29.921 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:29.923 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 30 to 0
2018-08-23 22:27:29.931 [GroupItemStateChangedEvent] - Guslights changed from 30.00000000 to 0.00000000 through BULB5USTOILET_Brightness
2018-08-23 22:27:29.935 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:29.945 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:29.946 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:29.949 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 0 to 30
2018-08-23 22:27:29.962 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 0 to 30
2018-08-23 22:27:29.966 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 0 to 30
2018-08-23 22:27:29.981 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:29.983 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 30 to 0
2018-08-23 22:27:29.987 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 30 to 0
2018-08-23 22:27:29.989 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 30 to 0
2018-08-23 22:27:30.013 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:30.019 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:30.023 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:30.057 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:30.064 [GroupItemStateChangedEvent] - Guslights changed from 30.00000000 to 0.00000000 through BULB8USBATHROOM_Brightness
2018-08-23 22:27:30.084 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:30.159 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:30.161 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:30.180 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:30.183 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:30.185 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:30.187 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:30.226 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 0 to 30
2018-08-23 22:27:30.235 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 0 to 30
2018-08-23 22:27:30.241 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 0 to 30
2018-08-23 22:27:30.248 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:30.251 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:30.282 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:30.322 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:30.325 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:30.327 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:30.342 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:30.351 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:30.357 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 30 to 0
2018-08-23 22:27:30.360 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 30 to 0
2018-08-23 22:27:30.366 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 30 to 0
2018-08-23 22:27:30.371 [vent.ItemStateChangedEvent] - Plug7_Signal changed from -55 to -54
2018-08-23 22:27:30.394 [GroupItemStateChangedEvent] - Guslights changed from 30.00000000 to 0.00000000 through BULB5USTOILET_Brightness
2018-08-23 22:27:30.397 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:30.401 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:30.403 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:30.406 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 0 to 30
2018-08-23 22:27:30.422 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 0 to 30
2018-08-23 22:27:30.424 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:30.426 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 0 to 30
2018-08-23 22:27:30.429 [GroupItemStateChangedEvent] - Guslights changed from 0 to 30.00000000 through BULB8USBATHROOM_Brightness
2018-08-23 22:27:30.443 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 30 to 0
2018-08-23 22:27:30.447 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 30 to 0
2018-08-23 22:27:30.449 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:30.466 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:30.471 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:30.476 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:30.479 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:30.482 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:30.485 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:30.508 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 30 to 0
2018-08-23 22:27:30.519 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 0 to 30
2018-08-23 22:27:30.521 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 0 to 30
2018-08-23 22:27:30.523 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 0 to 30
2018-08-23 22:27:30.531 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 30 to 0
2018-08-23 22:27:30.533 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 30 to 0
2018-08-23 22:27:30.545 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:30.604 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 30 to 0
2018-08-23 22:27:30.607 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:30.610 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:30.612 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:30.615 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 0 to 30
2018-08-23 22:27:30.618 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 0 to 30
2018-08-23 22:27:30.623 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 0 to 30
2018-08-23 22:27:30.630 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:30.632 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:30.643 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:30.645 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:30.648 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:30.656 [GroupItemStateChangedEvent] - Guslights changed from 0 to 30.00000000 through BULB8USBATHROOM_Brightness
2018-08-23 22:27:30.666 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:30.691 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:30.775 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:30.780 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:30.784 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:30.786 [GroupItemStateChangedEvent] - Guslights changed from 0 to 30.00000000 through BULB3LAMAIN_Brightness
2018-08-23 22:27:30.788 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:30.792 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:30.794 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:30.802 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:30.810 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:30.903 [GroupItemStateChangedEvent] - Guslights changed from 0 to 30.00000000 through BULB3LAMAIN_Brightness
2018-08-23 22:27:30.909 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:30.914 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:30.933 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:30.937 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:30.941 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:30.945 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:30.951 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:30.955 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 30 to 0
2018-08-23 22:27:30.957 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:30.963 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 30 to 0
2018-08-23 22:27:30.971 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 30 to 0
2018-08-23 22:27:30.976 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:30.983 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:30.986 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:30.994 [GroupItemStateChangedEvent] - Guslights changed from 30 to 0.00000000 through BULB5USTOILET_Brightness
2018-08-23 22:27:30.998 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:31.008 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:31.013 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:31.026 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:31.032 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:31.034 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:31.046 [ome.event.ItemCommandEvent] - Item 'LivingRoomMotionProxy' received command OFF
2018-08-23 22:27:31.055 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:31.065 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:31.079 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:31.102 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:31.110 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:31.117 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:31.120 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:31.150 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:31.155 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 0 to 30
2018-08-23 22:27:31.171 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 0 to 30
2018-08-23 22:27:31.190 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:31.194 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 0 to 30
2018-08-23 22:27:31.214 [GroupItemStateChangedEvent] - Guslights changed from 0 to 30.00000000 through BULB5USTOILET_Brightness
2018-08-23 22:27:31.217 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:31.225 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 30 to 0
2018-08-23 22:27:31.231 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:31.243 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:31.249 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 30 to 0
2018-08-23 22:27:31.256 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 30 to 0
2018-08-23 22:27:31.262 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 0 to 30
2018-08-23 22:27:31.265 [GroupItemStateChangedEvent] - Guslights changed from 0 to 30.00000000 through BULB3LAMAIN_Brightness
2018-08-23 22:27:31.284 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 0 to 30
2018-08-23 22:27:31.286 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:31.288 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:31.291 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:31.292 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:31.295 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:31.299 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:31.459 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:31.461 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 0 to 30
2018-08-23 22:27:31.471 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:31.476 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:31.484 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:31.563 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:31.582 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 30 to 0
2018-08-23 22:27:31.588 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:31.590 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:31.603 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:31.608 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 30 to 0
2018-08-23 22:27:31.621 [GroupItemStateChangedEvent] - Guslights changed from 30.00000000 to 0.00000000 through BULB3LAMAIN_Brightness
2018-08-23 22:27:31.624 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 30 to 0
2018-08-23 22:27:31.627 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 0 to 30
2018-08-23 22:27:31.630 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 0 to 30
2018-08-23 22:27:31.632 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 0 to 30
2018-08-23 22:27:31.634 [GroupItemStateChangedEvent] - Guslights changed from 0.00000000 to 30.00000000 through BULB3LAMAIN_Brightness
2018-08-23 22:27:31.636 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:31.639 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:31.640 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:31.643 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:31.666 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:31.669 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:31.677 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:31.680 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 30 to 0
2018-08-23 22:27:31.685 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:31.687 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 30 to 0
2018-08-23 22:27:31.688 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 30 to 0
2018-08-23 22:27:31.691 [vent.ItemStateChangedEvent] - LivingRoomMotionProxy changed from ON to OFF
2018-08-23 22:27:31.697 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:31.699 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:31.701 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:31.713 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:31.732 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 0 to 30
2018-08-23 22:27:31.752 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 0 to 30
2018-08-23 22:27:31.761 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 0 to 30
2018-08-23 22:27:31.781 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:31.817 [GroupItemStateChangedEvent] - Guslights changed from 0 to 30.00000000 through BULB5USTOILET_Brightness
2018-08-23 22:27:31.834 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:31.844 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:31.852 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:31.948 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:31.950 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30
2018-08-23 22:27:31.953 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 30
2018-08-23 22:27:31.969 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 30
2018-08-23 22:27:31.987 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 0
2018-08-23 22:27:31.993 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 0
2018-08-23 22:27:31.995 [ome.event.ItemCommandEvent] - Item 'BULB8USBATHROOM_Brightness' received command 0
2018-08-23 22:27:31.998 [ome.event.ItemCommandEvent] - Item 'Guslights' received command 0
2018-08-23 22:27:32.011 [vent.ItemStateChangedEvent] - BULB3LAMAIN_Brightness changed from 30 to 0
2018-08-23 22:27:32.013 [vent.ItemStateChangedEvent] - BULB5USTOILET_Brightness changed from 30 to 0
2018-08-23 22:27:32.015 [vent.ItemStateChangedEvent] - BULB8USBATHROOM_Brightness changed from 30 to 0
2018-08-23 22:27:32.018 [ome.event.ItemCommandEvent] - Item 'BULB3LAMAIN_Brightness' received command 30
2018-08-23 22:27:32.019 [ome.event.ItemCommandEvent] - Item 'BULB5USTOILET_Brightness' received command 30

Thats repeated over and over again

I think you misunderstand what createTimer() does. It sets up the block of code between [ ] to be executed in the future … and then immediately carries on to the next line in the rule. There is no waiting around for the time to expire.
So you are creating lots and lots of Timers while whizzing around the while-loop.

while-loops are almost always a really bad idea in OpenHAB - it’s event driven. When X do that. When Y stop doing that. After time X, if we’re still doing that, stop doing that.

If you can clarify what you are trying to make happen we can probably outline the way to go about it?

Hi @rossko57 thanks for the reply

I’m trying too create an away from home lighting schedule i would like too make more advanced with individual lights changing but got too start somewhere this is how far i got

it should
Wait 1 hour before starting and runs a different loop depending on the time of day

7AM & <10PM set all lights too on leave them on for 15 mins then turn them off and wait 25 mins before running / turning on again

1AM & <7AM set upstairs lights to 30% wait 60 seconds turn off wait 2 hours before turning back on

but now you have mentioned the timer block stuff i can see an error in my judgement i was expecting the same as thread::sleep but that approach is not recommended as there are long waits

That’s what was happening and it was definitely whizzing

Okay, that’s quite complicated. A limitation of createTimer() is that it runs its block of code once only. That makes it difficult to create cascading timers that follow on from each other, as each timer would have to contain all of the code to create all of the follow-on timers.

Some ideas in this old thread - basic approach is to run rule periodically and do random things

Here’s a completely different approach, that won’t suit everyone

1 Like

I thought it would be the simple approach and would just get something up and running maby not :wink:

Thanks for both the links i will look into them if this post doesn’t get more attention

i do like the idea of one using last weeks persistence data too trigger items its in the post you linked


that would also save the need for making the rule more advanced

There are smarter ways to do this, for example using some sort of random when switching lights, which lights, and how long to switch on the lights, but it’s no problem to do the job :wink:

var Timer tAway = null                                            // define a global var for the timer

rule "Away from home lighting"
when
    Item Away_from_home changed                                   // take care of both states
then
    if (Away_from_home.state != ON) {                             // somebody is there (or NULL)
        tAway.cancel                                              // so stop timer
        tAway = null                                              // initialize
        Ghouselights.sendCommand (0)                              // switch off lights
        Guslights.sendCommand(0)
    }
    else {                                                        // nobody at home anymore, so
        if(tAway != null) tAway.cancel                            // cancel old timer, if there is one (just in case...)
        tAway = createTimer(now.plusHours(1), [ |                 // first schedule, wait an hour
            if(now.getHourOfDay > 6 && now.getHourOfDay < 22 ) {  // 6.a.m. to 10 p.m.?
                if((Guslights.state as Number) > 0)
                    Guslights.sendCommand(0)                      // switch off Guslight if on
                if((Ghouselights.state as Number) < 100) {        // switch on Ghouselight if off
                    Ghouselights.sendCommand (100)
                    tAway.reschedule(now.plusMinutes(15))         // and reschedule timer
                }
                else {                                            // if Ghouselight is on
                    Ghouselights.sendCommand (0)                  // switch off
                    tAway.reschedule(now.plusMinutes(25))         // and reschedule timer
                }
            }
            else {                                                // time between 10 p.m. and 6 a.m.
                if((Ghouselights.state as Number) > 0) 
                    Ghouselights.sendCommand (0)                  // switch off Ghouselight of on
                if((Guslights.state as Number) < 30) {            // switch on Guslight if off
                    Guslights.sendCommand(30)
                    tAway.reschedule(now.plusMinutes(1))          // reschedule timer
                }
                else {                                            // if Guslight is on
                    Guslights.sendCommand(0)                      // switch off
                    tAway.reschedule(now.plusMinutes(132))        // reschedule timer
                }
            }
        ]
    }
end

I’ve got DPs for everything. :smiley:

I think I was the one who originally came up with that idea. I’ve often wondered if I should write it up as a DP. Maybe I should.

Anyway, to implement what you are trying to do correctly I think you would do something like (note I’ll assume Design Pattern: Time Of Day) the following. It think the behavior you are after is every hour to send a command to some lights, wait for a time, then send the command off, then wake up in some number of minutes and do it again:

val Timer awayFromHomeTimer = null
val Timer offTimer = null

rule "Away from home lighting"
when
    Item Away_from_home changed
then
    // cancel the timer if someone comes home
    if(Away_from_home.state == OFF && awayFromHomeTimer !== null) {
        awayFromHomeTimer.cancel
        awayFromHomeTimer = null
        offTimer.cancel
        offTimer = null
        return;
    }

    // Ignore the command if there is already a Timer (this should never happen)
    else if(awayFromHomeTimer !== null) return;

    awayFromHomeTimer = createTimer(now.plusSeconds(60), [  
        var lightsState = if(TimeOfDay.state == "DAY") 100 else 30 // I'm assuming Ghouselights is a Number Item
        var lights = if(TimeOfDay.state == "DAY") Ghouselights else GusLights
        var offTime = if(TimeOfDay.state == "DAY") 15 else 1
        var reschedule = if(TimeOfDay.state == "DAY") 25 else 132

        if(Away_from_home == ON) {
            lights.sendCommand(lightsState)
            offTimer = createTimer(now.plusMinutes(offTime), [ |
                lights.sendCommand(0)
                offTimer = null
            ]
            awayFromHomeTimer.reschedule(now.plusMinutes(reschedule))
        }
        else awayFromHomeTimer = null
    ]
end

I have to say, this is not pretty code but I think it does what you originally intended using Timers. I’d highly recommend using one of the other approaches discussed on the thread rossko57 linked to.

1 Like

Thanks for the replys im going too have ago again later will post updates

I’m thinking of using the persistence from last week from the post above