OpenHAB rule trigger failure

Platform:
Raspberry Pi 4 with 4 GB
OpenHAB 3

Description:
I am using a rule to start a pump at minutes 0, 20 and 40 between 06:00 and 13:59, Monday to Friday, and a similar rule to stop the same pump 5 minutes later. The pump is connected through a Shelly Plug-S.
I used the cron expressions: “0 0,20,40 6-13 ? * MON-FRI” and “0 5,25,45 6-13 ? * MON-FRI” to trigger the rules to start and stop the pump (send ON and OFF commands to the plug), and the result was that the starting and stopping of the pump was irregular (sometimes the pump did not start, others it would not stop).
Changing the cron expressions to “0-3 0,20,40 6-13 ? * MON-FRI” and “0-3 5,25,45 6-13 ? * MON-FRI” solved the problem.
This solution may send 1 or more commands in the 3 second period. Repeating the commands to the plug seems to be acceptable (to the plug) and the result is the expected sequence of start/stop actions.
Any hint on what is wrong?
Thanks

Do i understand it correctly, that you have a simple rule and you want to:

  1. start the pump on 0,20,40 minutes
  2. stop the pump everytime 5 mins later

There’s a more elegant solution to this: using “expire”, so you can define on an item, what should happen to a specific time after the last value change.

in OH3 you can do this also conveniently within the GUI. Go to the item, click on “Add Metadata” and “Expiration timer”. There you can chose, what should happen after a specific period of time.

This is, if your item works correctly in the first place. So if you still have problems, you should check:

  • does the Shelly Plug have a stable WiFi connection and
  • is the Shelly Plug correctly defined in the Shelly binding

I use 2 rules, one to start and another to stop the pump.
The Wi-Fi seems ok since, when using manual commands, I have no failures.

As I said, the more elegant solution would be to work with the “Expiration”-Metadata.
Apart from that, your two-rule solution should still work.

But to fully assess your setup, please open the two rules, switch to “Code” on top of the rule and paste both rules here (be sure to use code fences for better readability - one of the icons at the top here if writing)

configuration: {}
triggers:

  • id: “1”
    configuration:
    cronExpression: 0-3 0,20,40 6-13,19-21 ? * MON-FRI
    type: timer.GenericCronTrigger
    conditions:
  • inputs: {}
    id: “3”
    configuration:
    itemName: WaterPumpAutoMode
    state: ON
    operator: =
    type: core.ItemStateCondition
    actions:
  • inputs: {}
    id: “2”
    configuration:
    command: ON
    itemName: WaterPumpPlug_Control
    type: core.ItemCommandAction

Rule 2 - Pump stop

configuration: {}
triggers:

  • id: “1”
    configuration:
    cronExpression: 0-3 5,25,45 6-13,19-21 ? * MON-FRI
    type: timer.GenericCronTrigger
    conditions:
  • inputs: {}
    id: “3”
    configuration:
    itemName: WaterPumpAutoMode
    state: ON
    operator: =
    type: core.ItemStateCondition
    actions:
  • inputs: {}
    id: “2”
    configuration:
    command: OFF
    itemName: WaterPumpPlug_Control
    type: core.ItemCommandAction

please put your code into ``` code fences before and after the code, that makes it readable - and you can copy it much more easy.

as far as I can see, there’s nothing wrong with the rules. So the problem is not the rules, but something other. What makes me wonder is:

“manual commands” mean you use openHAB to manually send ON/OFF to the shelly plug?
Is there any hint in the logs?

The pump as an “Auto Mode” and a “Manual Mode”. The state of the “WaterPumpAutoMode” item is used the allow/block the action of the rule.
The pump can also be controlled using the OpenHAB UI (remote control of the Shelly Plug, without using the rule). I did not notice any failures when using the “manual” control.
I will try to insert some logs to check the triggering if the rule.
Thanks for the help.

I checked the logs and I found several lines like this:
2022-04-22 13:20:15.692 [WARN ] [y.internal.handler.ShellyBaseHandler] - shellyplug-s-881b5f: ERROR: Unable to process command ON for channel shelly:shellyplugs:881b5f:relay#output - Device unreachable or API Timeout ()
I moved the AP, the plug is connected to, closer to the Shelly Plug and changed the cron expression to “0 0,20,40…”.(no retries)
I got no more “ERROR” messages and the pump starts and stops at the expected times.
Thanks for your hints.

I should have examined the logs before starting theis topic.
:slight_smile:

I would use the auto off function on the shelly himselve and only send the pump on cmd. That way you would prevent that the pump stays on if the plug is not reachable anymore after you send the switch on cmd.

1 Like