Rules to only fire when its :00 or :30

hi @rlkoshak,
i now spent some time testing the behaviour of your rules code…but it seems that after it goes below 23V and setting the _timer switch to ON in never again goes OFF after Volt go higher than the threshold…so its dead-locked after the first email-notification (forever). From the code i understand that the behaviour has to be like this but i’m no that good to change it myself accordingly that after a Voltage higher 23V again the notification is reset so if later it goes bleow 23 again the notification would be sent…as i guess its expected to work.

2018-11-18 22:03:43.187 [ome.event.ItemCommandEvent] - Item 'PVislandVolt' received command 24.45
2018-11-18 22:03:43.197 [vent.ItemStateChangedEvent] - PVislandVolt changed from NULL to 24.45
2018-11-18 22:03:43.231 [vent.ItemStateChangedEvent] - PVislandVolt_Timer changed from NULL to OFF
2018-11-18 22:24:49.961 [ome.event.ItemCommandEvent] - Item 'PVislandVolt' received command 22.45
2018-11-18 22:24:49.995 [vent.ItemStateChangedEvent] - PVislandVolt changed from 24.45 to 22.45
2018-11-18 22:24:52.318 [ome.event.ItemCommandEvent] - Item 'PVislandVolt_Timer' received command ON
2018-11-18 22:24:52.324 [vent.ItemStateChangedEvent] - PVislandVolt_Timer changed from OFF to ON
2018-11-18 22:25:25.909 [ome.event.ItemCommandEvent] - Item 'PVislandVolt' received command 23.45
2018-11-18 22:25:25.929 [vent.ItemStateChangedEvent] - PVislandVolt changed from 22.45 to 23.45

hi @rlkoshak,
i now adapted your rule set to a more simplified version that seems to work. Can you please please have a check and let me know if this would be a stable rule set or if something is missing or should be more like yours… from above you can see that the pure rich-ruleset does never go back to normal state…maybe you can check this as well as yours looks more pro-level.

//***************************************************************************************************
rule “PVisland Voltage below 23V Alert - Notification”
when
Item PVislandVolt changed
then
if (PVislandVolt.state == NULL) return;
if (PVislandVolt_Timer.state == ON) return;
if (PVislandVolt.state < 23) {
sendMail(“norbert.jasdfasdfase.com”, "PVisland | Battery Voltage Level Alert | " + PVislandVolt.state + “V”, “—EoM—”)
PVislandVolt_Timer.sendCommand(ON)
}
end

rule “PVisland Voltage below 23V Alert - Return to Normal”
when
Item PVislandVolt changed
then
if (PVislandVolt.state == NULL) return;
if (PVislandVolt_Timer.state == OFF) return;
if (PVislandVolt.state > 23) {
PVislandVolt_Timer.sendCommand(OFF) }
end

OK, there is a logic error in the original but it should be easy enough to fix.

We need to move the line where we turn the timer off further up the Rule and send it when the volt state is over 23 and then only send the alert message if there isn’t a timer running.

rule "PVisland Voltage below 23V Alert - Notification"
when
    Item PVislandVolt changed
then
    if(PVislandVolt.state == NULL) return;
    if(PVislandVolt.state >= 24) PVislandVolt_Timer.postUpdate(OFF)
    else if(PVislandVolt_Timer.state == OFF) {
        sendMail("norasdfasfdasfdm", "PVisland | Battery Voltage Level Alert | " + PVislandVolt.state + " V", "---EoM---")
        PVislandVolt_Timer.sendCommand(ON)
    }
end

Thanks…so this new rule replaces both rules from above i guess?

Is there a chance to change the rule so OFF is not always set when new values come in.
Something like:

if((PVislandVolt.state >= 24) && (xxxTimer==ON)) PVislandVolt_Timer.postUpdate(OFF)

No, the second Rule gets run when the Timer expires. You still need that one.

As for the OFF, that is a typo. It should be PVislandVolt_Timer.postUpdate(OFF), not sendCommand(OFF). Then the second rule (from my post) will not execute every time.