Http binding only works on manual switch, not when triggerd by rule

Hello community,
I’ve got a little problem, and I’m kind of stuck. I can switch the switches (http binding) manually, but if they are switched via a rule, it just doesn’t work.

is there something wrong with my configuration?

lights.items:

Group:Switch:OR(ON,OFF) Lights "Alle Lampen"

Switch Wohnzimmer "Licht Wohnzimmer" (Lights) { http=">[ON:GET:http://192.168.15.53:5001/control?device=wohnzimmer&state=on] >[OFF:GET:http://192.168.15.53:5001/control?device=wohnzimmer$

Switch Kueche "Licht Küche" (Lights) { http=">[ON:GET:http://192.168.15.53:5001/control?device=kueche&state=on] >[OFF:GET:http://192.168.15.53:5001/control?device=kueche&state=off]" }

Switch Flur "Licht Flur" (Lights) { http=">[ON:GET:http://192.168.15.53:5001/control?device=flur&state=on] >[OFF:GET:http://192.168.15.53:5001/control?device=flur&state=off]" }

Switch Flur2 "Licht Wohnzimmer-Flur" (Lights) { http=">[ON:GET:http://192.168.15.53:5001/control?device=wohnzimmer-flur&state=on] >[OFF:GET:http://192.168.15.53:5001/control?device=wohnz$

Switch Flur3 "Licht Flur oben" (Lights) { http=">[ON:GET:http://192.168.15.53:5001/control?device=flur-oben&state=on] >[OFF:GET:http://192.168.15.53:5001/control?device=flur-oben&state=o$

Switch Kinderzimmer "Licht Kinderzimmer" (Lights) { http=">[ON:GET:http://192.168.15.53:5001/control?device=kinderzimmer&state=on] >[OFF:GET:http://192.168.15.53:5001/control?device=kind$
rule "light off evening"
        when
                Time cron "0 30 22 * * ?"
        then
                Wohnzimmer.sendCommand(OFF)
                Kueche.sendCommand(OFF)
                Flur.sendCommand(OFF)
                Flur2.sendCommand(OFF)
                Flur3.sendCommand(OFF)
                //Lights.sendCommand(ON)
        end
rule "light on before sunset"
        when
                Channel 'astro:sun:home-evt:set#event' triggered START
        then
                Wohnzimmer.sendCommand(ON)
                Kueche.sendCommand(ON)
                Flur.sendCommand(ON)
                Flur2.sendCommand(ON)
                Flur3.sendCommand(ON)
        end

in the log I can see that the rule works, but the light is still on. I can turn it off via the app or basicui

log:

2018-08-27 22:29:37.428 [vent.ItemStateChangedEvent] - Current_DateTime changed from 2018-08-27T22:28:37.359+0200 to 2018-08-27T22:29:37.360+0200
2018-08-27 22:30:00.631 [ome.event.ItemCommandEvent] - Item 'Wohnzimmer' received command OFF
2018-08-27 22:30:00.651 [ome.event.ItemCommandEvent] - Item 'Kueche' received command OFF
2018-08-27 22:30:00.668 [ome.event.ItemCommandEvent] - Item 'Flur' received command OFF
2018-08-27 22:30:00.671 [ome.event.ItemCommandEvent] - Item 'Flur2' received command OFF
2018-08-27 22:30:00.674 [ome.event.ItemCommandEvent] - Item 'Flur3' received command OFF
2018-08-27 22:30:00.815 [vent.ItemStateChangedEvent] - Wohnzimmer changed from ON to OFF
2018-08-27 22:30:00.834 [GroupItemStateChangedEvent] - Lights changed from ON to OFF through Flur3
2018-08-27 22:30:00.842 [GroupItemStateChangedEvent] - Lights changed from ON to OFF through Flur2
2018-08-27 22:30:00.851 [vent.ItemStateChangedEvent] - Flur2 changed from ON to OFF
2018-08-27 22:30:37.409 [vent.ItemStateChangedEvent] - Current_DateTime changed from 2018-08-27T22:29:37.360+0200 to 2018-08-27T22:30:37.361+0200

What do you see in events.log?

Looks like the first command works, others fail? Noting all http are directed at the same box, I’d speculate it is busy dealing with the first command and ignores others arriving before it is finished.
Try putting a delay between commands.

It can be so easy. With Thread::sleep(1000) behind the sendcommands everything works

Thanks :slight_smile:

Plus it looks more impressive if things sequence up in turn :wink:

Electricians would say it’s say it is kinder in spreading startup surge loads as well.

Beware that a rule with long delays is hogging limited resources, and can delay other rules starting or running.
There are complicated ways around that using timers to schedule things instead, but probably not necessary where you’re only running it twice a day.

Example

rule "sequence lights ON"
when
   your trigger
then
   LightAA.sendCommand(ON)       // now
   createTimer(now.plusSeconds(1))  [  |
       LightBB.sendCommand(ON)     // in one seconds time
      ]
   createTimer(now.plusSeconds(2))  [  |
       LightCC.sendCommand(ON)     // in two seconds time
      ]
end

This rule finishes quickly, having created a series of timers that will “go off” at different future times, each then executing its own little code block. (in this case, just a sendCommand)

the solution with timer is nice :slight_smile:

for everyone who finds this thread: I use this config to control my exisiting pilight installation…