Time is triggeringItem

I was excited to use the Time is trigger, but my normal design pattern doesn’t work here. I have a rule like this:

rule "Trigger on DateTime"
    // group DateTime members are not ready as of this Openhab version, otherwise it would look like
    // Member of gEndZones updated
    Time is end_CCK1 or
    Time is end_CCN1 or
    Time is end_CCC1 or
    Time is end_CCMR or
    Time is end_CCNW or
    Time is end_CCNE or
    Time is end_CCSW or
    Time is end_CCSE or
    Time is end_OCK1 or
    Time is end_OCK2 or
    Time is end_OCK3 or
    Time is end_OCK4 or
    Time is end_OCK5 or
    Time is end_OCD1 or
    Time is end_OCD2 or
    Time is end_OCD3 or
    Time is end_OCR1 or
    Time is end_OCR2 or
    Time is end_OCR3 or
    Time is end_OCMR or
    Time is end_SSMR or
    Time is end_SSSB or
    Time is end_SSSW or
    Time is end_SSSE
    var String root = triggeringItem.name.split("_").get(1)
    var istr_set = "setpoint_heat_" + root
    var istr_unoc = "setpointHeatUnoccupied_" + root
    if (ScriptServiceUtil.getItemRegistry.getItems(istr_set).size>0) {  // check if it exists
        var mySetHeat = ScriptServiceUtil.getItemRegistry.getItem(istr_set) as NumberItem
        var mySetHeatUnoc = ScriptServiceUtil.getItemRegistry.getItem(istr_unoc) as NumberItem
        mySetHeat.sendCommand(mySetHeatUnoc.state as Number)

When the time criteria is triggered, I get the following:
2024-04-06 18:20:00.771 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘hvac-1’ failed: The name ‘triggeringItem’ cannot be resolved to an item or type; line 35, column 23, length 14 in hvac

So, this all makes sense. Is there any implicit variable that holds information that allows me to pull out which DateTime caused the trigger? I could do a comparison and find the closest match, but it is possible that two DateTimes are identical, so I would need to keep context of which one has been processed, and that gets pretty ugly.
And since we are on this, if two DateTimes are identical, does this rule trigger twice? I haven’t checked for this possibility.

Use triggeringItemName as implicit variable as these rule triggers are not group based. Therefor there is no implicit var triggeringItem.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.