Astro set#event used in two .rules files only executes one

  • Platform information:
    • Hardware: rpi 3B+
    • OS: openhabianpi

I have setup a sunset with offset rules and it fires correctly however I am trying to use it in two seperate .rules files - one file for my lights and another for my blinds (rollershutters).

In my lights.rules I have this:

rule "Sunset offset rule"
when
	Channel 'astro:sun:home_offset15:set#event' triggered START
then
   logInfo("Sunset", "Sunset offset rule trigerred!")
   if (Entry_FrontGarden_Lights.state != ON) Entry_FrontGarden_Lights.sendCommand(ON)
end

In my blinds.rules I have this:

rule "Sunset offset rule"
when
	Channel 'astro:sun:home_offset15:set#event' triggered START
then
    logInfo("Blinds", "Sunset offset rule trigerred!")
    Office_Front_Blinds.sendCommand(100)
    Office_Side_Blinds.sendCommand(75)
    if (Astro_Season.state.toString.contains("WINTER")) {
        Courtyard_Door_Blind.sendCommand(100)
        Courtyard_LHS_Blinds.sendCommand(100)
        Courtyard_RHS_Blinds.sendCommand(100)
    }
    if (Astro_Season.state.toString.contains("SPRING")) {
        Courtyard_Door_Blind.sendCommand(50)
        Courtyard_LHS_Blinds.sendCommand(50)
        Courtyard_RHS_Blinds.sendCommand(50)
    }   
    if (Astro_Season.state.toString.contains("SUMMER")) {
        Courtyard_Door_Blind.sendCommand(0)
        Courtyard_LHS_Blinds.sendCommand(0)
        Courtyard_RHS_Blinds.sendCommand(0)
    } 
    if (Astro_Season.state.toString.contains("AUTUM")) {
        Courtyard_Door_Blind.sendCommand(50)
        Courtyard_LHS_Blinds.sendCommand(50)
        Courtyard_RHS_Blinds.sendCommand(50)
    }  
end

when the event triggered today this was all that was recorded in the logtail:

2018-08-22 17:38:00.013 [vent.ChannelTriggeredEvent] - astro:sun:home_offset15:set#event triggered START

==> /var/log/openhab2/openhab.log <==

2018-08-22 17:38:01.760 [INFO ] [clipse.smarthome.model.script.Blinds] - Sunset offset rule trigerred!

==> /var/log/openhab2/events.log <==

2018-08-22 17:38:01.774 [ome.event.ItemCommandEvent] - Item 'Office_Front_Blinds' received command 100

2018-08-22 17:38:01.791 [ome.event.ItemCommandEvent] - Item 'Office_Side_Blinds' received command 75

2018-08-22 17:38:01.800 [vent.ItemStateChangedEvent] - Office_Front_Blinds changed from 27.0 to 100

2018-08-22 17:38:01.804 [ome.event.ItemCommandEvent] - Item 'Courtyard_Door_Blind' received command 100

2018-08-22 17:38:01.809 [ome.event.ItemCommandEvent] - Item 'Courtyard_LHS_Blinds' received command 100

2018-08-22 17:38:01.812 [vent.ItemStateChangedEvent] - Office_Side_Blinds changed from 0.0 to 75

2018-08-22 17:38:01.818 [ome.event.ItemCommandEvent] - Item 'Courtyard_RHS_Blinds' received command 100

2018-08-22 17:38:01.833 [vent.ItemStateChangedEvent] - Courtyard_Door_Blind changed from 0.0 to 100

2018-08-22 17:38:01.840 [vent.ItemStateChangedEvent] - Courtyard_LHS_Blinds changed from 0.0 to 100

2018-08-22 17:38:01.843 [vent.ItemStateChangedEvent] - Courtyard_RHS_Blinds changed from 0.0 to 100

So you can see the blinds.rules offset rule triggered ok but the one in lights.rules did not. Is this something I need to code around by combining the rules into one file - it kind of makes it clunky and hard to manage if you cannot have rules for the specific device types listed together.

Similar thread (yes it ought to work, but you need to check OH version)

The rules can’t have the same name.

1 Like

Well spotted! Definitely a rule stopper.

Thanks very much excellent support again. Will adjust the rules names and test.

If you have many more rule like this that trigger based on solar events and Time you might benefit from Design Pattern: Time Of Day so centralize the calculation and generation of these events.